external_tbb_prebuilt.cmake 3.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
# ******************************************************************************
# Copyright 2017-2018 Intel Corporation
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
#     http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# ******************************************************************************

include(ExternalProject)

19 20 21 22

set(NGRAPH_TBB_VERSION "2019_U3")
set(NGRAPH_TBB_SUB_VERSION "tbb2019_20181203oss")

23
if (WIN32)
24
    set(TBB_FILE https://github.com/01org/tbb/releases/download/${NGRAPH_TBB_VERSION}/${NGRAPH_TBB_SUB_VERSION}_win.zip)
25
    set(TBB_SHA1_HASH 1989458a49e780d76248edac13b963f80c9a460c)
26
elseif(APPLE)
27
    set(TBB_FILE https://github.com/01org/tbb/releases/download/${NGRAPH_TBB_VERSION}/${NGRAPH_TBB_SUB_VERSION}_mac.tgz)
28
    set(TBB_SHA1_HASH 36926fb46add578b88a5c7e19652b94bb612e4be)
29 30 31 32
endif()

ExternalProject_Add(
    ext_tbb
33
    PREFIX tbb
34 35 36 37 38 39 40 41 42 43 44
    URL ${TBB_FILE}
    URL_HASH SHA1=${TBB_SHA1_HASH}
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
    UPDATE_COMMAND ""
    DOWNLOAD_NO_PROGRESS TRUE
    EXCLUDE_FROM_ALL TRUE
    )

ExternalProject_Get_Property(ext_tbb SOURCE_DIR)
45
set(INSTALL_DIR ${SOURCE_DIR}/${NGRAPH_TBB_SUB_VERSION})
46

47 48 49 50 51 52
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
    set(TBB_LIB_NAME tbb_debug)
else()
    set(TBB_LIB_NAME tbb)
endif()

53
if (WIN32)
54 55 56 57 58
    set(TBB_LINK_LIBS ${NGRAPH_ARCHIVE_OUTPUT_DIRECTORY}/${TBB_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX})

    ExternalProject_Add_Step(
        ext_tbb
        CopyTBB
59
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INSTALL_DIR}/bin/intel64/vc14/${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
60 61 62 63 64 65 66
        COMMENT "Move tbb shared libraries to ngraph build directory"
        DEPENDEES download
        )

    ExternalProject_Add_Step(
        ext_tbb
        CopyTBBIMP
67
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INSTALL_DIR}/lib/intel64/vc14/${TBB_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX} ${NGRAPH_ARCHIVE_OUTPUT_DIRECTORY}/${TBB_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
68 69 70 71
        COMMENT "Move tbb libraries to ngraph build directory"
        DEPENDEES download
        )

72 73
    install(FILES ${NGRAPH_ARCHIVE_INSTALL_SRC_DIRECTORY}/${TBB_LIB_NAME}${CMAKE_STATIC_LIBRARY_SUFFIX}
                  ${NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY}/${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
74
            DESTINATION ${NGRAPH_INSTALL_LIB})
75 76
elseif(APPLE)
    set(TBB_LINK_LIBS
77
        ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
78 79 80
    )

    add_custom_command(TARGET ext_tbb POST_BUILD
81
        COMMAND ${CMAKE_COMMAND} -E copy_if_different ${INSTALL_DIR}/lib/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX} ${NGRAPH_LIBRARY_OUTPUT_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
82 83
        COMMENT "Move tbb libraries to ngraph build directory"
    )
Scott Cyphers's avatar
Scott Cyphers committed
84

85
    install(FILES ${NGRAPH_LIBRARY_INSTALL_SRC_DIRECTORY}/${CMAKE_SHARED_LIBRARY_PREFIX}${TBB_LIB_NAME}${CMAKE_SHARED_LIBRARY_SUFFIX}
Scott Cyphers's avatar
Scott Cyphers committed
86
            DESTINATION ${NGRAPH_INSTALL_LIB})
87 88
endif()

89 90 91

add_library(libtbb INTERFACE)
add_dependencies(libtbb ext_tbb)
92
target_include_directories(libtbb SYSTEM INTERFACE ${INSTALL_DIR}/include)
93
target_link_libraries(libtbb INTERFACE ${TBB_LINK_LIBS})