Geant4 Cross Reference |
1 # - Find ThreadingBuildingBlocks include dirs 1 # - Find ThreadingBuildingBlocks include dirs and libraries 2 # Use this module by invoking find_package wit 2 # Use this module by invoking find_package with the form: 3 # find_package(TBB 3 # find_package(TBB 4 # [REQUIRED] # Fail with error 4 # [REQUIRED] # Fail with error if TBB is not found 5 # ) # 5 # ) # 6 # Once done, this will define 6 # Once done, this will define 7 # 7 # 8 # TBB_FOUND - system has TBB 8 # TBB_FOUND - system has TBB 9 # TBB_INCLUDE_DIRS - the TBB include director 9 # TBB_INCLUDE_DIRS - the TBB include directories 10 # TBB_LIBRARIES - TBB libraries to be lined, 10 # TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or 11 # malloc proxy 11 # malloc proxy 12 # TBB::tbb - imported target for the TBB libr 12 # TBB::tbb - imported target for the TBB library 13 # 13 # 14 # TBB_VERSION_MAJOR - Major Product Version N 14 # TBB_VERSION_MAJOR - Major Product Version Number 15 # TBB_VERSION_MINOR - Minor Product Version N 15 # TBB_VERSION_MINOR - Minor Product Version Number 16 # TBB_INTERFACE_VERSION - Engineering Focused 16 # TBB_INTERFACE_VERSION - Engineering Focused Version Number 17 # TBB_COMPATIBLE_INTERFACE_VERSION - The olde 17 # TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version 18 # still su 18 # still supported. This uses the engineering 19 # focused 19 # focused interface version numbers. 20 # 20 # 21 # TBB_MALLOC_FOUND - system has TBB malloc li 21 # TBB_MALLOC_FOUND - system has TBB malloc library 22 # TBB_MALLOC_INCLUDE_DIRS - the TBB malloc in 22 # TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories 23 # TBB_MALLOC_LIBRARIES - The TBB malloc libra 23 # TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined 24 # TBB::malloc - imported target for the TBB m 24 # TBB::malloc - imported target for the TBB malloc library 25 # 25 # 26 # TBB_MALLOC_PROXY_FOUND - system has TBB mal 26 # TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library 27 # TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB mal 27 # TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories 28 # TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc 28 # TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined 29 # TBB::malloc_proxy - imported target for the 29 # TBB::malloc_proxy - imported target for the TBB malloc proxy library 30 # 30 # 31 # 31 # 32 # This module reads hints about search locatio 32 # This module reads hints about search locations from variables: 33 # ENV TBB_ARCH_PLATFORM - for eg. set it to " 33 # ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds 34 # ENV TBB_ROOT or just TBB_ROOT - root direct 34 # ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation 35 # ENV TBB_BUILD_PREFIX - specifies the build 35 # ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb 36 # libraries. Should be 36 # libraries. Should be specified with ENV TBB_ROOT 37 # and optionally... 37 # and optionally... 38 # ENV TBB_BUILD_DIR - if build directory is d 38 # ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build 39 # 39 # 40 # 40 # 41 # Modified by Robert Maynard from the original 41 # Modified by Robert Maynard from the original OGRE source 42 # 42 # 43 #--------------------------------------------- 43 #------------------------------------------------------------------- 44 # This file is part of the CMake build system 44 # This file is part of the CMake build system for OGRE 45 # (Object-oriented Graphics Rendering Engi 45 # (Object-oriented Graphics Rendering Engine) 46 # For the latest info, see http://www.ogre3d.o 46 # For the latest info, see http://www.ogre3d.org/ 47 # 47 # 48 # The contents of this file are placed in the 48 # The contents of this file are placed in the public domain. Feel 49 # free to make use of it in any way you like. 49 # free to make use of it in any way you like. 50 #--------------------------------------------- 50 #------------------------------------------------------------------- 51 # 51 # 52 #============================================= 52 #============================================================================= 53 # Copyright 2010-2012 Kitware, Inc. 53 # Copyright 2010-2012 Kitware, Inc. 54 # Copyright 2012 Rolf Eike Beer <eike@sf- 54 # Copyright 2012 Rolf Eike Beer <eike@sf-mail.de> 55 # 55 # 56 # Distributed under the OSI-approved BSD Licen 56 # Distributed under the OSI-approved BSD License (the "License"); 57 # see accompanying file COPYING-CMAKE-SCRIPTS 57 # see accompanying file COPYING-CMAKE-SCRIPTS for details. 58 # 58 # 59 # This software is distributed WITHOUT ANY WAR 59 # This software is distributed WITHOUT ANY WARRANTY; without even the 60 # implied warranty of MERCHANTABILITY or FITNE 60 # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 61 # See the License for more information. 61 # See the License for more information. 62 #============================================= 62 #============================================================================= 63 63 64 #============================================= 64 #============================================================================= 65 # FindTBB helper functions and macros 65 # FindTBB helper functions and macros 66 # 66 # 67 67 68 # Use TBBConfig.cmake if possible. 68 # Use TBBConfig.cmake if possible. 69 69 70 set(_tbb_find_quiet) 70 set(_tbb_find_quiet) 71 if (TBB_FIND_QUIETLY) 71 if (TBB_FIND_QUIETLY) 72 set(_tbb_find_quiet QUIET) 72 set(_tbb_find_quiet QUIET) 73 endif () 73 endif () 74 set(_tbb_find_components) 74 set(_tbb_find_components) 75 set(_tbb_find_optional_components) 75 set(_tbb_find_optional_components) 76 foreach (_tbb_find_component IN LISTS TBB_FIND 76 foreach (_tbb_find_component IN LISTS TBB_FIND_COMPONENTS) 77 if (TBB_FIND_REQUIRED_${_tbb_find_component} 77 if (TBB_FIND_REQUIRED_${_tbb_find_component}) 78 list(APPEND _tbb_find_components "${_tbb_f 78 list(APPEND _tbb_find_components "${_tbb_find_component}") 79 else () 79 else () 80 list(APPEND _tbb_find_optional_components 80 list(APPEND _tbb_find_optional_components "${_tbb_find_component}") 81 endif () 81 endif () 82 endforeach () 82 endforeach () 83 unset(_tbb_find_component) 83 unset(_tbb_find_component) 84 find_package(TBB CONFIG ${_tbb_find_quiet} 84 find_package(TBB CONFIG ${_tbb_find_quiet} 85 COMPONENTS ${_tbb_find_components} 85 COMPONENTS ${_tbb_find_components} 86 OPTIONAL_COMPONENTS ${_tbb_find_optional_com 86 OPTIONAL_COMPONENTS ${_tbb_find_optional_components}) 87 unset(_tbb_find_quiet) 87 unset(_tbb_find_quiet) 88 unset(_tbb_find_components) 88 unset(_tbb_find_components) 89 unset(_tbb_find_optional_components) 89 unset(_tbb_find_optional_components) 90 if (TBB_FOUND) 90 if (TBB_FOUND) 91 return () 91 return () 92 endif () 92 endif () 93 93 94 #============================================= 94 #==================================================== 95 # Fix the library path in case it is a linker 95 # Fix the library path in case it is a linker script 96 #============================================= 96 #==================================================== 97 function(tbb_extract_real_library library real 97 function(tbb_extract_real_library library real_library) 98 if(NOT UNIX OR NOT EXISTS ${library}) 98 if(NOT UNIX OR NOT EXISTS ${library}) 99 set(${real_library} "${library}" PARENT_SC 99 set(${real_library} "${library}" PARENT_SCOPE) 100 return() 100 return() 101 endif() 101 endif() 102 102 103 #Read in the first 4 bytes and see if they a 103 #Read in the first 4 bytes and see if they are the ELF magic number 104 set(_elf_magic "7f454c46") 104 set(_elf_magic "7f454c46") 105 file(READ ${library} _hex_data OFFSET 0 LIMI 105 file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX) 106 if(_hex_data STREQUAL _elf_magic) 106 if(_hex_data STREQUAL _elf_magic) 107 #we have opened a elf binary so this is wh 107 #we have opened a elf binary so this is what 108 #we should link to 108 #we should link to 109 set(${real_library} "${library}" PARENT_SC 109 set(${real_library} "${library}" PARENT_SCOPE) 110 return() 110 return() 111 endif() 111 endif() 112 112 113 file(READ ${library} _data OFFSET 0 LIMIT 10 113 file(READ ${library} _data OFFSET 0 LIMIT 1024) 114 if("${_data}" MATCHES "INPUT \\(([^(]+)\\)") 114 if("${_data}" MATCHES "INPUT \\(([^(]+)\\)") 115 #extract out the .so name from REGEX MATCH 115 #extract out the .so name from REGEX MATCH command 116 set(_proper_so_name "${CMAKE_MATCH_1}") 116 set(_proper_so_name "${CMAKE_MATCH_1}") 117 117 118 #construct path to the real .so which is p 118 #construct path to the real .so which is presumed to be in the same directory 119 #as the input file 119 #as the input file 120 get_filename_component(_so_dir "${library} 120 get_filename_component(_so_dir "${library}" DIRECTORY) 121 set(${real_library} "${_so_dir}/${_proper_ 121 set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE) 122 else() 122 else() 123 #unable to determine what this library is 123 #unable to determine what this library is so just hope everything works 124 #and pass it unmodified. 124 #and pass it unmodified. 125 set(${real_library} "${library}" PARENT_SC 125 set(${real_library} "${library}" PARENT_SCOPE) 126 endif() 126 endif() 127 endfunction() 127 endfunction() 128 128 129 #============================================= 129 #=============================================== 130 # Do the final processing for the package find 130 # Do the final processing for the package find. 131 #============================================= 131 #=============================================== 132 macro(findpkg_finish PREFIX TARGET_NAME) 132 macro(findpkg_finish PREFIX TARGET_NAME) 133 if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBR 133 if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY) 134 set(${PREFIX}_FOUND TRUE) 134 set(${PREFIX}_FOUND TRUE) 135 set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_IN 135 set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR}) 136 set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRA 136 set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY}) 137 else () 137 else () 138 if (${PREFIX}_FIND_REQUIRED AND NOT ${PREF 138 if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY) 139 message(FATAL_ERROR "Required library ${ 139 message(FATAL_ERROR "Required library ${PREFIX} not found.") 140 endif () 140 endif () 141 endif () 141 endif () 142 142 143 if (NOT TARGET "TBB::${TARGET_NAME}") 143 if (NOT TARGET "TBB::${TARGET_NAME}") 144 if (${PREFIX}_LIBRARY_RELEASE) 144 if (${PREFIX}_LIBRARY_RELEASE) 145 tbb_extract_real_library(${${PREFIX}_LIB 145 tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release) 146 endif () 146 endif () 147 if (${PREFIX}_LIBRARY_DEBUG) 147 if (${PREFIX}_LIBRARY_DEBUG) 148 tbb_extract_real_library(${${PREFIX}_LIB 148 tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug) 149 endif () 149 endif () 150 add_library(TBB::${TARGET_NAME} UNKNOWN IM 150 add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED) 151 set_target_properties(TBB::${TARGET_NAME} 151 set_target_properties(TBB::${TARGET_NAME} PROPERTIES 152 INTERFACE_INCLUDE_DIRECTORIES "${${PREFI 152 INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}") 153 if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_ 153 if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE) 154 set_target_properties(TBB::${TARGET_NAME 154 set_target_properties(TBB::${TARGET_NAME} PROPERTIES 155 IMPORTED_LOCATION "${real_release}" 155 IMPORTED_LOCATION "${real_release}" 156 IMPORTED_LOCATION_DEBUG "${real_debug} 156 IMPORTED_LOCATION_DEBUG "${real_debug}" 157 IMPORTED_LOCATION_RELEASE "${real_rele 157 IMPORTED_LOCATION_RELEASE "${real_release}") 158 elseif (${PREFIX}_LIBRARY_RELEASE) 158 elseif (${PREFIX}_LIBRARY_RELEASE) 159 set_target_properties(TBB::${TARGET_NAME 159 set_target_properties(TBB::${TARGET_NAME} PROPERTIES 160 IMPORTED_LOCATION "${real_release}") 160 IMPORTED_LOCATION "${real_release}") 161 elseif (${PREFIX}_LIBRARY_DEBUG) 161 elseif (${PREFIX}_LIBRARY_DEBUG) 162 set_target_properties(TBB::${TARGET_NAME 162 set_target_properties(TBB::${TARGET_NAME} PROPERTIES 163 IMPORTED_LOCATION "${real_debug}") 163 IMPORTED_LOCATION "${real_debug}") 164 endif () 164 endif () 165 endif () 165 endif () 166 166 167 #mark the following variables as internal va 167 #mark the following variables as internal variables 168 mark_as_advanced(${PREFIX}_INCLUDE_DIR 168 mark_as_advanced(${PREFIX}_INCLUDE_DIR 169 ${PREFIX}_LIBRARY 169 ${PREFIX}_LIBRARY 170 ${PREFIX}_LIBRARY_DEBUG 170 ${PREFIX}_LIBRARY_DEBUG 171 ${PREFIX}_LIBRARY_RELEASE) 171 ${PREFIX}_LIBRARY_RELEASE) 172 endmacro() 172 endmacro() 173 173 174 #============================================= 174 #=============================================== 175 # Generate debug names from given release name 175 # Generate debug names from given release names 176 #============================================= 176 #=============================================== 177 macro(get_debug_names PREFIX) 177 macro(get_debug_names PREFIX) 178 foreach(i ${${PREFIX}}) 178 foreach(i ${${PREFIX}}) 179 set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i 179 set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i}) 180 endforeach() 180 endforeach() 181 endmacro() 181 endmacro() 182 182 183 #============================================= 183 #=============================================== 184 # See if we have env vars to help us find tbb 184 # See if we have env vars to help us find tbb 185 #============================================= 185 #=============================================== 186 macro(getenv_path VAR) 186 macro(getenv_path VAR) 187 set(ENV_${VAR} $ENV{${VAR}}) 187 set(ENV_${VAR} $ENV{${VAR}}) 188 # replace won't work if var is blank 188 # replace won't work if var is blank 189 if (ENV_${VAR}) 189 if (ENV_${VAR}) 190 string( REGEX REPLACE "\\\\" "/" ENV_${VA 190 string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} ) 191 endif () 191 endif () 192 endmacro() 192 endmacro() 193 193 194 #============================================= 194 #=============================================== 195 # Couple a set of release AND debug libraries 195 # Couple a set of release AND debug libraries 196 #============================================= 196 #=============================================== 197 macro(make_library_set PREFIX) 197 macro(make_library_set PREFIX) 198 if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG) 198 if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG) 199 set(${PREFIX} optimized ${${PREFIX}_RELEAS 199 set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG}) 200 elseif (${PREFIX}_RELEASE) 200 elseif (${PREFIX}_RELEASE) 201 set(${PREFIX} ${${PREFIX}_RELEASE}) 201 set(${PREFIX} ${${PREFIX}_RELEASE}) 202 elseif (${PREFIX}_DEBUG) 202 elseif (${PREFIX}_DEBUG) 203 set(${PREFIX} ${${PREFIX}_DEBUG}) 203 set(${PREFIX} ${${PREFIX}_DEBUG}) 204 endif () 204 endif () 205 endmacro() 205 endmacro() 206 206 207 207 208 #============================================= 208 #============================================================================= 209 # Now to actually find TBB 209 # Now to actually find TBB 210 # 210 # 211 211 212 # Get path, convert backslashes as ${ENV_${var 212 # Get path, convert backslashes as ${ENV_${var}} 213 getenv_path(TBB_ROOT) 213 getenv_path(TBB_ROOT) 214 214 215 # initialize search paths 215 # initialize search paths 216 set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT 216 set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT}) 217 set(TBB_INC_SEARCH_PATH "") 217 set(TBB_INC_SEARCH_PATH "") 218 set(TBB_LIB_SEARCH_PATH "") 218 set(TBB_LIB_SEARCH_PATH "") 219 219 220 220 221 # If user built from sources 221 # If user built from sources 222 set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX}) 222 set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX}) 223 if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT) 223 if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT) 224 getenv_path(TBB_BUILD_DIR) 224 getenv_path(TBB_BUILD_DIR) 225 if (NOT ENV_TBB_BUILD_DIR) 225 if (NOT ENV_TBB_BUILD_DIR) 226 set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/buil 226 set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build) 227 endif () 227 endif () 228 228 229 # include directory under ${ENV_TBB_ROOT}/in 229 # include directory under ${ENV_TBB_ROOT}/include 230 list(APPEND TBB_LIB_SEARCH_PATH 230 list(APPEND TBB_LIB_SEARCH_PATH 231 ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_r 231 ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release 232 ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_d 232 ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug) 233 endif () 233 endif () 234 234 235 235 236 # For Windows, let's assume that the user migh 236 # For Windows, let's assume that the user might be using the precompiled 237 # TBB packages from the main website. These us 237 # TBB packages from the main website. These use a rather awkward directory 238 # structure (at least for automatically findin 238 # structure (at least for automatically finding the right files) depending 239 # on platform and compiler, but we'll do our b 239 # on platform and compiler, but we'll do our best to accommodate it. 240 # Not adding the same effort for the precompil 240 # Not adding the same effort for the precompiled linux builds, though. Those 241 # have different versions for CC compiler vers 241 # have different versions for CC compiler versions and linux kernels which 242 # will never adequately match the user's setup 242 # will never adequately match the user's setup, so there is no feasible way 243 # to detect the "best" version to use. The use 243 # to detect the "best" version to use. The user will have to manually 244 # select the right files. (Chances are the dis 244 # select the right files. (Chances are the distributions are shipping their 245 # custom version of tbb, anyway, so the proble 245 # custom version of tbb, anyway, so the problem is probably nonexistent.) 246 if (WIN32 AND MSVC) 246 if (WIN32 AND MSVC) 247 set(COMPILER_PREFIX "vc7.1") 247 set(COMPILER_PREFIX "vc7.1") 248 if (MSVC_VERSION EQUAL 1400) 248 if (MSVC_VERSION EQUAL 1400) 249 set(COMPILER_PREFIX "vc8") 249 set(COMPILER_PREFIX "vc8") 250 elseif(MSVC_VERSION EQUAL 1500) 250 elseif(MSVC_VERSION EQUAL 1500) 251 set(COMPILER_PREFIX "vc9") 251 set(COMPILER_PREFIX "vc9") 252 elseif(MSVC_VERSION EQUAL 1600) 252 elseif(MSVC_VERSION EQUAL 1600) 253 set(COMPILER_PREFIX "vc10") 253 set(COMPILER_PREFIX "vc10") 254 elseif(MSVC_VERSION EQUAL 1700) 254 elseif(MSVC_VERSION EQUAL 1700) 255 set(COMPILER_PREFIX "vc11") 255 set(COMPILER_PREFIX "vc11") 256 elseif(MSVC_VERSION EQUAL 1800) 256 elseif(MSVC_VERSION EQUAL 1800) 257 set(COMPILER_PREFIX "vc12") 257 set(COMPILER_PREFIX "vc12") 258 elseif(MSVC_VERSION GREATER_EQUAL 1900) 258 elseif(MSVC_VERSION GREATER_EQUAL 1900) 259 set(COMPILER_PREFIX "vc14") 259 set(COMPILER_PREFIX "vc14") 260 endif () 260 endif () 261 261 262 # for each prefix path, add ia32/64\${COMPIL 262 # for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path 263 foreach (dir IN LISTS TBB_PREFIX_PATH) 263 foreach (dir IN LISTS TBB_PREFIX_PATH) 264 if (CMAKE_CL_64) 264 if (CMAKE_CL_64) 265 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 265 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib) 266 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 266 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX}) 267 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 267 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib) 268 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 268 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX}) 269 else () 269 else () 270 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 270 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib) 271 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 271 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX}) 272 endif () 272 endif () 273 endforeach () 273 endforeach () 274 endif () 274 endif () 275 275 276 # For OS X binary distribution, choose libc++ 276 # For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9) 277 # and above and AppleClang 277 # and above and AppleClang 278 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND 278 if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND 279 NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0 279 NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0) 280 set (USE_LIBCXX OFF) 280 set (USE_LIBCXX OFF) 281 cmake_policy(GET CMP0025 POLICY_VAR) 281 cmake_policy(GET CMP0025 POLICY_VAR) 282 282 283 if (POLICY_VAR STREQUAL "NEW") 283 if (POLICY_VAR STREQUAL "NEW") 284 if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleC 284 if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") 285 set (USE_LIBCXX ON) 285 set (USE_LIBCXX ON) 286 endif () 286 endif () 287 else () 287 else () 288 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" 288 if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") 289 set (USE_LIBCXX ON) 289 set (USE_LIBCXX ON) 290 endif () 290 endif () 291 endif () 291 endif () 292 292 293 if (USE_LIBCXX) 293 if (USE_LIBCXX) 294 foreach (dir IN LISTS TBB_PREFIX_PATH) 294 foreach (dir IN LISTS TBB_PREFIX_PATH) 295 list (APPEND TBB_LIB_SEARCH_PATH ${dir}/ 295 list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib) 296 endforeach () 296 endforeach () 297 endif () 297 endif () 298 endif () 298 endif () 299 299 300 # check compiler ABI 300 # check compiler ABI 301 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 301 if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") 302 set(COMPILER_PREFIX) 302 set(COMPILER_PREFIX) 303 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_L 303 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) 304 list(APPEND COMPILER_PREFIX "gcc4.8") 304 list(APPEND COMPILER_PREFIX "gcc4.8") 305 endif() 305 endif() 306 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_L 306 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) 307 list(APPEND COMPILER_PREFIX "gcc4.7") 307 list(APPEND COMPILER_PREFIX "gcc4.7") 308 endif() 308 endif() 309 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_L 309 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) 310 list(APPEND COMPILER_PREFIX "gcc4.4") 310 list(APPEND COMPILER_PREFIX "gcc4.4") 311 endif() 311 endif() 312 list(APPEND COMPILER_PREFIX "gcc4.1") 312 list(APPEND COMPILER_PREFIX "gcc4.1") 313 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 313 elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") 314 set(COMPILER_PREFIX) 314 set(COMPILER_PREFIX) 315 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_L 315 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess 316 list(APPEND COMPILER_PREFIX "gcc4.8") 316 list(APPEND COMPILER_PREFIX "gcc4.8") 317 endif() 317 endif() 318 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_L 318 if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) 319 list(APPEND COMPILER_PREFIX "gcc4.7") 319 list(APPEND COMPILER_PREFIX "gcc4.7") 320 endif() 320 endif() 321 list(APPEND COMPILER_PREFIX "gcc4.4") 321 list(APPEND COMPILER_PREFIX "gcc4.4") 322 else() # Assume compatibility with 4.4 for oth 322 else() # Assume compatibility with 4.4 for other compilers 323 list(APPEND COMPILER_PREFIX "gcc4.4") 323 list(APPEND COMPILER_PREFIX "gcc4.4") 324 endif () 324 endif () 325 325 326 # if platform architecture is explicitly speci 326 # if platform architecture is explicitly specified 327 set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM}) 327 set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM}) 328 if (TBB_ARCH_PLATFORM) 328 if (TBB_ARCH_PLATFORM) 329 foreach (dir IN LISTS TBB_PREFIX_PATH) 329 foreach (dir IN LISTS TBB_PREFIX_PATH) 330 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${T 330 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib) 331 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib 331 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM}) 332 endforeach () 332 endforeach () 333 endif () 333 endif () 334 334 335 foreach (dir IN LISTS TBB_PREFIX_PATH) 335 foreach (dir IN LISTS TBB_PREFIX_PATH) 336 foreach (prefix IN LISTS COMPILER_PREFIX) 336 foreach (prefix IN LISTS COMPILER_PREFIX) 337 if (CMAKE_SIZEOF_VOID_P EQUAL 8) 337 if (CMAKE_SIZEOF_VOID_P EQUAL 8) 338 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 338 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64) 339 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 339 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix}) 340 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 340 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib) 341 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 341 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib) 342 else () 342 else () 343 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 343 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32) 344 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/l 344 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix}) 345 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 345 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib) 346 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/i 346 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib) 347 endif () 347 endif () 348 endforeach() 348 endforeach() 349 endforeach () 349 endforeach () 350 350 351 # add general search paths 351 # add general search paths 352 foreach (dir IN LISTS TBB_PREFIX_PATH) 352 foreach (dir IN LISTS TBB_PREFIX_PATH) 353 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib $ 353 list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb 354 ${dir}/Libs) 354 ${dir}/Libs) 355 list(APPEND TBB_INC_SEARCH_PATH ${dir}/inclu 355 list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include 356 ${dir}/include/tbb) 356 ${dir}/include/tbb) 357 endforeach () 357 endforeach () 358 358 359 set(TBB_LIBRARY_NAMES tbb) 359 set(TBB_LIBRARY_NAMES tbb) 360 get_debug_names(TBB_LIBRARY_NAMES) 360 get_debug_names(TBB_LIBRARY_NAMES) 361 361 362 362 363 find_path(TBB_INCLUDE_DIR 363 find_path(TBB_INCLUDE_DIR 364 NAMES tbb/tbb.h 364 NAMES tbb/tbb.h 365 PATHS ${TBB_INC_SEARCH_PATH}) 365 PATHS ${TBB_INC_SEARCH_PATH}) 366 366 367 find_library(TBB_LIBRARY_RELEASE 367 find_library(TBB_LIBRARY_RELEASE 368 NAMES ${TBB_LIBRARY_NAMES} 368 NAMES ${TBB_LIBRARY_NAMES} 369 PATHS ${TBB_LIB_SEARCH_PATH}) 369 PATHS ${TBB_LIB_SEARCH_PATH}) 370 find_library(TBB_LIBRARY_DEBUG 370 find_library(TBB_LIBRARY_DEBUG 371 NAMES ${TBB_LIBRARY_NAMES_DEBUG} 371 NAMES ${TBB_LIBRARY_NAMES_DEBUG} 372 PATHS ${TBB_LIB_SEARCH_PATH}) 372 PATHS ${TBB_LIB_SEARCH_PATH}) 373 make_library_set(TBB_LIBRARY) 373 make_library_set(TBB_LIBRARY) 374 374 375 findpkg_finish(TBB tbb) 375 findpkg_finish(TBB tbb) 376 376 377 #if we haven't found TBB no point on going any 377 #if we haven't found TBB no point on going any further 378 if (NOT TBB_FOUND) 378 if (NOT TBB_FOUND) 379 return() 379 return() 380 endif () 380 endif () 381 381 382 #============================================= 382 #============================================================================= 383 # Look for TBB's malloc package 383 # Look for TBB's malloc package 384 set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc) 384 set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc) 385 get_debug_names(TBB_MALLOC_LIBRARY_NAMES) 385 get_debug_names(TBB_MALLOC_LIBRARY_NAMES) 386 386 387 find_path(TBB_MALLOC_INCLUDE_DIR 387 find_path(TBB_MALLOC_INCLUDE_DIR 388 NAMES tbb/tbb.h 388 NAMES tbb/tbb.h 389 PATHS ${TBB_INC_SEARCH_PATH}) 389 PATHS ${TBB_INC_SEARCH_PATH}) 390 390 391 find_library(TBB_MALLOC_LIBRARY_RELEASE 391 find_library(TBB_MALLOC_LIBRARY_RELEASE 392 NAMES ${TBB_MALLOC_LIBRARY_NAMES} 392 NAMES ${TBB_MALLOC_LIBRARY_NAMES} 393 PATHS ${TBB_LIB_SEARCH_PATH}) 393 PATHS ${TBB_LIB_SEARCH_PATH}) 394 find_library(TBB_MALLOC_LIBRARY_DEBUG 394 find_library(TBB_MALLOC_LIBRARY_DEBUG 395 NAMES ${TBB_MALLOC_LIBRARY_NAMES_ 395 NAMES ${TBB_MALLOC_LIBRARY_NAMES_DEBUG} 396 PATHS ${TBB_LIB_SEARCH_PATH}) 396 PATHS ${TBB_LIB_SEARCH_PATH}) 397 make_library_set(TBB_MALLOC_LIBRARY) 397 make_library_set(TBB_MALLOC_LIBRARY) 398 398 399 findpkg_finish(TBB_MALLOC tbbmalloc) 399 findpkg_finish(TBB_MALLOC tbbmalloc) 400 400 401 #============================================= 401 #============================================================================= 402 # Look for TBB's malloc proxy package 402 # Look for TBB's malloc proxy package 403 set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_p 403 set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy) 404 get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES 404 get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES) 405 405 406 find_path(TBB_MALLOC_PROXY_INCLUDE_DIR 406 find_path(TBB_MALLOC_PROXY_INCLUDE_DIR 407 NAMES tbb/tbbmalloc_proxy.h 407 NAMES tbb/tbbmalloc_proxy.h 408 PATHS ${TBB_INC_SEARCH_PATH}) 408 PATHS ${TBB_INC_SEARCH_PATH}) 409 409 410 find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE 410 find_library(TBB_MALLOC_PROXY_LIBRARY_RELEASE 411 NAMES ${TBB_MALLOC_PROXY_LIBRARY_ 411 NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES} 412 PATHS ${TBB_LIB_SEARCH_PATH}) 412 PATHS ${TBB_LIB_SEARCH_PATH}) 413 find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG 413 find_library(TBB_MALLOC_PROXY_LIBRARY_DEBUG 414 NAMES ${TBB_MALLOC_PROXY_LIBRARY_ 414 NAMES ${TBB_MALLOC_PROXY_LIBRARY_NAMES_DEBUG} 415 PATHS ${TBB_LIB_SEARCH_PATH}) 415 PATHS ${TBB_LIB_SEARCH_PATH}) 416 make_library_set(TBB_MALLOC_PROXY_LIBRARY) 416 make_library_set(TBB_MALLOC_PROXY_LIBRARY) 417 417 418 findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_prox 418 findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy) 419 419 420 420 421 #============================================= 421 #============================================================================= 422 #parse all the version numbers from tbb 422 #parse all the version numbers from tbb 423 if(NOT TBB_VERSION) 423 if(NOT TBB_VERSION) 424 if (EXISTS "${TBB_INCLUDE_DIR}/oneapi/tbb/ve 424 if (EXISTS "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h") 425 file(STRINGS 425 file(STRINGS 426 "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h 426 "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h" 427 TBB_VERSION_CONTENTS 427 TBB_VERSION_CONTENTS 428 REGEX "VERSION") 428 REGEX "VERSION") 429 else() 429 else() 430 #only read the start of the file 430 #only read the start of the file 431 file(STRINGS 431 file(STRINGS 432 "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" 432 "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" 433 TBB_VERSION_CONTENTS 433 TBB_VERSION_CONTENTS 434 REGEX "VERSION") 434 REGEX "VERSION") 435 endif() 435 endif() 436 436 437 string(REGEX REPLACE 437 string(REGEX REPLACE 438 ".*#define TBB_VERSION_MAJOR ([0-9]+).*" " 438 ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" 439 TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS} 439 TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}") 440 440 441 string(REGEX REPLACE 441 string(REGEX REPLACE 442 ".*#define TBB_VERSION_MINOR ([0-9]+).*" " 442 ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" 443 TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS} 443 TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}") 444 444 445 string(REGEX REPLACE 445 string(REGEX REPLACE 446 ".*#define TBB_INTERFACE_VERSION ([0-9 446 ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" 447 TBB_INTERFACE_VERSION "${TBB_VERSION_C 447 TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") 448 448 449 string(REGEX REPLACE 449 string(REGEX REPLACE 450 ".*#define TBB_COMPATIBLE_INTERFACE_VE 450 ".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1" 451 TBB_COMPATIBLE_INTERFACE_VERSION "${TB 451 TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") 452 452 453 set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_ 453 set(TBB_VERSION "${TBB_VERSION_MAJOR}.${TBB_VERSION_MINOR}") 454 454 455 endif() 455 endif() 456 456 457 include(FindPackageHandleStandardArgs) 457 include(FindPackageHandleStandardArgs) 458 find_package_handle_standard_args(TBB 458 find_package_handle_standard_args(TBB 459 REQUIRED_VARS TBB_INCLUDE_DIR TBB_LIBRARY 459 REQUIRED_VARS TBB_INCLUDE_DIR TBB_LIBRARY 460 VERSION_VAR TBB_VERSION) 460 VERSION_VAR TBB_VERSION)