[tbb] Add support for Linux and OSX

[tbb] Fix installed cmake file. Add vcpkg_test_cmake()

[tbb] Fix static non-windows builds

[tbb] Fix find_package() on Windows
This commit is contained in:
Robert Schumacher 2018-08-28 23:19:08 -07:00
parent e3956a98d0
commit 6af7c99555
4 changed files with 88 additions and 71 deletions

18
ports/tbb/CMakeLists.txt Normal file
View File

@ -0,0 +1,18 @@
project(tbb CXX)
file(GLOB SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*)
file(COPY ${SOURCES} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/src)
include(${CMAKE_CURRENT_BINARY_DIR}/src/cmake/TBBBuild.cmake REQUIRED)
tbb_build(TBB_ROOT ${CMAKE_CURRENT_BINARY_DIR}/src MAKE_ARGS extra_inc=big_iron.inc)
set(SUBDIR ${CMAKE_CURRENT_BINARY_DIR}/tbb_cmake_build/tbb_cmake_build_subdir)
if(CMAKE_BUILD_TYPE STREQUAL "Release")
set(SUBDIR "${SUBDIR}_release")
else()
set(SUBDIR "${SUBDIR}_debug")
endif()
file(GLOB OUTPUTS ${SUBDIR}/*.so.* ${SUBDIR}/*.so ${SUBDIR}/*.a ${SUBDIR}/*.dylib ${SUBDIR}/*.dylib.*)
install(FILES ${OUTPUTS} DESTINATION lib)

View File

@ -1,3 +1,3 @@
Source: tbb
Version: 2018_U5
Version: 2018_U5-4
Description: Intel's Threading Building Blocks.

View File

@ -1,91 +1,86 @@
if (VCPKG_LIBRARY_LINKAGE STREQUAL static)
message(STATUS "Warning: Static building not supported yet. Building dynamic.")
set(VCPKG_LIBRARY_LINKAGE dynamic)
endif()
if (VCPKG_CRT_LINKAGE STREQUAL static)
message(FATAL_ERROR "TBB does not currently support static crt linkage")
include(vcpkg_common_functions)
if(NOT VCPKG_CMAKE_SYSTEM_NAME OR VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
vcpkg_check_linkage(ONLY_DYNAMIC_LIBRARY)
endif()
include(vcpkg_common_functions)
vcpkg_from_github(
OUT_SOURCE_PATH SOURCE_PATH
REPO 01org/tbb
REF 2018_U5
SHA512 3e8d20276ccb1b50099f96b6cf968e3d0ada53caea1fa836ecb8652f1dca236fbbbf2c783e64ea2f761f7f21725064d19b72d176e35e4dc29706b8a30965153b
HEAD_REF tbb_2018)
HEAD_REF tbb_2018
)
if(TRIPLET_SYSTEM_ARCH STREQUAL x86)
set(BUILD_ARCH Win32)
file(COPY ${CMAKE_CURRENT_LIST_DIR}/CMakeLists.txt DESTINATION ${SOURCE_PATH})
if(VCPKG_CMAKE_SYSTEM_NAME AND NOT VCPKG_CMAKE_SYSTEM_NAME STREQUAL "WindowsStore")
vcpkg_configure_cmake(
SOURCE_PATH ${SOURCE_PATH}
PREFER_NINJA
)
vcpkg_install_cmake()
# Settings for TBBConfigForSource.cmake.in
set(TBB_LIB_EXT a)
set(TBB_LIB_PREFIX lib)
else()
set(BUILD_ARCH ${TRIPLET_SYSTEM_ARCH})
if (VCPKG_CRT_LINKAGE STREQUAL static)
set(RELEASE_CONFIGURATION Release-MT)
set(DEBUG_CONFIGURATION Debug-MT)
else()
set(RELEASE_CONFIGURATION Release)
set(DEBUG_CONFIGURATION Debug)
endif()
vcpkg_install_msbuild(
SOURCE_PATH ${SOURCE_PATH}
PROJECT_SUBPATH build/vs2013/makefile.sln
RELEASE_CONFIGURATION ${RELEASE_CONFIGURATION}
DEBUG_CONFIGURATION ${DEBUG_CONFIGURATION}
)
# Settings for TBBConfigForSource.cmake.in
set(TBB_LIB_EXT lib)
set(TBB_LIB_PREFIX)
endif()
set(TBB_MSBUILD_PROJECT_DIR ${SOURCE_PATH}/build/vs2013)
vcpkg_build_msbuild(PROJECT_PATH ${TBB_MSBUILD_PROJECT_DIR}/makefile.sln PLATFORM ${BUILD_ARCH})
# Installation
message(STATUS "Installing")
file(COPY
${SOURCE_PATH}/include/tbb
${SOURCE_PATH}/include/serial
DESTINATION ${CURRENT_PACKAGES_DIR}/include)
set(DEBUG_OUTPUT_PATH ${TBB_MSBUILD_PROJECT_DIR}/${BUILD_ARCH}/Debug)
set(RELEASE_OUTPUT_PATH ${TBB_MSBUILD_PROJECT_DIR}/${BUILD_ARCH}/Release)
# Settings for TBBConfigForSource.cmake.in
if(VCPKG_LIBRARY_LINKAGE STREQUAL "static")
set(TBB_DEFAULT_COMPONENTS tbb tbbmalloc)
else()
set(TBB_DEFAULT_COMPONENTS tbb tbbmalloc tbbmalloc_proxy)
endif()
file(READ "${SOURCE_PATH}/include/tbb/tbb_stddef.h" _tbb_stddef)
string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" _tbb_ver_major "${_tbb_stddef}")
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" _tbb_ver_minor "${_tbb_stddef}")
string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" TBB_INTERFACE_VERSION "${_tbb_stddef}")
set(TBB_VERSION "${_tbb_ver_major}.${_tbb_ver_minor}")
set(TBB_RELEASE_DIR "\${_tbb_root}/lib")
set(TBB_DEBUG_DIR "\${_tbb_root}/debug/lib")
file(COPY
${RELEASE_OUTPUT_PATH}/tbb.lib
${RELEASE_OUTPUT_PATH}/tbbmalloc.lib
${RELEASE_OUTPUT_PATH}/tbbmalloc_proxy.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/lib)
file(COPY
${DEBUG_OUTPUT_PATH}/tbb_debug.lib
${DEBUG_OUTPUT_PATH}/tbbmalloc_debug.lib
${DEBUG_OUTPUT_PATH}/tbbmalloc_proxy_debug.lib
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/lib)
file(COPY
${RELEASE_OUTPUT_PATH}/tbb.dll
${RELEASE_OUTPUT_PATH}/tbbmalloc.dll
${RELEASE_OUTPUT_PATH}/tbbmalloc_proxy.dll
DESTINATION ${CURRENT_PACKAGES_DIR}/bin)
file(COPY
${DEBUG_OUTPUT_PATH}/tbb_debug.dll
${DEBUG_OUTPUT_PATH}/tbbmalloc_debug.dll
${DEBUG_OUTPUT_PATH}/tbbmalloc_proxy_debug.dll
DESTINATION ${CURRENT_PACKAGES_DIR}/debug/bin)
vcpkg_copy_pdbs()
include(${SOURCE_PATH}/cmake/TBBMakeConfig.cmake)
tbb_make_config(TBB_ROOT ${CURRENT_PACKAGES_DIR}
CONFIG_DIR TBB_CONFIG_DIR # is set to ${CURRENT_PACKAGES_DIR}/cmake
SYSTEM_NAME "Windows"
CONFIG_FOR_SOURCE
TBB_RELEASE_DIR "\${_tbb_root}/bin"
TBB_DEBUG_DIR "\${_tbb_root}/debug/bin")
file(COPY ${TBB_CONFIG_DIR}/TBBConfig.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/tbb)
file(COPY ${TBB_CONFIG_DIR}/TBBConfigVersion.cmake DESTINATION ${CURRENT_PACKAGES_DIR}/share/tbb)
file(REMOVE_RECURSE ${TBB_CONFIG_DIR})
# make it work with our installation layout
file(READ ${CURRENT_PACKAGES_DIR}/share/tbb/TBBConfig.cmake TBB_CONFIG_CMAKE)
configure_file(
${SOURCE_PATH}/cmake/templates/TBBConfigForSource.cmake.in
${CURRENT_PACKAGES_DIR}/share/tbb/TBBConfig.cmake
@ONLY
)
file(READ ${CURRENT_PACKAGES_DIR}/share/tbb/TBBConfig.cmake _contents)
string(REPLACE
"get_filename_component(_tbb_root \"\${_tbb_root}\" PATH)"
"get_filename_component(_tbb_root \"\${_tbb_root}\" PATH)
get_filename_component(_tbb_root \"\${_tbb_root}\" PATH)" TBB_CONFIG_CMAKE "${TBB_CONFIG_CMAKE}")
string(REPLACE
"\${_tbb_root}/bin/\${_tbb_component}.lib"
"\${_tbb_root}/lib/\${_tbb_component}.lib" TBB_CONFIG_CMAKE "${TBB_CONFIG_CMAKE}")
string(REPLACE
"\${_tbb_root}/debug/bin/\${_tbb_component}_debug.lib"
"\${_tbb_root}/debug/lib/\${_tbb_component}_debug.lib" TBB_CONFIG_CMAKE "${TBB_CONFIG_CMAKE}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/tbb/TBBConfig.cmake "${TBB_CONFIG_CMAKE}")
message(STATUS "Installing done")
"get_filename_component(_tbb_root \"\${_tbb_root}\" PATH)"
"get_filename_component(_tbb_root \"\${_tbb_root}\" PATH)\nget_filename_component(_tbb_root \"\${_tbb_root}\" PATH)"
_contents
"${_contents}"
)
string(REPLACE "SHARED IMPORTED)" "UNKNOWN IMPORTED)" _contents "${_contents}")
file(WRITE ${CURRENT_PACKAGES_DIR}/share/tbb/TBBConfig.cmake "${_contents}")
# Handle copyright
file(COPY ${SOURCE_PATH}/LICENSE DESTINATION ${CURRENT_PACKAGES_DIR}/share/tbb)
file(COPY ${SOURCE_PATH}/LICENSE ${CMAKE_CURRENT_LIST_DIR}/usage DESTINATION ${CURRENT_PACKAGES_DIR}/share/tbb)
file(RENAME ${CURRENT_PACKAGES_DIR}/share/tbb/LICENSE ${CURRENT_PACKAGES_DIR}/share/tbb/copyright)
vcpkg_test_cmake(PACKAGE_NAME TBB)

4
ports/tbb/usage Normal file
View File

@ -0,0 +1,4 @@
The package tbb provides CMake targets:
find_package(TBB CONFIG REQUIRED)
target_link_libraries(main PRIVATE TBB::tbb)