Unverified Commit c7e47d1f authored by Sang Ik Lee's avatar Sang Ik Lee Committed by GitHub

Move TBB out of CPU backend. (#2458)

parent 99245594
......@@ -29,4 +29,34 @@ if(NGRAPH_TBB_ENABLE)
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
execute_process(COMMAND "${CMAKE_COMMAND}" --build .
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/tbb")
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
else()
message(STATUS "Found TBB and imported target ${TBB_IMPORTED_TARGETS}")
endif()
set_source_files_properties(cpu_external_function.cpp
PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
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 "/${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_BUILDDIR_NAME}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
)
target_include_directories(libtbb SYSTEM INTERFACE ${TBB_ROOT}/include)
endif()
......@@ -133,38 +133,6 @@ if (NGRAPH_HALIDE)
)
endif()
if (NGRAPH_TBB_ENABLE AND NOT (WIN32 OR APPLE))
include(${TBB_ROOT}/cmake/TBBBuild.cmake)
tbb_build(TBB_ROOT ${TBB_ROOT} MAKE_ARGS tbb_build_dir=${CMAKE_CURRENT_BINARY_DIR}/tbb_build
tbb_build_prefix=tbb CONFIG_DIR TBB_DIR)
find_package(TBB REQUIRED tbb)
if (NOT TBB_FOUND)
message(FATAL_ERROR "TBB is needed by the CPU backend and was not found")
else()
message(STATUS "Found TBB and imported target ${TBB_IMPORTED_TARGETS}")
endif()
set_source_files_properties(cpu_external_function.cpp
PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
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 "/${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_BUILDDIR_NAME}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
)
target_include_directories(libtbb SYSTEM INTERFACE ${TBB_ROOT}/include)
endif()
if (NGRAPH_CPU_ENABLE)
set(NGRAPH_CPU_DEBUGINFO_ENABLE 0 CACHE STRING "Enable debuginfo in the CPU backend")
......@@ -177,6 +145,10 @@ if (NGRAPH_CPU_ENABLE)
if (NGRAPH_DEX_ONLY)
target_compile_definitions(cpu_backend PRIVATE "NGRAPH_DEX_ONLY")
endif()
if(NGRAPH_TBB_ENABLE)
set_source_files_properties(cpu_external_function.cpp
PROPERTIES COMPILE_DEFINITIONS "NGRAPH_TBB_ENABLE")
endif()
if (NGRAPH_HALIDE)
target_compile_definitions(cpu_backend PRIVATE "NGRAPH_HALIDE")
ExternalProject_Get_Property(ext_halide BINARY_DIR)
......
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