Fixes for release only build of dependencies on windows

This commit is contained in:
tamasmeszaros 2019-10-30 14:50:06 +01:00
parent 5c5a3948f9
commit 189bd1a8ce
3 changed files with 279 additions and 279 deletions

135
deps/blosc-mods.patch vendored
View File

@ -1,23 +1,22 @@
From 24640a466b28dfda26069096554676e8c0b6d090 Mon Sep 17 00:00:00 2001
From 5669891dfaaa4c814f3ec667ca6bf4e693aea978 Mon Sep 17 00:00:00 2001
From: tamasmeszaros <meszaros.q@gmail.com>
Date: Tue, 22 Oct 2019 11:29:05 +0200
Subject: [PATCH] Install.dll in prefix/bin and add config export to cmake
build
Date: Wed, 30 Oct 2019 12:54:52 +0100
Subject: [PATCH] Blosc 1.17 fixes and cmake config script
---
CMakeLists.txt | 112 ++++++++++++++++++++----------------
blosc/CMakeLists.txt | 121 ++++++++++-----------------------------
CMakeLists.txt | 105 +++++++++++++++++-----------------
blosc/CMakeLists.txt | 118 +++++++++------------------------------
cmake/FindLZ4.cmake | 6 +-
cmake/FindSnappy.cmake | 8 ++-
cmake/FindZstd.cmake | 8 ++-
cmake_config.cmake.in | 33 +++++++++++
internal-complibs/CMakeLists.txt | 30 ++++++++++
7 files changed, 173 insertions(+), 145 deletions(-)
cmake_config.cmake.in | 24 ++++++++
internal-complibs/CMakeLists.txt | 35 ++++++++++++
7 files changed, 157 insertions(+), 147 deletions(-)
create mode 100644 cmake_config.cmake.in
create mode 100644 internal-complibs/CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 59d9fab..bdc0dda 100644
index 59d9fab..e9134c2 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -71,7 +71,7 @@
@ -29,36 +28,11 @@ index 59d9fab..bdc0dda 100644
if (NOT CMAKE_VERSION VERSION_LESS 3.3)
cmake_policy(SET CMP0063 NEW)
endif()
@@ -124,55 +124,37 @@ option(PREFER_EXTERNAL_ZSTD
@@ -124,55 +124,30 @@ option(PREFER_EXTERNAL_ZSTD
set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
+set(PRIVATE_LIBS "")
+set(PUBLIC_LIBS "")
+set(PUBLIC_PACKAGES "" CACHE INTERNAL "")
+macro(use_package _pkg _tgt)
+ string(TOUPPER ${_pkg} _PKG)
+ if(NOT DEACTIVATE_${_PKG})
+ if(PREFER_EXTERNAL_${_PKG})
+ find_package(${_pkg})
+ if (NOT ${_pkg}_FOUND )
+ message(STATUS "No ${_pkg} found. Using internal sources.")
+ endif()
+ else()
+ message(STATUS "Using ${_pkg} internal sources.")
+ endif(PREFER_EXTERNAL_${_PKG})
+ # HAVE_${_pkg} will be set to true because even if the library is
+ # not found, we will use the included sources for it
+ set(HAVE_${_PKG} TRUE)
+ if (${_pkg}_FOUND)
+ list(APPEND PUBLIC_LIBS ${_pkg}::${_tgt})
+ set(PUBLIC_PACKAGES "${PUBLIC_PACKAGES};${_pkg}" CACHE INTERNAL "")
+ else()
+ list(APPEND PRIVATE_LIBS ${_pkg}::${_tgt})
+ endif()
+ endif(NOT DEACTIVATE_${_PKG})
+endmacro()
-
-if(NOT DEACTIVATE_LZ4)
- if(PREFER_EXTERNAL_LZ4)
- find_package(LZ4)
@ -107,6 +81,25 @@ index 59d9fab..bdc0dda 100644
- # not found, we will use the included sources for it
- set(HAVE_ZSTD TRUE)
-endif (NOT DEACTIVATE_ZSTD)
+set(LIBS "")
+macro(use_package _pkg _tgt)
+ string(TOUPPER ${_pkg} _PKG)
+ if(NOT DEACTIVATE_${_PKG})
+ if(PREFER_EXTERNAL_${_PKG})
+ find_package(${_pkg})
+ if (NOT ${_pkg}_FOUND )
+ message(STATUS "No ${_pkg} found. Using internal sources.")
+ endif()
+ else()
+ message(STATUS "Using ${_pkg} internal sources.")
+ endif(PREFER_EXTERNAL_${_PKG})
+ # HAVE_${_pkg} will be set to true because even if the library is
+ # not found, we will use the included sources for it
+ set(HAVE_${_PKG} TRUE)
+ list(APPEND LIBS ${_pkg}::${_tgt})
+ endif(NOT DEACTIVATE_${_PKG})
+endmacro()
+
+set(ZLIB_ROOT $ENV{ZLIB_ROOT})
+use_package(ZLIB ZLIB)
+use_package(LZ4 LZ4)
@ -115,7 +108,7 @@ index 59d9fab..bdc0dda 100644
# create the config.h file
configure_file ("blosc/config.h.in" "blosc/config.h" )
@@ -316,6 +298,7 @@ endif()
@@ -316,6 +291,7 @@ endif()
# subdirectories
@ -123,7 +116,15 @@ index 59d9fab..bdc0dda 100644
add_subdirectory(blosc)
if(BUILD_TESTS)
@@ -338,10 +321,41 @@ if (BLOSC_INSTALL)
@@ -328,7 +304,6 @@ if(BUILD_BENCHMARKS)
add_subdirectory(bench)
endif(BUILD_BENCHMARKS)
-
# uninstall target
if (BLOSC_INSTALL)
configure_file(
@@ -338,10 +313,38 @@ if (BLOSC_INSTALL)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/blosc.pc"
DESTINATION lib/pkgconfig COMPONENT DEV)
@ -157,16 +158,13 @@ index 59d9fab..bdc0dda 100644
+ install(FILES
+ "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfig.cmake"
+ "${CMAKE_CURRENT_BINARY_DIR}/cmakeexports/BloscConfigVersion.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLZ4.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindZstd.cmake"
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindSnappy.cmake"
+ DESTINATION lib/cmake/Blosc COMPONENT DEV)
+
add_custom_target(uninstall
COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
endif()
diff --git a/blosc/CMakeLists.txt b/blosc/CMakeLists.txt
index 1d1bebe..16aff02 100644
index 1d1bebe..f554abe 100644
--- a/blosc/CMakeLists.txt
+++ b/blosc/CMakeLists.txt
@@ -1,52 +1,11 @@
@ -222,19 +220,17 @@ index 1d1bebe..16aff02 100644
# library sources
set(SOURCES blosc.c blosclz.c fastcopy.c shuffle-generic.c bitshuffle-generic.c
@@ -73,53 +32,15 @@ if(WIN32)
@@ -73,53 +32,13 @@ if(WIN32)
message(STATUS "using the internal pthread library for win32 systems.")
set(SOURCES ${SOURCES} win32/pthread.c)
else(NOT Threads_FOUND)
- set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND PUBLIC_LIBS Threads::Threads)
+ set(PUBLIC_PACKAGES "${PUBLIC_PACKAGES};Threads" CACHE INTERNAL "")
+ list(APPEND LIBS Threads::Threads)
endif(NOT Threads_FOUND)
else(WIN32)
find_package(Threads REQUIRED)
- set(LIBS ${LIBS} ${CMAKE_THREAD_LIBS_INIT})
+ list(APPEND PUBLIC_LIBS Threads::Threads)
+ set(PUBLIC_PACKAGES "${PUBLIC_PACKAGES};Threads" CACHE INTERNAL "")
+ list(APPEND LIBS Threads::Threads)
endif(WIN32)
-if(NOT DEACTIVATE_LZ4)
@ -280,7 +276,7 @@ index 1d1bebe..16aff02 100644
# targets
if (BUILD_SHARED)
add_library(blosc_shared SHARED ${SOURCES})
@@ -191,14 +112,18 @@ if (BUILD_TESTS)
@@ -191,14 +110,17 @@ if (BUILD_TESTS)
endif()
endif()
@ -289,8 +285,7 @@ index 1d1bebe..16aff02 100644
if (BUILD_SHARED)
- target_link_libraries(blosc_shared ${LIBS})
- target_include_directories(blosc_shared PUBLIC ${BLOSC_INCLUDE_DIRS})
+ target_link_libraries(blosc_shared PUBLIC ${PUBLIC_LIBS})
+ target_link_libraries(blosc_shared PRIVATE ${PRIVATE_LIBS})
+ target_link_libraries(blosc_shared PRIVATE ${LIBS})
+ target_include_directories(blosc_shared PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+ target_link_libraries(blosc INTERFACE blosc_shared)
endif()
@ -298,19 +293,19 @@ index 1d1bebe..16aff02 100644
if (BUILD_TESTS)
- target_link_libraries(blosc_shared_testing ${LIBS})
- target_include_directories(blosc_shared_testing PUBLIC ${BLOSC_INCLUDE_DIRS})
+ target_link_libraries(blosc_shared_testing ${PUBLIC_LIBS} ${PRIVATE_LIBS})
+ target_link_libraries(blosc_shared_testing PRIVATE ${LIBS})
+ target_include_directories(blosc_shared_testing PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
endif()
if(BUILD_STATIC)
@@ -207,17 +132,31 @@ if(BUILD_STATIC)
@@ -207,17 +129,31 @@ if(BUILD_STATIC)
if (MSVC)
set_target_properties(blosc_static PROPERTIES PREFIX lib)
endif()
- target_link_libraries(blosc_static ${LIBS})
- target_include_directories(blosc_static PUBLIC ${BLOSC_INCLUDE_DIRS})
+ target_link_libraries(blosc_static PUBLIC ${PUBLIC_LIBS})
+ target_link_libraries(blosc_static PRIVATE ${PRIVATE_LIBS})
+ # With the static library, cmake has to deal with transitive dependencies
+ target_link_libraries(blosc_static PRIVATE ${LIBS})
+ target_include_directories(blosc_static PUBLIC $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>)
+ if (NOT BUILD_SHARED)
+ target_link_libraries(blosc INTERFACE blosc_static)
@ -398,24 +393,15 @@ index 7db4bb9..cabc2f8 100644
\ No newline at end of file
diff --git a/cmake_config.cmake.in b/cmake_config.cmake.in
new file mode 100644
index 0000000..b4ede30
index 0000000..0f6af24
--- /dev/null
+++ b/cmake_config.cmake.in
@@ -0,0 +1,33 @@
@@ -0,0 +1,24 @@
+include(CMakeFindDependencyMacro)
+
+list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR})
+
+set(_deps "@PUBLIC_PACKAGES@")
+
+foreach(pkg ${_deps})
+ # no minimum versions are required by upstream
+ find_dependency(${pkg})
+endforeach()
+
+include("${CMAKE_CURRENT_LIST_DIR}/BloscTargets.cmake")
+
+function(remap_configs from_Cfg to_Cfg)
+function(_blosc_remap_configs from_Cfg to_Cfg)
+ string(TOUPPER ${from_Cfg} from_CFG)
+ string(TOLOWER ${from_Cfg} from_cfg)
+
@ -432,21 +418,25 @@ index 0000000..b4ede30
+# MSVC will try to link RelWithDebInfo or MinSizeRel target with debug config
+# if no matching installation is present which would result in link errors.
+if(MSVC)
+ remap_configs(RelWithDebInfo Release)
+ remap_configs(MinSizeRel Release)
+ _blosc_remap_configs(RelWithDebInfo Release)
+ _blosc_remap_configs(MinSizeRel Release)
+endif()
diff --git a/internal-complibs/CMakeLists.txt b/internal-complibs/CMakeLists.txt
new file mode 100644
index 0000000..5b23484
index 0000000..4586efa
--- /dev/null
+++ b/internal-complibs/CMakeLists.txt
@@ -0,0 +1,30 @@
@@ -0,0 +1,35 @@
+macro(add_lib_target pkg tgt incdir files)
+ string(TOUPPER ${pkg} TGT)
+ if(NOT DEACTIVATE_${TGT} AND NOT ${pkg}_FOUND)
+ add_library(${tgt}_objs OBJECT ${files})
+ add_library(${tgt} INTERFACE)
+ target_include_directories(${tgt}_objs PRIVATE $<BUILD_INTERFACE:${incdir}>)
+ target_include_directories(${tgt} INTERFACE $<BUILD_INTERFACE:${incdir}>)
+ target_sources(${tgt} INTERFACE "$<BUILD_INTERFACE:${files}>")
+ #set_target_properties(${tgt} PROPERTIES INTERFACE_SOURCES "$<TARGET_OBJECTS:${tgt}_objs>")
+ set_target_properties(${tgt}_objs PROPERTIES POSITION_INDEPENDENT_CODE ON)
+ target_sources(${tgt} INTERFACE "$<BUILD_INTERFACE:$<TARGET_OBJECTS:${tgt}_objs>>")
+ add_library(${pkg}::${tgt} ALIAS ${tgt})
+
+ # This creates dummy (empty) interface targets in the exported config.
@ -471,6 +461,7 @@ index 0000000..5b23484
+file(GLOB ZSTD_FILES ${ZSTD_DIR}/common/*.c ${ZSTD_DIR}/compress/*.c ${ZSTD_DIR}/decompress/*.c)
+add_lib_target(Zstd Zstd ${ZSTD_DIR} "${ZSTD_FILES}")
+target_include_directories(Zstd INTERFACE $<BUILD_INTERFACE:${ZSTD_DIR}/common>)
+target_include_directories(Zstd_objs PRIVATE $<BUILD_INTERFACE:${ZSTD_DIR}/common>)
\ No newline at end of file
--
2.16.2.windows.1

View File

@ -81,7 +81,6 @@ ExternalProject_Add(dep_boost
INSTALL_COMMAND "" # b2 does that already
)
ExternalProject_Add(dep_tbb
EXCLUDE_FROM_ALL 1
URL "https://github.com/wjakob/tbb/archive/a0dc9bf76d0120f917b641ed095360448cabc85b.tar.gz"
@ -99,22 +98,22 @@ ExternalProject_Add(dep_tbb
add_debug_dep(dep_tbb)
ExternalProject_Add(dep_gtest
EXCLUDE_FROM_ALL 1
URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
CMAKE_ARGS
-DBUILD_GMOCK=OFF
-Dgtest_force_shared_crt=ON
-DCMAKE_POSITION_INDEPENDENT_CODE=ON
"-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
INSTALL_COMMAND ""
)
# ExternalProject_Add(dep_gtest
# EXCLUDE_FROM_ALL 1
# URL "https://github.com/google/googletest/archive/release-1.8.1.tar.gz"
# URL_HASH SHA256=9bf1fe5182a604b4135edc1a425ae356c9ad15e9b23f9f12a02e80184c3a249c
# CMAKE_GENERATOR "${DEP_MSVC_GEN}"
# CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
# CMAKE_ARGS
# -DBUILD_GMOCK=OFF
# -Dgtest_force_shared_crt=ON
# -DCMAKE_POSITION_INDEPENDENT_CODE=ON
# "-DCMAKE_INSTALL_PREFIX:PATH=${DESTDIR}\\usr\\local"
# BUILD_COMMAND msbuild /m /P:Configuration=Release INSTALL.vcxproj
# INSTALL_COMMAND ""
# )
add_debug_dep(dep_gtest)
# add_debug_dep(dep_gtest)
ExternalProject_Add(dep_cereal
EXCLUDE_FROM_ALL 1
@ -181,7 +180,6 @@ if (${DEP_DEBUG})
)
endif ()
if (${DEPS_BITS} EQUAL 32)
set(DEP_LIBCURL_TARGET "x86")
else ()
@ -305,8 +303,8 @@ endif ()
ExternalProject_Add(dep_blosc
EXCLUDE_FROM_ALL 1
GIT_REPOSITORY https://github.com/Blosc/c-blosc.git
GIT_TAG v1.17.0
URL https://github.com/Blosc/c-blosc/archive/v1.17.0.zip
URL_HASH SHA256=7463a1df566704f212263312717ab2c36b45d45cba6cd0dccebf91b2cc4b4da9
DEPENDS dep_zlib
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
@ -331,7 +329,7 @@ ExternalProject_Add(dep_openexr
EXCLUDE_FROM_ALL 1
GIT_REPOSITORY https://github.com/openexr/openexr.git
GIT_TAG v2.4.0
DEPENDS dep_zlib
DEPENDS
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
CMAKE_ARGS
@ -350,9 +348,9 @@ add_debug_dep(dep_openexr)
ExternalProject_Add(dep_openvdb
EXCLUDE_FROM_ALL 1
GIT_REPOSITORY https://github.com/AcademySoftwareFoundation/openvdb.git
GIT_TAG v6.2.1
DEPENDS dep_blosc dep_openexr dep_tbb
URL https://github.com/AcademySoftwareFoundation/openvdb/archive/v6.2.1.zip
URL_HASH SHA256=dc337399dce8e1c9f21f20e97b1ce7e4933cb0a63bb3b8b734d8fcc464aa0c48
DEPENDS dep_blosc dep_openexr dep_tbb dep_boost
CMAKE_GENERATOR "${DEP_MSVC_GEN}"
CMAKE_GENERATOR_PLATFORM "${DEP_PLATFORM}"
CMAKE_ARGS

View File

@ -1,4 +1,4 @@
From ee867b9f226412c0f3b83fa01cd43539acc4ed95 Mon Sep 17 00:00:00 2001
From e48f4a835fe7cb391f9f90945472bd367fb4c4f1 Mon Sep 17 00:00:00 2001
From: tamasmeszaros <meszaros.q@gmail.com>
Date: Wed, 16 Oct 2019 17:42:50 +0200
Subject: [PATCH] Build fixes for PrusaSlicer integration
@ -7,17 +7,17 @@ Subject: [PATCH] Build fixes for PrusaSlicer integration
CMakeLists.txt | 3 -
cmake/FindBlosc.cmake | 218 ---------------
cmake/FindCppUnit.cmake | 4 +-
cmake/FindIlmBase.cmake | 337 -----------------------
cmake/FindIlmBase.cmake | 337 ----------------------
cmake/FindOpenEXR.cmake | 329 ----------------------
cmake/FindOpenVDB.cmake | 19 +-
cmake/FindTBB.cmake | 593 ++++++++++++++++++++--------------------
cmake/FindTBB.cmake | 605 ++++++++++++++++++++--------------------
openvdb/CMakeLists.txt | 13 +-
openvdb/Grid.cc | 3 +
openvdb/PlatformConfig.h | 9 +-
openvdb/cmd/CMakeLists.txt | 4 +-
openvdb/unittest/CMakeLists.txt | 3 +-
openvdb/unittest/TestFile.cc | 2 +-
13 files changed, 325 insertions(+), 1212 deletions(-)
13 files changed, 336 insertions(+), 1213 deletions(-)
delete mode 100644 cmake/FindBlosc.cmake
delete mode 100644 cmake/FindIlmBase.cmake
delete mode 100644 cmake/FindOpenEXR.cmake
@ -1011,10 +1011,10 @@ index 63a2eda..6211071 100644
endforeach()
diff --git a/cmake/FindTBB.cmake b/cmake/FindTBB.cmake
index bdf9c81..ffdee03 100644
index bdf9c81..c6bdec9 100644
--- a/cmake/FindTBB.cmake
+++ b/cmake/FindTBB.cmake
@@ -1,333 +1,322 @@
@@ -1,333 +1,332 @@
-# Copyright (c) DreamWorks Animation LLC
+# The MIT License (MIT)
#
@ -1205,10 +1205,6 @@ index bdf9c81..ffdee03 100644
+#
+# This module will also create the "tbb" target that may be used when building
+# executables and libraries.
+
+include(FindPackageHandleStandardArgs)
+
+if(NOT TBB_FOUND)
-mark_as_advanced(
- Tbb_INCLUDE_DIR
@ -1227,6 +1223,39 @@ index bdf9c81..ffdee03 100644
- foreach(COMPONENT ${TBB_FIND_COMPONENTS})
- if(NOT ${COMPONENT} IN_LIST _TBB_COMPONENT_LIST)
- list(APPEND _IGNORED_COMPONENTS ${COMPONENT})
- endif()
- endforeach()
+unset(TBB_FOUND CACHE)
+unset(TBB_INCLUDE_DIRS CACHE)
+unset(TBB_LIBRARIES)
+unset(TBB_LIBRARIES_DEBUG)
+unset(TBB_LIBRARIES_RELEASE)
- if(_IGNORED_COMPONENTS)
- message(STATUS "Ignoring unknown components of TBB:")
- foreach(COMPONENT ${_IGNORED_COMPONENTS})
- message(STATUS " ${COMPONENT}")
- endforeach()
- list(REMOVE_ITEM TBB_FIND_COMPONENTS ${_IGNORED_COMPONENTS})
- endif()
-else()
- set(_TBB_COMPONENTS_PROVIDED FALSE)
- set(TBB_FIND_COMPONENTS ${_TBB_COMPONENT_LIST})
-endif()
+include(FindPackageHandleStandardArgs)
+
+find_package(Threads QUIET REQUIRED)
-# Append TBB_ROOT or $ENV{TBB_ROOT} if set (prioritize the direct cmake var)
-set(_TBB_ROOT_SEARCH_DIR "")
+if(NOT TBB_FOUND)
-if(TBB_ROOT)
- list(APPEND _TBB_ROOT_SEARCH_DIR ${TBB_ROOT})
-else()
- set(_ENV_TBB_ROOT $ENV{TBB_ROOT})
- if(_ENV_TBB_ROOT)
- list(APPEND _TBB_ROOT_SEARCH_DIR ${_ENV_TBB_ROOT})
+ ##################################
+ # Check the build type
+ ##################################
@ -1241,7 +1270,8 @@ index bdf9c81..ffdee03 100644
+ set(TBB_BUILD_TYPE DEBUG)
+ else()
+ set(TBB_BUILD_TYPE RELEASE)
+ endif()
endif()
-endif()
+
+ ##################################
+ # Set the TBB search directories
@ -1261,7 +1291,53 @@ index bdf9c81..ffdee03 100644
+ else()
+ set(TBB_ARCHITECTURE "ia32")
+ endif()
+
-# Additionally try and use pkconfig to find Tbb
-
-find_package(PkgConfig)
-pkg_check_modules(PC_Tbb QUIET tbb)
-
-# ------------------------------------------------------------------------
-# Search for tbb include DIR
-# ------------------------------------------------------------------------
-
-set(_TBB_INCLUDE_SEARCH_DIRS "")
-list(APPEND _TBB_INCLUDE_SEARCH_DIRS
- ${TBB_INCLUDEDIR}
- ${_TBB_ROOT_SEARCH_DIR}
- ${PC_Tbb_INCLUDE_DIRS}
- ${SYSTEM_LIBRARY_PATHS}
-)
-
-# Look for a standard tbb header file.
-find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
- NO_DEFAULT_PATH
- PATHS ${_TBB_INCLUDE_SEARCH_DIRS}
- PATH_SUFFIXES include
-)
-
-if(EXISTS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
- file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
- _tbb_version_major_string REGEX "#define TBB_VERSION_MAJOR "
- )
- string(REGEX REPLACE "#define TBB_VERSION_MAJOR" ""
- _tbb_version_major_string "${_tbb_version_major_string}"
- )
- string(STRIP "${_tbb_version_major_string}" Tbb_VERSION_MAJOR)
-
- file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
- _tbb_version_minor_string REGEX "#define TBB_VERSION_MINOR "
- )
- string(REGEX REPLACE "#define TBB_VERSION_MINOR" ""
- _tbb_version_minor_string "${_tbb_version_minor_string}"
- )
- string(STRIP "${_tbb_version_minor_string}" Tbb_VERSION_MINOR)
-
- unset(_tbb_version_major_string)
- unset(_tbb_version_minor_string)
-
- set(Tbb_VERSION ${Tbb_VERSION_MAJOR}.${Tbb_VERSION_MINOR})
-endif()
+ # Set the TBB search library path search suffix based on the version of VC
+ if(WINDOWS_STORE)
+ set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11_ui")
@ -1273,15 +1349,11 @@ index bdf9c81..ffdee03 100644
+ set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc11")
+ elseif(MSVC10)
+ set(TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc10")
endif()
- endforeach()
+ endif()
- if(_IGNORED_COMPONENTS)
- message(STATUS "Ignoring unknown components of TBB:")
- foreach(COMPONENT ${_IGNORED_COMPONENTS})
- message(STATUS " ${COMPONENT}")
- endforeach()
- list(REMOVE_ITEM TBB_FIND_COMPONENTS ${_IGNORED_COMPONENTS})
-# ------------------------------------------------------------------------
-# Search for TBB lib DIR
-# ------------------------------------------------------------------------
+ # Add the library path search suffix for the VC independent version of TBB
+ list(APPEND TBB_LIB_PATH_SUFFIX "lib/${TBB_ARCHITECTURE}/vc_mt")
+
@ -1332,109 +1404,18 @@ index bdf9c81..ffdee03 100644
+ string(REGEX REPLACE ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
+ TBB_INTERFACE_VERSION "${_tbb_version_file}")
+ set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}")
endif()
-else()
- set(_TBB_COMPONENTS_PROVIDED FALSE)
- set(TBB_FIND_COMPONENTS ${_TBB_COMPONENT_LIST})
-endif()
+ endif()
-# Append TBB_ROOT or $ENV{TBB_ROOT} if set (prioritize the direct cmake var)
-set(_TBB_ROOT_SEARCH_DIR "")
-set(_TBB_LIBRARYDIR_SEARCH_DIRS "")
+ ##################################
+ # Find TBB components
+ ##################################
-if(TBB_ROOT)
- list(APPEND _TBB_ROOT_SEARCH_DIR ${TBB_ROOT})
-else()
- set(_ENV_TBB_ROOT $ENV{TBB_ROOT})
- if(_ENV_TBB_ROOT)
- list(APPEND _TBB_ROOT_SEARCH_DIR ${_ENV_TBB_ROOT})
-# Append to _TBB_LIBRARYDIR_SEARCH_DIRS in priority order
+ if(TBB_VERSION VERSION_LESS 4.3)
+ set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc tbb)
+ else()
+ set(TBB_SEARCH_COMPOMPONENTS tbb_preview tbbmalloc_proxy tbbmalloc tbb)
endif()
-endif()
-# Additionally try and use pkconfig to find Tbb
-
-find_package(PkgConfig)
-pkg_check_modules(PC_Tbb QUIET tbb)
-
-# ------------------------------------------------------------------------
-# Search for tbb include DIR
-# ------------------------------------------------------------------------
-
-set(_TBB_INCLUDE_SEARCH_DIRS "")
-list(APPEND _TBB_INCLUDE_SEARCH_DIRS
- ${TBB_INCLUDEDIR}
- ${_TBB_ROOT_SEARCH_DIR}
- ${PC_Tbb_INCLUDE_DIRS}
- ${SYSTEM_LIBRARY_PATHS}
-)
-
-# Look for a standard tbb header file.
-find_path(Tbb_INCLUDE_DIR tbb/tbb_stddef.h
- NO_DEFAULT_PATH
- PATHS ${_TBB_INCLUDE_SEARCH_DIRS}
- PATH_SUFFIXES include
-)
-
-if(EXISTS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h")
- file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
- _tbb_version_major_string REGEX "#define TBB_VERSION_MAJOR "
- )
- string(REGEX REPLACE "#define TBB_VERSION_MAJOR" ""
- _tbb_version_major_string "${_tbb_version_major_string}"
- )
- string(STRIP "${_tbb_version_major_string}" Tbb_VERSION_MAJOR)
-
- file(STRINGS "${Tbb_INCLUDE_DIR}/tbb/tbb_stddef.h"
- _tbb_version_minor_string REGEX "#define TBB_VERSION_MINOR "
- )
- string(REGEX REPLACE "#define TBB_VERSION_MINOR" ""
- _tbb_version_minor_string "${_tbb_version_minor_string}"
- )
- string(STRIP "${_tbb_version_minor_string}" Tbb_VERSION_MINOR)
-
- unset(_tbb_version_major_string)
- unset(_tbb_version_minor_string)
-
- set(Tbb_VERSION ${Tbb_VERSION_MAJOR}.${Tbb_VERSION_MINOR})
-endif()
+ if(TBB_STATIC)
+ set(TBB_STATIC_SUFFIX "_static")
+ endif()
+
+ # Find each component
+ foreach(_comp ${TBB_SEARCH_COMPOMPONENTS})
+ if(";${TBB_FIND_COMPONENTS};tbb;" MATCHES ";${_comp};")
-# ------------------------------------------------------------------------
-# Search for TBB lib DIR
-# ------------------------------------------------------------------------
+ # Search for the libraries
+ find_library(TBB_${_comp}_LIBRARY_RELEASE ${_comp}${TBB_STATIC_SUFFIX}
+ HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+ PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+ PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
-set(_TBB_LIBRARYDIR_SEARCH_DIRS "")
+ find_library(TBB_${_comp}_LIBRARY_DEBUG ${_comp}${TBB_STATIC_SUFFIX}_debug
+ HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+ PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+ PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
-# Append to _TBB_LIBRARYDIR_SEARCH_DIRS in priority order
+ if(TBB_${_comp}_LIBRARY_DEBUG)
+ list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}")
+ endif()
+ if(TBB_${_comp}_LIBRARY_RELEASE)
+ list(APPEND TBB_LIBRARIES_RELEASE "${TBB_${_comp}_LIBRARY_RELEASE}")
+ endif()
+ if(TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE} AND NOT TBB_${_comp}_LIBRARY)
+ set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}")
+ endif()
-set(_TBB_LIBRARYDIR_SEARCH_DIRS "")
@ -1444,41 +1425,35 @@ index bdf9c81..ffdee03 100644
- ${PC_Tbb_LIBRARY_DIRS}
- ${SYSTEM_LIBRARY_PATHS}
-)
+ if(TBB_${_comp}_LIBRARY AND EXISTS "${TBB_${_comp}_LIBRARY}")
+ set(TBB_${_comp}_FOUND TRUE)
+ else()
+ set(TBB_${_comp}_FOUND FALSE)
+ if(TBB_STATIC)
+ set(TBB_STATIC_SUFFIX "_static")
+ endif()
-set(TBB_PATH_SUFFIXES
- lib64
- lib
-)
+ # Mark internal variables as advanced
+ mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE)
+ mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG)
+ mark_as_advanced(TBB_${_comp}_LIBRARY)
+ # Find each component
+ foreach(_comp ${TBB_SEARCH_COMPOMPONENTS})
+ if(";${TBB_FIND_COMPONENTS};tbb;" MATCHES ";${_comp};")
-# platform branching
+ endif()
+ endforeach()
+ unset(TBB_${_comp}_LIBRARY_DEBUG CACHE)
+ unset(TBB_${_comp}_LIBRARY_RELEASE CACHE)
-if(UNIX)
- list(INSERT TBB_PATH_SUFFIXES 0 lib/x86_64-linux-gnu)
-endif()
+ ##################################
+ # Set compile flags and libraries
+ ##################################
+ # Search for the libraries
+ find_library(TBB_${_comp}_LIBRARY_RELEASE ${_comp}${TBB_STATIC_SUFFIX}
+ HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+ PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+ PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
-if(APPLE)
- if(TBB_FOR_CLANG)
- list(INSERT TBB_PATH_SUFFIXES 0 lib/libc++)
+ set(TBB_DEFINITIONS_RELEASE "")
+ set(TBB_DEFINITIONS_DEBUG "TBB_USE_DEBUG=1")
+
+ if(TBB_LIBRARIES_${TBB_BUILD_TYPE})
+ set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}")
endif()
- endif()
-elseif(WIN32)
- if(MSVC10)
- set(TBB_VC_DIR vc10)
@ -1498,44 +1473,25 @@ index bdf9c81..ffdee03 100644
- else()
- list(INSERT TBB_PATH_SUFFIXES 0 lib/intel64/gcc4.4)
- endif()
+
+ if(NOT MSVC AND NOT TBB_LIBRARIES)
+ set(TBB_LIBRARIES ${TBB_LIBRARIES_RELEASE})
endif()
- endif()
-endif()
+ find_library(TBB_${_comp}_LIBRARY_DEBUG ${_comp}${TBB_STATIC_SUFFIX}_debug
+ HINTS ${TBB_LIBRARY} ${TBB_SEARCH_DIR}
+ PATHS ${TBB_DEFAULT_SEARCH_DIR} ENV LIBRARY_PATH
+ PATH_SUFFIXES ${TBB_LIB_PATH_SUFFIX})
-if(UNIX AND TBB_USE_STATIC_LIBS)
- set(_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
- set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")
-endif()
+ if (MSVC AND TBB_STATIC)
+ set(TBB_DEFINITIONS __TBB_NO_IMPLICIT_LINKAGE)
+ if(TBB_${_comp}_LIBRARY_DEBUG)
+ list(APPEND TBB_LIBRARIES_DEBUG "${TBB_${_comp}_LIBRARY_DEBUG}")
+ endif()
+
+ unset (TBB_STATIC_SUFFIX)
+
+ find_package_handle_standard_args(TBB
+ REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES
+ HANDLE_COMPONENTS
+ VERSION_VAR TBB_VERSION)
+
+ ##################################
+ # Create targets
+ ##################################
+
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND)
+ add_library(TBB::tbb UNKNOWN IMPORTED)
+ set_target_properties(TBB::tbb PROPERTIES
+ INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}
+ IMPORTED_LOCATION ${TBB_LIBRARIES})
+ if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG)
+ set_target_properties(TBB::tbb PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS};$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:${TBB_DEFINITIONS_DEBUG}>;$<$<CONFIG:Release>:${TBB_DEFINITIONS_RELEASE}>"
+ IMPORTED_LOCATION_DEBUG ${TBB_LIBRARIES_DEBUG}
+ IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_RELEASE}
+ IMPORTED_LOCATION_RELEASE ${TBB_LIBRARIES_RELEASE}
+ IMPORTED_LOCATION_MINSIZEREL ${TBB_LIBRARIES_RELEASE}
+ )
+ if(TBB_${_comp}_LIBRARY_RELEASE)
+ list(APPEND TBB_LIBRARIES_RELEASE "${TBB_${_comp}_LIBRARY_RELEASE}")
+ endif()
+ if(TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE} AND NOT TBB_${_comp}_LIBRARY)
+ set(TBB_${_comp}_LIBRARY "${TBB_${_comp}_LIBRARY_${TBB_BUILD_TYPE}}")
+ endif()
-set(Tbb_LIB_COMPONENTS "")
@ -1559,19 +1515,84 @@ index bdf9c81..ffdee03 100644
- # Extract the directory and apply the matched text (in brackets)
- get_filename_component(Tbb_${COMPONENT}_DIR "${Tbb_${COMPONENT}_LIBRARY}" DIRECTORY)
- set(Tbb_${COMPONENT}_LIBRARY "${Tbb_${COMPONENT}_DIR}/${CMAKE_MATCH_1}")
+ if(TBB_${_comp}_LIBRARY AND EXISTS "${TBB_${_comp}_LIBRARY}")
+ set(TBB_${_comp}_FOUND TRUE)
+ else()
+ set(TBB_${_comp}_FOUND FALSE)
endif()
+
+ # Mark internal variables as advanced
+ mark_as_advanced(TBB_${_comp}_LIBRARY_RELEASE)
+ mark_as_advanced(TBB_${_comp}_LIBRARY_DEBUG)
+ mark_as_advanced(TBB_${_comp}_LIBRARY)
+
endif()
- endif()
+ if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
+ find_package(Threads QUIET REQUIRED)
+ set_target_properties(TBB::tbb PROPERTIES INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS};Threads::Threads")
endif()
endif()
+ endforeach()
- list(APPEND Tbb_LIB_COMPONENTS ${Tbb_${COMPONENT}_LIBRARY})
-
+ ##################################
+ # Set compile flags and libraries
+ ##################################
- if(Tbb_${COMPONENT}_LIBRARY)
- set(TBB_${COMPONENT}_FOUND TRUE)
- else()
- set(TBB_${COMPONENT}_FOUND FALSE)
+ set(TBB_DEFINITIONS_RELEASE "")
+ set(TBB_DEFINITIONS_DEBUG "TBB_USE_DEBUG=1")
+
+ if(TBB_LIBRARIES_${TBB_BUILD_TYPE})
+ set(TBB_LIBRARIES "${TBB_LIBRARIES_${TBB_BUILD_TYPE}}")
+ endif()
+
+ if(NOT MSVC AND NOT TBB_LIBRARIES)
+ set(TBB_LIBRARIES ${TBB_LIBRARIES_RELEASE})
endif()
-endforeach()
-if(UNIX AND TBB_USE_STATIC_LIBS)
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
- unset(_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
-endif()
+ set(TBB_DEFINITIONS "")
+ if (MSVC AND TBB_STATIC)
+ set(TBB_DEFINITIONS __TBB_NO_IMPLICIT_LINKAGE)
+ endif ()
+
+ unset (TBB_STATIC_SUFFIX)
+
+ find_package_handle_standard_args(TBB
+ REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES
+ FAIL_MESSAGE "TBB library cannot be found. Consider set TBBROOT environment variable."
+ HANDLE_COMPONENTS
+ VERSION_VAR TBB_VERSION)
+
+ ##################################
+ # Create targets
+ ##################################
+
+ if(NOT CMAKE_VERSION VERSION_LESS 3.0 AND TBB_FOUND)
+ add_library(TBB::tbb UNKNOWN IMPORTED)
+ set_target_properties(TBB::tbb PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS}"
+ INTERFACE_LINK_LIBRARIES "Threads::Threads;${CMAKE_DL_LIBS}"
+ INTERFACE_INCLUDE_DIRECTORIES ${TBB_INCLUDE_DIRS}
+ IMPORTED_LOCATION ${TBB_LIBRARIES})
+ if(TBB_LIBRARIES_RELEASE AND TBB_LIBRARIES_DEBUG)
+ set_target_properties(TBB::tbb PROPERTIES
+ INTERFACE_COMPILE_DEFINITIONS "${TBB_DEFINITIONS};$<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:${TBB_DEFINITIONS_DEBUG}>;$<$<CONFIG:Release>:${TBB_DEFINITIONS_RELEASE}>"
+ IMPORTED_LOCATION_DEBUG ${TBB_LIBRARIES_DEBUG}
+ IMPORTED_LOCATION_RELWITHDEBINFO ${TBB_LIBRARIES_RELEASE}
+ IMPORTED_LOCATION_RELEASE ${TBB_LIBRARIES_RELEASE}
+ IMPORTED_LOCATION_MINSIZEREL ${TBB_LIBRARIES_RELEASE}
+ )
+ endif()
+ endif()
-# ------------------------------------------------------------------------
-# Cache and set TBB_FOUND
-# ------------------------------------------------------------------------
+ mark_as_advanced(TBB_INCLUDE_DIRS TBB_LIBRARIES)
+
+ unset(TBB_ARCHITECTURE)
@ -1588,18 +1609,8 @@ index bdf9c81..ffdee03 100644
+ message(STATUS " TBB_LIBRARIES_DEBUG = ${TBB_LIBRARIES_DEBUG}")
+ message(STATUS " TBB_DEFINITIONS_RELEASE = ${TBB_DEFINITIONS_RELEASE}")
+ message(STATUS " TBB_LIBRARIES_RELEASE = ${TBB_LIBRARIES_RELEASE}")
endif()
-endforeach()
+ endif()
-if(UNIX AND TBB_USE_STATIC_LIBS)
- set(CMAKE_FIND_LIBRARY_SUFFIXES ${_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})
- unset(_TBB_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES)
-endif()
-
-# ------------------------------------------------------------------------
-# Cache and set TBB_FOUND
-# ------------------------------------------------------------------------
-
-include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(TBB
- FOUND_VAR TBB_FOUND