Commit b7dc7493 authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Scott Cyphers

Use git shallow clone if CMake >= 3.6. Remove BUILD_BYPRODUCTS. (#2469)

* Use git shallow clone if CMake >= 3.6. Remove BUILD_BYPRODUCTS.

* Fix ONNX, protobuf integration.
parent a6be6ea3
......@@ -311,6 +311,11 @@ if(NGRAPH_DEBUG_ENABLE)
add_definitions(-DNGRAPH_DEBUG_ENABLE)
endif()
if(NOT (${CMAKE_VERSION} VERSION_LESS 3.6))
set(NGRAPH_GIT_ARGS GIT_SHALLOW 1)
message(STATUS "nGraph using git shallow copy.")
endif()
#-----------------------------------------------------------------------------------------------
# External projects install directory
#-----------------------------------------------------------------------------------------------
......
......@@ -40,6 +40,7 @@ ExternalProject_Add(
PREFIX cldnn
GIT_REPOSITORY ${CLDNN_GIT_REPO_URL}
GIT_TAG ${CLDNN_GIT_LABEL}
${NGRAPH_GIT_ARGS}
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
......
......@@ -29,6 +29,7 @@ ExternalProject_Add(
PREFIX eigen
GIT_REPOSITORY ${EIGEN_GIT_URL}
GIT_TAG ${EIGEN_GIT_TAG}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
......
......@@ -52,6 +52,7 @@ ExternalProject_Add(
PREFIX gtest
GIT_REPOSITORY ${GTEST_GIT_REPO_URL}
GIT_TAG ${GTEST_GIT_LABEL}
${NGRAPH_GIT_ARGS}
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
......
......@@ -46,6 +46,7 @@ ExternalProject_Add(
DEPENDS ext_halide_llvm
GIT_REPOSITORY ${HALIDE_GIT_REPO_URL}
GIT_TAG ${HALIDE_GIT_TAG}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
......
......@@ -29,6 +29,7 @@ ExternalProject_Add(
PREFIX json
GIT_REPOSITORY ${JSON_GIT_REPO_URL}
GIT_TAG ${JSON_GIT_LABEL}
${NGRAPH_GIT_ARGS}
# Disable install step
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
......
......@@ -27,6 +27,7 @@ ExternalProject_Add(
PREFIX clang
GIT_REPOSITORY https://github.com/llvm-mirror/clang.git
GIT_TAG 26cac19a0d622afc91cd52a002921074bccc6a27
${NGRAPH_GIT_ARGS}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
......@@ -42,6 +43,7 @@ ExternalProject_Add(
PREFIX openmp
GIT_REPOSITORY https://github.com/llvm-mirror/openmp.git
GIT_TAG 29b515e1e6d26b5b0d32d47d28dcdb4b8a11470d
${NGRAPH_GIT_ARGS}
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
INSTALL_COMMAND ""
......@@ -64,6 +66,7 @@ ExternalProject_Add(
DEPENDS ext_clang ext_openmp
GIT_REPOSITORY https://github.com/llvm-mirror/llvm.git
GIT_TAG da4a2839d80ac52958be0129b871beedfe90136e
${NGRAPH_GIT_ARGS}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
......
......@@ -106,6 +106,7 @@ if (WIN32)
DEPENDS ext_mkl
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
CONFIGURE_COMMAND
# Patch gets mad if it applied for a second time so:
......@@ -142,6 +143,7 @@ else()
DEPENDS ext_mkl
GIT_REPOSITORY ${MKLDNN_GIT_REPO_URL}
GIT_TAG ${MKLDNN_GIT_TAG}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
CONFIGURE_COMMAND
# Patch gets mad if it applied for a second time so:
......
......@@ -31,6 +31,7 @@ ExternalProject_Add(
PREFIX MLSL
GIT_REPOSITORY ${MLSL_GIT_URL}
GIT_TAG ${MLSL_GIT_TAG}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
CONFIGURE_COMMAND ""
BUILD_COMMAND ${MAKE_EXE} -j 1 ENABLE_INTERNAL_ENV_UPDATE=1
......
......@@ -30,95 +30,29 @@ set(ONNX_VERSION 1.3.0)
set(ONNX_GIT_REPO_URL https://github.com/onnx/onnx.git)
set(ONNX_GIT_BRANCH rel-${ONNX_VERSION})
# The 'BUILD_BYPRODUCTS' arguments was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_onnx
PREFIX onnx
GIT_REPOSITORY ${ONNX_GIT_REPO_URL}
GIT_TAG ${ONNX_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF
-DProtobuf_PROTOC_EXECUTABLE=${Protobuf_PROTOC_EXECUTABLE}
-DProtobuf_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}
-DPROTOBUF_LIBRARY=${Protobuf_LIBRARY}
-DPROTOBUF_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}
-DPROTOBUF_SRC_ROOT_FOLDER=${Protobuf_SRC_ROOT_FOLDER}
-DONNX_ML=TRUE
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/bin"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx"
EXCLUDE_FROM_ALL TRUE
)
else()
if (${CMAKE_VERSION} VERSION_LESS 3.6)
ExternalProject_Add(
ext_onnx
PREFIX ext_onnx
GIT_REPOSITORY ${ONNX_GIT_REPO_URL}
GIT_TAG ${ONNX_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF
-DProtobuf_PROTOC_EXECUTABLE=${Protobuf_PROTOC_EXECUTABLE}
-DProtobuf_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}
-DPROTOBUF_LIBRARY=${Protobuf_LIBRARY}
-DPROTOBUF_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}
-DPROTOBUF_SRC_ROOT_FOLDER=${Protobuf_SRC_ROOT_FOLDER}
-DONNX_ML=TRUE
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/bin"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx"
BUILD_BYPRODUCTS ${EXTERNAL_PROJECTS_ROOT}/onnx/bin/libonnx_proto.a
${EXTERNAL_PROJECTS_ROOT}/onnx/bin/libonnx.a
EXCLUDE_FROM_ALL TRUE
)
else()
# To speed things up prefer 'shallow copy' for CMake 3.6 and later
ExternalProject_Add(
ext_onnx
PREFIX ext_onnx
GIT_REPOSITORY ${ONNX_GIT_REPO_URL}
GIT_TAG ${ONNX_GIT_BRANCH}
GIT_SHALLOW TRUE
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF
-DProtobuf_PROTOC_EXECUTABLE=${Protobuf_PROTOC_EXECUTABLE}
-DProtobuf_LIBRARY=${Protobuf_LIBRARY}
-DProtobuf_INCLUDE_DIR=${Protobuf_INCLUDE_DIR}
-DONNX_ML=TRUE
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/bin"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx"
BUILD_BYPRODUCTS ${EXTERNAL_PROJECTS_ROOT}/onnx/bin/libonnx_proto.a
${EXTERNAL_PROJECTS_ROOT}/onnx/bin/libonnx.a
EXCLUDE_FROM_ALL TRUE
)
endif()
endif()
ExternalProject_Add(
ext_onnx
PREFIX onnx
GIT_REPOSITORY ${ONNX_GIT_REPO_URL}
GIT_TAG ${ONNX_GIT_BRANCH}
${NGRAPH_GIT_ARGS}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DONNX_GEN_PB_TYPE_STUBS=OFF
-DCMAKE_PREFIX_PATH=${Protobuf_INSTALL_PREFIX}
-DONNX_ML=TRUE
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx/bin"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/onnx"
EXCLUDE_FROM_ALL TRUE
)
# -----------------------------------------------------------------------------
......
......@@ -24,85 +24,33 @@ include(ExternalProject)
set(PROTOBUF_GIT_REPO_URL https://github.com/google/protobuf.git)
set(PROTOBUF_GIT_BRANCH origin/3.5.x)
# The 'BUILD_BYPRODUCTS' arguments was introduced in CMake 3.2.
if (${CMAKE_VERSION} VERSION_LESS 3.2)
ExternalProject_Add(
ext_protobuf
PREFIX protobuf
GIT_REPOSITORY ${PROTOBUF_GIT_REPO_URL}
GIT_TAG ${PROTOBUF_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh && ./configure --disable-shared CXXFLAGS=-fPIC
BUILD_COMMAND ${MAKE}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf"
EXCLUDE_FROM_ALL TRUE
)
else()
if (${CMAKE_VERSION} VERSION_LESS 3.6)
ExternalProject_Add(
ext_protobuf
PREFIX protobuf
GIT_REPOSITORY ${PROTOBUF_GIT_REPO_URL}
GIT_TAG ${PROTOBUF_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh && ./configure --disable-shared CXXFLAGS=-fPIC
BUILD_COMMAND ${MAKE}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/protobuf/src/src/.libs/libprotobuf.a"
EXCLUDE_FROM_ALL TRUE
)
else()
# To speed things up prefer 'shallow copy' for CMake 3.6 and later
ExternalProject_Add(
ext_protobuf
PREFIX protobuf
GIT_REPOSITORY ${PROTOBUF_GIT_REPO_URL}
GIT_TAG ${PROTOBUF_GIT_BRANCH}
GIT_SHALLOW TRUE
INSTALL_COMMAND ""
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh && ./configure --disable-shared CXXFLAGS=-fPIC
BUILD_COMMAND ${MAKE}
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf"
BUILD_BYPRODUCTS "${EXTERNAL_PROJECTS_ROOT}/protobuf/src/src/.libs/libprotobuf.a"
EXCLUDE_FROM_ALL TRUE
)
endif()
endif()
# -----------------------------------------------------------------------------
ExternalProject_Add(
ext_protobuf
PREFIX protobuf
GIT_REPOSITORY ${PROTOBUF_GIT_REPO_URL}
GIT_TAG ${PROTOBUF_GIT_BRANCH}
${NGRAPH_GIT_ARGS}
UPDATE_COMMAND ""
PATCH_COMMAND ""
CONFIGURE_COMMAND ./autogen.sh COMMAND ./configure --prefix=${EXTERNAL_PROJECTS_ROOT}/protobuf --disable-shared CXX=${CMAKE_CXX_COMPILER} CXXFLAGS=-fPIC
TMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/tmp"
STAMP_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/stamp"
DOWNLOAD_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/download"
SOURCE_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf/src"
INSTALL_DIR "${EXTERNAL_PROJECTS_ROOT}/protobuf"
EXCLUDE_FROM_ALL TRUE
)
ExternalProject_Get_Property(ext_protobuf SOURCE_DIR BINARY_DIR)
# -----------------------------------------------------------------------------
# Use the interface of FindProtobuf.cmake
# -----------------------------------------------------------------------------
set(Protobuf_SRC_ROOT_FOLDER ${SOURCE_DIR})
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_SRC_ROOT_FOLDER}/src/protoc)
set(Protobuf_INCLUDE_DIR ${Protobuf_SRC_ROOT_FOLDER}/src)
set(Protobuf_LIBRARY ${Protobuf_SRC_ROOT_FOLDER}/src/.libs/libprotobuf.a)
set(Protobuf_INSTALL_PREFIX ${EXTERNAL_PROJECTS_ROOT}/protobuf)
set(Protobuf_PROTOC_EXECUTABLE ${Protobuf_INSTALL_PREFIX}/bin/protoc)
set(Protobuf_INCLUDE_DIR ${Protobuf_INSTALL_PREFIX}/include)
set(Protobuf_LIBRARY ${Protobuf_INSTALL_PREFIX}/lib/libprotobuf.a)
set(Protobuf_LIBRARIES ${Protobuf_LIBRARY})
if (NOT TARGET protobuf::libprotobuf)
......
......@@ -25,6 +25,7 @@ ExternalProject_Add(
PREFIX tbb
GIT_REPOSITORY ${TBB_GIT_REPO_URL}
GIT_TAG ${TBB_GIT_TAG}
${NGRAPH_GIT_ARGS}
SOURCE_DIR "${TBB_ROOT}"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
......
......@@ -24,6 +24,7 @@ ExternalProject_Add(
pybind11
GIT_REPOSITORY "https://github.com/pybind/pybind11.git"
GIT_TAG "v2.2.4"
${NGRAPH_GIT_ARGS}
SOURCE_DIR "${CMAKE_BINARY_DIR}/pybind11"
CONFIGURE_COMMAND ""
BUILD_COMMAND ""
......
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