Unverified Commit 2fe7f0f3 authored by Adam Procter's avatar Adam Procter Committed by GitHub

Allow caching of external dependencies (everything but TBB, which I can't figure out yet) (#473)

parent 4fa49e8e
......@@ -148,14 +148,14 @@ endif()
#-----------------------------------------------------------------------------------------------
# Root for external installs, when using `make`, e.g.
# ${EXTERNAL_INSTALL_DIR}
# ├── eigen <-- ${EIGEN_INSTALL_DIR}
# ${EXTERNAL_PROJECTS_ROOT}
# ├── eigen
# │   ├── include
# │   │   └── eigen3 <-- ${EIGEN_INCLUDE_DIR}
# │   │   ├── Eigen
# │ ...
# │
# └── mkldnn <-- ${MKLDNN_INSTALL_DIR}
# └── mkldnn
# ├── include <-- ${MKLDNN_INCLUDE_DIR}
# │   ├── mkldnn.h
# │ ...
......
......@@ -17,8 +17,6 @@
# Enable ExternalProject CMake module
include(ExternalProject)
set(EIGEN_INSTALL_DIR ${EXTERNAL_INSTALL_DIR}/eigen)
set(EIGEN_PROJECT eigen)
set(EIGEN_GIT_TAG d608d9f3f577118981acbdd40da9dcf6b514668a)
set(EIGEN_GIT_URL https://github.com/jmenon/eigen)
......@@ -29,25 +27,35 @@ set(EIGEN_GIT_URL https://github.com/jmenon/eigen)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
${EIGEN_PROJECT}
ext_eigen
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/eigen -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen"
)
else()
ExternalProject_Add(
${EIGEN_PROJECT}
ext_eigen
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EIGEN_INSTALL_DIR} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
BUILD_BYPRODUCTS "${EIGEN_INSTALL_DIR}/include/eigen3"
CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/eigen -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/eigen/include/eigen3"
)
endif()
#----------------------------------------------------------------------------------------------------------
ExternalProject_Get_Property(eigen source_dir binary_dir)
set(EIGEN_INCLUDE_DIR "${EIGEN_INSTALL_DIR}/include/eigen3" PARENT_SCOPE)
set(EIGEN_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/eigen/include/eigen3" PARENT_SCOPE)
......@@ -27,46 +27,53 @@ SET(GTEST_GIT_LABEL release-1.8.0)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
gtest
ext_gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest"
)
else()
ExternalProject_Add(
gtest
ext_gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/gtest
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
BUILD_BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest-build/googlemock/gtest/libgtest.a"
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock/gtest/libgtest.a"
)
endif()
#----------------------------------------------------------------------------------------------------------
# Get GTest source and binary directories from CMake project
ExternalProject_Get_Property(gtest source_dir binary_dir)
get_filename_component(
GTEST_INCLUDE_DIR
"${CMAKE_CURRENT_BINARY_DIR}/gtest/src/gtest/googletest/include"
"${EXTERNAL_PROJECTS_ROOT}/gtest/src/googletest/include"
ABSOLUTE)
set(GTEST_INCLUDE_DIR "${GTEST_INCLUDE_DIR}" PARENT_SCOPE)
# Create a libgtest target to be used as a dependency by test programs
add_library(libgtest IMPORTED STATIC GLOBAL)
add_dependencies(libgtest gtest)
add_dependencies(libgtest ext_gtest)
# Set libgtest properties
set_target_properties(libgtest PROPERTIES
"IMPORTED_LOCATION" "${binary_dir}/googlemock/gtest/libgtest.a"
"IMPORTED_LOCATION" "${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock/gtest/libgtest.a"
"IMPORTED_LINK_INTERFACE_LIBRARIES" "${CMAKE_THREAD_LIBS_INIT}"
)
......@@ -23,30 +23,40 @@ if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHE
set(RELEASE_TAG release_50)
set(EXTERNAL_INSTALL_LOCATION ${CMAKE_CURRENT_BINARY_DIR}/ext_llvm-prefix)
ExternalProject_Add(clang
ExternalProject_Add(ext_clang
GIT_REPOSITORY https://github.com/llvm-mirror/clang.git
GIT_TAG ${RELEASE_TAG}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/clang/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/clang/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/clang/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/clang/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/clang/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/clang"
)
ExternalProject_Get_Property(clang SOURCE_DIR)
ExternalProject_Get_Property(ext_clang SOURCE_DIR)
set(CLANG_SOURCE_DIR ${SOURCE_DIR})
ExternalProject_Add(openmp
ExternalProject_Add(ext_openmp
GIT_REPOSITORY https://github.com/llvm-mirror/openmp.git
GIT_TAG ${RELEASE_TAG}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
UPDATE_COMMAND ""
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/openmp"
)
ExternalProject_Get_Property(openmp SOURCE_DIR)
ExternalProject_Get_Property(ext_openmp SOURCE_DIR)
set(OPENMP_SOURCE_DIR ${SOURCE_DIR})
if(DEFINED CMAKE_ASM_COMPILER)
......@@ -56,13 +66,13 @@ if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHE
endif()
ExternalProject_Add(ext_llvm
DEPENDS clang openmp
DEPENDS ext_clang ext_openmp
GIT_REPOSITORY https://github.com/llvm-mirror/llvm.git
GIT_TAG ${RELEASE_TAG}
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_ASM_COMPILER=${LLVM_CMAKE_ASM_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_INSTALL_LOCATION}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/llvm
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=OFF
-DLLVM_INCLUDE_TESTS=OFF
......@@ -72,15 +82,20 @@ if((NGRAPH_CPU_ENABLE OR NGRAPH_GPU_ENABLE) AND (NOT ${CMAKE_SYSTEM_NAME} MATCHE
-DLLVM_EXTERNAL_CLANG_SOURCE_DIR=${CLANG_SOURCE_DIR}
-DLLVM_EXTERNAL_OPENMP_SOURCE_DIR=${OPENMP_SOURCE_DIR}
UPDATE_COMMAND ""
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm"
BUILD_BYPRODUCTS ${EXTERNAL_PROJECTS_ROOT}/llvm/lib/libLLVMCore.a
)
ExternalProject_Get_Property(ext_llvm SOURCE_DIR)
ExternalProject_Get_Property(ext_llvm BINARY_DIR)
ExternalProject_Get_Property(ext_llvm INSTALL_DIR)
set(LLVM_INCLUDE_DIR "${INSTALL_DIR}/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${SOURCE_DIR}/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${INSTALL_DIR}/lib" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/include" PARENT_SCOPE)
set(LLVM_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/include") # used by other external projects in current scope
set(LLVM_LIB_DIR "${EXTERNAL_PROJECTS_ROOT}/llvm/lib" PARENT_SCOPE)
set(LLVM_LINK_LIBS
clangTooling
......
......@@ -24,7 +24,6 @@ if(NGRAPH_CPU_ENABLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MKLDNN_GIT_REPO_URL https://github.com/intel/mkl-dnn)
set(MKLDNN_GIT_TAG "3e1f8f5")
set(MKLDNN_INSTALL_DIR ${EXTERNAL_INSTALL_DIR}/mkldnn)
# The 'BUILD_BYPRODUCTS' argument was introduced in CMake 3.2.
if(${CMAKE_VERSION} VERSION_LESS 3.2)
......@@ -38,7 +37,13 @@ if(NGRAPH_CPU_ENABLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
)
else()
ExternalProject_Add(
......@@ -51,8 +56,14 @@ if(NGRAPH_CPU_ENABLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${MKLDNN_INSTALL_DIR}
BUILD_BYPRODUCTS "${MKLDNN_INSTALL_DIR}/include/mkldnn.hpp"
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/build"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/mkldnn/include/mkldnn.hpp"
)
endif()
......@@ -67,7 +78,7 @@ if(NGRAPH_CPU_ENABLE AND NOT ${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
)
set(MKLDNN_INCLUDE_DIR "${MKLDNN_INSTALL_DIR}/include" PARENT_SCOPE)
set(MKLDNN_LIB_DIR "${MKLDNN_INSTALL_DIR}/lib" PARENT_SCOPE)
set(MKLDNN_INCLUDE_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/include" PARENT_SCOPE)
set(MKLDNN_LIB_DIR "${EXTERNAL_PROJECTS_ROOT}/mkldnn/lib" PARENT_SCOPE)
endif()
......@@ -249,7 +249,7 @@ if (NGRAPH_CPU_ENABLE AND LLVM_INCLUDE_DIR AND MKLDNN_INCLUDE_DIR)
# Generate the resource file containing all headers used by the codegen compiler
add_custom_target(header_resource
resource_generator --output ${CMAKE_BINARY_DIR}/header_resource.hpp --base codegen
DEPENDS resource_generator eigen ext_llvm ext_mkldnn
DEPENDS resource_generator ext_eigen ext_llvm ext_mkldnn
BYPRODUCTS
)
add_dependencies(ngraph header_resource)
......
......@@ -23,7 +23,7 @@ if (NGRAPH_CPU_ENABLE AND NOT APPLE)
)
add_executable(resource_generator ${SRC})
add_dependencies(resource_generator ext_llvm eigen ext_mkldnn)
add_dependencies(resource_generator ext_llvm ext_eigen ext_mkldnn)
set(HEADER_SEARCH_DEFINES
"EIGEN_HEADERS_PATH=\"${EIGEN_INCLUDE_DIR}\""
......
......@@ -174,7 +174,7 @@ endif()
target_link_libraries(unit-test ngraph libgtest pthread)
target_link_libraries(unit-test ${CMAKE_DL_LIBS})
add_dependencies(unit-test ngraph libgtest eigen)
add_dependencies(unit-test ngraph libgtest ext_eigen)
add_custom_target(style-check
COMMAND ${PROJECT_SOURCE_DIR}/maint/check-code-format.sh
......
......@@ -14,6 +14,10 @@
# limitations under the License.
# ******************************************************************************
if(NOT DEFINED EXTERNAL_PROJECTS_ROOT)
set(EXTERNAL_PROJECTS_ROOT ${CMAKE_CURRENT_BINARY_DIR})
endif()
include( ../cmake/external_gtest.cmake )
include( ../cmake/external_eigen.cmake )
include( ../cmake/external_mkldnn.cmake )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment