Commit 8763557d authored by Sang Ik Lee's avatar Sang Ik Lee Committed by Robert Kimball

Forward nGraph's C/C++ compiler, build type and generator information. (#2267)

* Forward nGraph's C/C++ compiler, build type and generator information to cmake based external projects.

* Fix typo.

* Pass generator related info properly.

* Googletest is using DEBUG_POSTFIX

* TBB uses postfix for debug lib.

* Fix typo.
parent 90503652
......@@ -60,6 +60,31 @@ if (UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if ("${CMAKE_GENERATOR}" MATCHES "^Visual Studio.*$")
set(MSVS TRUE)
endif()
# Setup CMAKE_ARGS to be forwarded to External Projects
set(NGRAPH_FORWARD_CMAKE_ARGS
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
)
if (NOT MSVS)
if(NOT CMAKE_BUILD_TYPE)
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=Release
)
else()
set(NGRAPH_FORWARD_CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
)
endif()
endif()
message(STATUS "NGRAPH_FORWARD_CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}")
# Prevent Eigen from using any LGPL3 code
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DEIGEN_MPL2_ONLY -DTBB_USE_THREADING_TOOLS")
......
......@@ -32,7 +32,7 @@ endif()
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (DEFINED NGRAPH_USE_CXX_ABI)
set(COMPILE_FLAGS "${COMPILE_FLAGS} -D_GLIBCXX_USE_CXX11_ABI=${NGRAPH_USE_CXX_ABI}")
endif()
endif()
endif()
ExternalProject_Add(
......@@ -43,9 +43,12 @@ ExternalProject_Add(
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
# -DCLDNN__OUTPUT_DIR=out/Debug
-DCMAKE_BUILD_TYPE=Release
-DCLDNN__BOOST_VERSION=${BOOST_VERSION}
-DCLDNN__INCLUDE_TESTS=FALSE
-DCLDNN__INCLUDE_TUTORIAL=FALSE
......
......@@ -34,8 +34,6 @@ endif()
set(GTEST_OUTPUT_DIR ${EXTERNAL_PROJECTS_ROOT}/gtest/build/googlemock/gtest)
set(GTEST_CMAKE_ARGS
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_FLAGS=${COMPILE_FLAGS}
)
if(WIN32)
......@@ -54,7 +52,12 @@ ExternalProject_Add(
# Disable install step
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS ${GTEST_CMAKE_ARGS}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
${GTEST_CMAKE_ARGS}
BINARY_DIR "${EXTERNAL_PROJECTS_ROOT}/gtest/build"
EXCLUDE_FROM_ALL TRUE
)
......@@ -66,4 +69,9 @@ ExternalProject_Get_Property(ext_gtest SOURCE_DIR BINARY_DIR)
add_library(libgtest INTERFACE)
add_dependencies(libgtest ext_gtest)
target_include_directories(libgtest SYSTEM INTERFACE ${SOURCE_DIR}/googletest/include)
target_link_libraries(libgtest INTERFACE ${GTEST_OUTPUT_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}gtest${CMAKE_STATIC_LIBRARY_SUFFIX})
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(GTEST_LIB_NAME gtestd)
else()
set(GTEST_LIB_NAME gtest)
endif()
target_link_libraries(libgtest INTERFACE ${GTEST_OUTPUT_DIR}/${CMAKE_STATIC_LIBRARY_PREFIX}${GTEST_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})
......@@ -46,11 +46,12 @@ ExternalProject_Add(
GIT_TAG ${HALIDE_GIT_TAG}
UPDATE_COMMAND ""
PATCH_COMMAND patch -p1 --forward --reject-file=- -i ${CMAKE_SOURCE_DIR}/cmake/halide.patch || exit 0
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DLLVM_DIR=${HALIDE_LLVM_DIR}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/halide
-DHALIDE_SHARED_LIBRARY=OFF
-DWITH_APPS=OFF
......
......@@ -61,12 +61,13 @@ ExternalProject_Add(
DEPENDS ext_clang ext_openmp
GIT_REPOSITORY https://github.com/llvm-mirror/llvm.git
GIT_TAG da4a2839d80ac52958be0129b871beedfe90136e
CMAKE_ARGS -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS ${NGRAPH_FORWARD_CMAKE_ARGS}
-DCMAKE_ASM_COMPILER=${LLVM_CMAKE_ASM_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_CXX_FLAGS=${COMPILE_FLAGS}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/llvm
-DCMAKE_BUILD_TYPE=Release
-DLLVM_ENABLE_ASSERTIONS=OFF
-DLLVM_INCLUDE_TESTS=OFF
-DLLVM_INCLUDE_EXAMPLES=OFF
......
......@@ -107,12 +107,13 @@ ExternalProject_Add(
PATCH_COMMAND patch -p1 --forward --reject-file=- -i ${CMAKE_SOURCE_DIR}/cmake/${MKLDNN_PATCH_FILE} || exit 0
# Uncomment below with any in-flight MKL-DNN patches
# PATCH_COMMAND patch -p1 < ${CMAKE_SOURCE_DIR}/third-party/patches/mkldnn-cmake-openmp.patch
CMAKE_GENERATOR ${CMAKE_GENERATOR}
CMAKE_GENERATOR_PLATFORM ${CMAKE_GENERATOR_PLATFORM}
CMAKE_GENERATOR_TOOLSET ${CMAKE_GENERATOR_TOOLSET}
CMAKE_ARGS
${NGRAPH_FORWARD_CMAKE_ARGS}
-DWITH_TEST=FALSE
-DWITH_EXAMPLE=FALSE
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_C_COMPILER=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER=${CMAKE_CXX_COMPILER}
-DCMAKE_INSTALL_PREFIX=${EXTERNAL_PROJECTS_ROOT}/mkldnn
-DMKLDNN_ENABLE_CONCURRENT_EXEC=ON
-DMKLROOT=${MKL_ROOT}
......
......@@ -39,7 +39,11 @@ if (${CMAKE_VERSION} VERSION_LESS 3.2)
GIT_TAG ${ONNX_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DONNX_GEN_PB_TYPE_STUBS=OFF
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}
......@@ -63,7 +67,11 @@ else()
GIT_TAG ${ONNX_GIT_BRANCH}
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DONNX_GEN_PB_TYPE_STUBS=OFF
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}
......@@ -90,7 +98,11 @@ else()
GIT_SHALLOW TRUE
INSTALL_COMMAND ""
UPDATE_COMMAND ""
CMAKE_ARGS -DONNX_GEN_PB_TYPE_STUBS=OFF
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}
......
......@@ -150,13 +150,20 @@ if (NGRAPH_TBB_ENABLE)
set_source_files_properties(cpu_external_function.cpp
PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_release/
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(TBB_LIB_NAME tbb_debug)
set(TBB_BUILDDIR_NAME tbb_debug)
else()
set(TBB_LIB_NAME tbb)
set(TBB_BUILDDIR_NAME tbb_release)
endif()
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/tbb_build/${TBB_BUILDDIR_NAME}/
DESTINATION ${NGRAPH_INSTALL_LIB}
FILES_MATCHING REGEX "/libtbb${CMAKE_SHARED_LIBRARY_SUFFIX}(\\.[0-9]+)*$"
FILES_MATCHING REGEX "/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}(\\.[0-9]+)*$"
)
add_library(libtbb INTERFACE)
target_link_libraries(libtbb INTERFACE
${CMAKE_CURRENT_BINARY_DIR}/tbb_build/tbb_release/libtbb${CMAKE_SHARED_LIBRARY_SUFFIX}
${CMAKE_CURRENT_BINARY_DIR}/tbb_build/${TBB_BUILDDIR_NAME}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
)
target_include_directories(libtbb SYSTEM INTERFACE ${TBB_ROOT}/include)
endif()
......
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