Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 1 | # - Find ThreadingBuildingBlocks include dirs and libraries |
| 2 | # Use this module by invoking find_package with the form: |
| 3 | # find_package(TBB |
| 4 | # [REQUIRED] # Fail with error if TBB is not found |
| 5 | # ) # |
| 6 | # Once done, this will define |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 7 | # |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 8 | # TBB_FOUND - system has TBB |
| 9 | # TBB_INCLUDE_DIRS - the TBB include directories |
| 10 | # TBB_LIBRARIES - TBB libraries to be lined, doesn't include malloc or |
| 11 | # malloc proxy |
| 12 | # TBB::tbb - imported target for the TBB library |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 13 | # |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 14 | # TBB_VERSION_MAJOR - Major Product Version Number |
| 15 | # TBB_VERSION_MINOR - Minor Product Version Number |
| 16 | # TBB_INTERFACE_VERSION - Engineering Focused Version Number |
| 17 | # TBB_COMPATIBLE_INTERFACE_VERSION - The oldest major interface version |
| 18 | # still supported. This uses the engineering |
| 19 | # focused interface version numbers. |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 20 | # |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 21 | # TBB_MALLOC_FOUND - system has TBB malloc library |
| 22 | # TBB_MALLOC_INCLUDE_DIRS - the TBB malloc include directories |
| 23 | # TBB_MALLOC_LIBRARIES - The TBB malloc libraries to be lined |
| 24 | # TBB::malloc - imported target for the TBB malloc library |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 25 | # |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 26 | # TBB_MALLOC_PROXY_FOUND - system has TBB malloc proxy library |
| 27 | # TBB_MALLOC_PROXY_INCLUDE_DIRS = the TBB malloc proxy include directories |
| 28 | # TBB_MALLOC_PROXY_LIBRARIES - The TBB malloc proxy libraries to be lined |
| 29 | # TBB::malloc_proxy - imported target for the TBB malloc proxy library |
| 30 | # |
| 31 | # |
| 32 | # This module reads hints about search locations from variables: |
| 33 | # ENV TBB_ARCH_PLATFORM - for eg. set it to "mic" for Xeon Phi builds |
| 34 | # ENV TBB_ROOT or just TBB_ROOT - root directory of tbb installation |
| 35 | # ENV TBB_BUILD_PREFIX - specifies the build prefix for user built tbb |
| 36 | # libraries. Should be specified with ENV TBB_ROOT |
| 37 | # and optionally... |
| 38 | # ENV TBB_BUILD_DIR - if build directory is different than ${TBB_ROOT}/build |
| 39 | # |
| 40 | # |
| 41 | # Modified by Robert Maynard from the original OGRE source |
| 42 | # |
| 43 | #------------------------------------------------------------------- |
| 44 | # This file is part of the CMake build system for OGRE |
| 45 | # (Object-oriented Graphics Rendering Engine) |
| 46 | # For the latest info, see http://www.ogre3d.org/ |
| 47 | # |
| 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. |
| 50 | #------------------------------------------------------------------- |
| 51 | # |
| 52 | # ========================================================================= |
| 53 | # Taken from Copyright.txt in the root of the VTK source tree as per |
| 54 | # instructions to substitute the full license in place of the summary |
| 55 | # reference when distributing outside of VTK |
| 56 | # ========================================================================= |
| 57 | # |
| 58 | # Program: Visualization Toolkit |
| 59 | # Module: Copyright.txt |
| 60 | # |
| 61 | # Copyright (c) 1993-2015 Ken Martin, Will Schroeder, Bill Lorensen |
| 62 | # All rights reserved. |
| 63 | # |
| 64 | # Redistribution and use in source and binary forms, with or without |
| 65 | # modification, are permitted provided that the following conditions are met: |
| 66 | # |
| 67 | # * Redistributions of source code must retain the above copyright notice, |
| 68 | # this list of conditions and the following disclaimer. |
| 69 | # |
| 70 | # * Redistributions in binary form must reproduce the above copyright notice, |
| 71 | # this list of conditions and the following disclaimer in the documentation |
| 72 | # and/or other materials provided with the distribution. |
| 73 | # |
| 74 | # * Neither name of Ken Martin, Will Schroeder, or Bill Lorensen nor the names |
| 75 | # of any contributors may be used to endorse or promote products derived |
| 76 | # from this software without specific prior written permission. |
| 77 | # |
| 78 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' |
| 79 | # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
| 80 | # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE |
| 81 | # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHORS OR CONTRIBUTORS BE LIABLE FOR |
| 82 | # ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
| 83 | # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
| 84 | # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
| 85 | # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 86 | # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 87 | # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 88 | # |
| 89 | # =========================================================================*/ |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 90 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 91 | #============================================================================= |
| 92 | # FindTBB helper functions and macros |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 93 | # |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 94 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 95 | #==================================================== |
| 96 | # Fix the library path in case it is a linker script |
| 97 | #==================================================== |
| 98 | function(tbb_extract_real_library library real_library) |
| 99 | if(NOT UNIX OR NOT EXISTS ${library}) |
| 100 | set(${real_library} "${library}" PARENT_SCOPE) |
| 101 | return() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 102 | endif() |
| 103 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 104 | #Read in the first 4 bytes and see if they are the ELF magic number |
| 105 | set(_elf_magic "7f454c46") |
| 106 | file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX) |
| 107 | if(_hex_data STREQUAL _elf_magic) |
| 108 | #we have opened a elf binary so this is what |
| 109 | #we should link to |
| 110 | set(${real_library} "${library}" PARENT_SCOPE) |
| 111 | return() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 112 | endif() |
| 113 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 114 | file(READ ${library} _data OFFSET 0 LIMIT 1024) |
| 115 | if("${_data}" MATCHES "INPUT \\(([^(]+)\\)") |
| 116 | #extract out the .so name from REGEX MATCH command |
| 117 | set(_proper_so_name "${CMAKE_MATCH_1}") |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 118 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 119 | #construct path to the real .so which is presumed to be in the same directory |
| 120 | #as the input file |
| 121 | get_filename_component(_so_dir "${library}" DIRECTORY) |
| 122 | set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE) |
| 123 | else() |
| 124 | #unable to determine what this library is so just hope everything works |
| 125 | #and pass it unmodified. |
| 126 | set(${real_library} "${library}" PARENT_SCOPE) |
| 127 | endif() |
| 128 | endfunction() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 129 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 130 | #=============================================== |
| 131 | # Do the final processing for the package find. |
| 132 | #=============================================== |
| 133 | macro(findpkg_finish PREFIX TARGET_NAME) |
| 134 | if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY) |
| 135 | set(${PREFIX}_FOUND TRUE) |
| 136 | set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR}) |
| 137 | set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY}) |
| 138 | else () |
| 139 | if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY) |
| 140 | message(FATAL_ERROR "Required library ${PREFIX} not found.") |
| 141 | endif () |
| 142 | endif () |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 143 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 144 | if (NOT TARGET "TBB::${TARGET_NAME}") |
| 145 | if (${PREFIX}_LIBRARY_RELEASE) |
| 146 | tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release) |
| 147 | endif () |
| 148 | if (${PREFIX}_LIBRARY_DEBUG) |
| 149 | tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug) |
| 150 | endif () |
| 151 | add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED) |
| 152 | set_target_properties(TBB::${TARGET_NAME} PROPERTIES |
| 153 | INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}") |
| 154 | if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE) |
| 155 | set_target_properties(TBB::${TARGET_NAME} PROPERTIES |
| 156 | IMPORTED_LOCATION "${real_release}" |
| 157 | IMPORTED_LOCATION_DEBUG "${real_debug}" |
| 158 | IMPORTED_LOCATION_RELEASE "${real_release}") |
| 159 | elseif (${PREFIX}_LIBRARY_RELEASE) |
| 160 | set_target_properties(TBB::${TARGET_NAME} PROPERTIES |
| 161 | IMPORTED_LOCATION "${real_release}") |
| 162 | elseif (${PREFIX}_LIBRARY_DEBUG) |
| 163 | set_target_properties(TBB::${TARGET_NAME} PROPERTIES |
| 164 | IMPORTED_LOCATION "${real_debug}") |
| 165 | endif () |
| 166 | endif () |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 167 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 168 | #mark the following variables as internal variables |
| 169 | mark_as_advanced(${PREFIX}_INCLUDE_DIR |
| 170 | ${PREFIX}_LIBRARY |
| 171 | ${PREFIX}_LIBRARY_DEBUG |
| 172 | ${PREFIX}_LIBRARY_RELEASE) |
| 173 | endmacro() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 174 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 175 | #=============================================== |
| 176 | # Generate debug names from given release names |
| 177 | #=============================================== |
| 178 | macro(get_debug_names PREFIX) |
| 179 | foreach(i ${${PREFIX}}) |
| 180 | set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i}) |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 181 | endforeach() |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 182 | endmacro() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 183 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 184 | #=============================================== |
| 185 | # See if we have env vars to help us find tbb |
| 186 | #=============================================== |
| 187 | macro(getenv_path VAR) |
| 188 | set(ENV_${VAR} $ENV{${VAR}}) |
| 189 | # replace won't work if var is blank |
| 190 | if (ENV_${VAR}) |
| 191 | string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} ) |
| 192 | endif () |
| 193 | endmacro() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 194 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 195 | #=============================================== |
| 196 | # Couple a set of release AND debug libraries |
| 197 | #=============================================== |
| 198 | macro(make_library_set PREFIX) |
| 199 | if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG) |
| 200 | set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG}) |
| 201 | elseif (${PREFIX}_RELEASE) |
| 202 | set(${PREFIX} ${${PREFIX}_RELEASE}) |
| 203 | elseif (${PREFIX}_DEBUG) |
| 204 | set(${PREFIX} ${${PREFIX}_DEBUG}) |
| 205 | endif () |
| 206 | endmacro() |
| 207 | |
| 208 | #=============================================== |
| 209 | # Ensure that the release & debug libraries found are from the same installation. |
| 210 | #=============================================== |
| 211 | macro(find_tbb_library_verifying_release_debug_locations PREFIX) |
| 212 | find_library(${PREFIX}_RELEASE |
| 213 | NAMES ${${PREFIX}_NAMES} |
| 214 | HINTS ${TBB_LIB_SEARCH_PATH}) |
| 215 | if (${PREFIX}_RELEASE) |
| 216 | # To avoid finding a mismatched set of release & debug libraries from |
| 217 | # different installations if the first found does not have debug libraries |
| 218 | # by forcing the search for debug to only occur within the detected release |
| 219 | # library directory (if found). Although this would break detection if the |
| 220 | # release & debug libraries were shipped in different directories, this is |
| 221 | # not the case in the official TBB releases for any platform. |
| 222 | get_filename_component( |
| 223 | FOUND_RELEASE_LIB_DIR "${${PREFIX}_RELEASE}" DIRECTORY) |
| 224 | find_library(${PREFIX}_DEBUG |
| 225 | NAMES ${${PREFIX}_NAMES_DEBUG} |
| 226 | HINTS ${FOUND_RELEASE_LIB_DIR} |
| 227 | NO_DEFAULT_PATH) |
| 228 | else() |
| 229 | find_library(${PREFIX}_DEBUG |
| 230 | NAMES ${${PREFIX}_NAMES_DEBUG} |
| 231 | HINTS ${TBB_LIB_SEARCH_PATH}) |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 232 | endif() |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 233 | endmacro() |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 234 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 235 | #============================================================================= |
| 236 | # Now to actually find TBB |
| 237 | # |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 238 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 239 | # Get path, convert backslashes as ${ENV_${var}} |
| 240 | getenv_path(TBB_ROOT) |
| 241 | |
| 242 | # initialize search paths |
| 243 | set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT}) |
| 244 | set(TBB_INC_SEARCH_PATH "") |
| 245 | set(TBB_LIB_SEARCH_PATH "") |
| 246 | |
| 247 | |
| 248 | # If user built from sources |
| 249 | set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX}) |
| 250 | if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT) |
| 251 | getenv_path(TBB_BUILD_DIR) |
| 252 | if (NOT ENV_TBB_BUILD_DIR) |
| 253 | set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build) |
| 254 | endif () |
| 255 | |
| 256 | # include directory under ${ENV_TBB_ROOT}/include |
| 257 | list(APPEND TBB_LIB_SEARCH_PATH |
| 258 | ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release |
| 259 | ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug) |
| 260 | endif () |
| 261 | |
| 262 | |
| 263 | # For Windows, let's assume that the user might be using the precompiled |
| 264 | # TBB packages from the main website. These use a rather awkward directory |
| 265 | # structure (at least for automatically finding the right files) depending |
| 266 | # on platform and compiler, but we'll do our best to accommodate it. |
| 267 | # Not adding the same effort for the precompiled linux builds, though. Those |
| 268 | # have different versions for CC compiler versions and linux kernels which |
| 269 | # will never adequately match the user's setup, so there is no feasible way |
| 270 | # to detect the "best" version to use. The user will have to manually |
| 271 | # select the right files. (Chances are the distributions are shipping their |
| 272 | # custom version of tbb, anyway, so the problem is probably nonexistent.) |
| 273 | if (WIN32 AND MSVC) |
| 274 | set(COMPILER_PREFIX "vc7.1") |
| 275 | if (MSVC_VERSION EQUAL 1400) |
| 276 | set(COMPILER_PREFIX "vc8") |
| 277 | elseif(MSVC_VERSION EQUAL 1500) |
| 278 | set(COMPILER_PREFIX "vc9") |
| 279 | elseif(MSVC_VERSION EQUAL 1600) |
| 280 | set(COMPILER_PREFIX "vc10") |
| 281 | elseif(MSVC_VERSION EQUAL 1700) |
| 282 | set(COMPILER_PREFIX "vc11") |
| 283 | elseif(MSVC_VERSION EQUAL 1800) |
| 284 | set(COMPILER_PREFIX "vc12") |
| 285 | elseif(MSVC_VERSION GREATER_EQUAL 1900) |
| 286 | set(COMPILER_PREFIX "vc14") |
| 287 | endif () |
| 288 | |
| 289 | # for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path |
| 290 | foreach (dir IN LISTS TBB_PREFIX_PATH) |
| 291 | if (CMAKE_CL_64) |
| 292 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib) |
| 293 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX}) |
| 294 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib) |
| 295 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX}) |
| 296 | else () |
| 297 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib) |
| 298 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX}) |
| 299 | endif () |
| 300 | endforeach () |
| 301 | endif () |
| 302 | |
| 303 | # For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9) |
| 304 | # and above and AppleClang |
| 305 | if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND |
| 306 | NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0) |
| 307 | set (USE_LIBCXX OFF) |
| 308 | cmake_policy(GET CMP0025 POLICY_VAR) |
| 309 | |
| 310 | if (POLICY_VAR STREQUAL "NEW") |
| 311 | if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") |
| 312 | set (USE_LIBCXX ON) |
| 313 | endif () |
| 314 | else () |
| 315 | if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") |
| 316 | set (USE_LIBCXX ON) |
| 317 | endif () |
| 318 | endif () |
| 319 | |
| 320 | if (USE_LIBCXX) |
| 321 | foreach (dir IN LISTS TBB_PREFIX_PATH) |
| 322 | list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib) |
| 323 | endforeach () |
| 324 | endif () |
| 325 | endif () |
| 326 | |
| 327 | # check compiler ABI |
| 328 | if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") |
| 329 | set(COMPILER_PREFIX) |
| 330 | if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8) |
| 331 | list(APPEND COMPILER_PREFIX "gcc4.8") |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 332 | endif() |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 333 | if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7) |
| 334 | list(APPEND COMPILER_PREFIX "gcc4.7") |
| 335 | endif() |
| 336 | if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4) |
| 337 | list(APPEND COMPILER_PREFIX "gcc4.4") |
| 338 | endif() |
| 339 | list(APPEND COMPILER_PREFIX "gcc4.1") |
| 340 | elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 341 | set(COMPILER_PREFIX) |
| 342 | if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess |
| 343 | list(APPEND COMPILER_PREFIX "gcc4.8") |
| 344 | endif() |
| 345 | if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6) |
| 346 | list(APPEND COMPILER_PREFIX "gcc4.7") |
| 347 | endif() |
| 348 | list(APPEND COMPILER_PREFIX "gcc4.4") |
| 349 | else() # Assume compatibility with 4.4 for other compilers |
| 350 | list(APPEND COMPILER_PREFIX "gcc4.4") |
| 351 | endif () |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 352 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 353 | # if platform architecture is explicitly specified |
| 354 | set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM}) |
| 355 | if (TBB_ARCH_PLATFORM) |
| 356 | foreach (dir IN LISTS TBB_PREFIX_PATH) |
| 357 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib) |
| 358 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM}) |
| 359 | endforeach () |
| 360 | endif () |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 361 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 362 | foreach (dir IN LISTS TBB_PREFIX_PATH) |
| 363 | foreach (prefix IN LISTS COMPILER_PREFIX) |
| 364 | if (CMAKE_SIZEOF_VOID_P EQUAL 8) |
| 365 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64) |
| 366 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix}) |
| 367 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib) |
| 368 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib) |
| 369 | else () |
| 370 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32) |
| 371 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix}) |
| 372 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib) |
| 373 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib) |
| 374 | endif () |
| 375 | endforeach() |
| 376 | endforeach () |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 377 | |
Austin Schuh | 1d1e6ea | 2020-12-23 21:56:30 -0800 | [diff] [blame] | 378 | # add general search paths |
| 379 | foreach (dir IN LISTS TBB_PREFIX_PATH) |
| 380 | list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb |
| 381 | ${dir}/Libs) |
| 382 | list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include |
| 383 | ${dir}/include/tbb) |
| 384 | endforeach () |
| 385 | |
| 386 | set(TBB_LIBRARY_NAMES tbb) |
| 387 | get_debug_names(TBB_LIBRARY_NAMES) |
| 388 | |
| 389 | find_path(TBB_INCLUDE_DIR |
| 390 | NAMES tbb/tbb.h |
| 391 | HINTS ${TBB_INC_SEARCH_PATH}) |
| 392 | find_tbb_library_verifying_release_debug_locations(TBB_LIBRARY) |
| 393 | make_library_set(TBB_LIBRARY) |
| 394 | |
| 395 | findpkg_finish(TBB tbb) |
| 396 | |
| 397 | #if we haven't found TBB no point on going any further |
| 398 | if (NOT TBB_FOUND) |
| 399 | return() |
| 400 | endif () |
| 401 | |
| 402 | #============================================================================= |
| 403 | # Look for TBB's malloc package |
| 404 | set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc) |
| 405 | get_debug_names(TBB_MALLOC_LIBRARY_NAMES) |
| 406 | |
| 407 | find_path(TBB_MALLOC_INCLUDE_DIR |
| 408 | NAMES tbb/tbb.h |
| 409 | HINTS ${TBB_INC_SEARCH_PATH}) |
| 410 | find_tbb_library_verifying_release_debug_locations(TBB_MALLOC_LIBRARY) |
| 411 | make_library_set(TBB_MALLOC_LIBRARY) |
| 412 | |
| 413 | findpkg_finish(TBB_MALLOC tbbmalloc) |
| 414 | |
| 415 | #============================================================================= |
| 416 | # Look for TBB's malloc proxy package |
| 417 | set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy) |
| 418 | get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES) |
| 419 | |
| 420 | find_path(TBB_MALLOC_PROXY_INCLUDE_DIR |
| 421 | NAMES tbb/tbbmalloc_proxy.h |
| 422 | HINTS ${TBB_INC_SEARCH_PATH}) |
| 423 | find_tbb_library_verifying_release_debug_locations(TBB_MALLOC_PROXY_LIBRARY) |
| 424 | make_library_set(TBB_MALLOC_PROXY_LIBRARY) |
| 425 | |
| 426 | findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy) |
| 427 | |
| 428 | |
| 429 | #============================================================================= |
| 430 | #parse all the version numbers from tbb |
| 431 | if(NOT TBB_VERSION) |
| 432 | |
| 433 | #only read the start of the file |
| 434 | file(STRINGS |
| 435 | "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h" |
| 436 | TBB_VERSION_CONTENTS |
| 437 | REGEX "VERSION") |
| 438 | |
| 439 | string(REGEX REPLACE |
| 440 | ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1" |
| 441 | TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}") |
| 442 | |
| 443 | string(REGEX REPLACE |
| 444 | ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1" |
| 445 | TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}") |
| 446 | |
| 447 | string(REGEX REPLACE |
| 448 | ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1" |
| 449 | TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") |
| 450 | |
| 451 | string(REGEX REPLACE |
| 452 | ".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1" |
| 453 | TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}") |
Austin Schuh | 70cc955 | 2019-01-21 19:46:48 -0800 | [diff] [blame] | 454 | |
| 455 | endif() |