FindTBB.cmake 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468
  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
  7. #
  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
  13. #
  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.
  20. #
  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
  25. #
  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. # =========================================================================*/
  90. #=============================================================================
  91. # FindTBB helper functions and macros
  92. #
  93. #====================================================
  94. # Fix the library path in case it is a linker script
  95. #====================================================
  96. function(tbb_extract_real_library library real_library)
  97. if(NOT UNIX OR NOT EXISTS ${library})
  98. set(${real_library} "${library}" PARENT_SCOPE)
  99. return()
  100. endif()
  101. #Read in the first 4 bytes and see if they are the ELF magic number
  102. set(_elf_magic "7f454c46")
  103. file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX)
  104. if(_hex_data STREQUAL _elf_magic)
  105. #we have opened a elf binary so this is what
  106. #we should link to
  107. set(${real_library} "${library}" PARENT_SCOPE)
  108. return()
  109. endif()
  110. file(READ ${library} _data OFFSET 0 LIMIT 1024)
  111. if("${_data}" MATCHES "INPUT \\(([^(]+)\\)")
  112. #extract out the .so name from REGEX MATCH command
  113. set(_proper_so_name "${CMAKE_MATCH_1}")
  114. #construct path to the real .so which is presumed to be in the same directory
  115. #as the input file
  116. get_filename_component(_so_dir "${library}" DIRECTORY)
  117. set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE)
  118. else()
  119. #unable to determine what this library is so just hope everything works
  120. #and pass it unmodified.
  121. set(${real_library} "${library}" PARENT_SCOPE)
  122. endif()
  123. endfunction()
  124. #===============================================
  125. # Do the final processing for the package find.
  126. #===============================================
  127. macro(findpkg_finish PREFIX TARGET_NAME)
  128. if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
  129. set(${PREFIX}_FOUND TRUE)
  130. set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
  131. set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
  132. else ()
  133. if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
  134. message(FATAL_ERROR "Required library ${PREFIX} not found.")
  135. endif ()
  136. endif ()
  137. if (NOT TARGET "TBB::${TARGET_NAME}")
  138. if (${PREFIX}_LIBRARY_RELEASE)
  139. tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release)
  140. endif ()
  141. if (${PREFIX}_LIBRARY_DEBUG)
  142. tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug)
  143. endif ()
  144. add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED)
  145. set_target_properties(TBB::${TARGET_NAME} PROPERTIES
  146. INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}")
  147. if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE)
  148. set_target_properties(TBB::${TARGET_NAME} PROPERTIES
  149. IMPORTED_LOCATION "${real_release}"
  150. IMPORTED_LOCATION_DEBUG "${real_debug}"
  151. IMPORTED_LOCATION_RELEASE "${real_release}")
  152. elseif (${PREFIX}_LIBRARY_RELEASE)
  153. set_target_properties(TBB::${TARGET_NAME} PROPERTIES
  154. IMPORTED_LOCATION "${real_release}")
  155. elseif (${PREFIX}_LIBRARY_DEBUG)
  156. set_target_properties(TBB::${TARGET_NAME} PROPERTIES
  157. IMPORTED_LOCATION "${real_debug}")
  158. endif ()
  159. endif ()
  160. #mark the following variables as internal variables
  161. mark_as_advanced(${PREFIX}_INCLUDE_DIR
  162. ${PREFIX}_LIBRARY
  163. ${PREFIX}_LIBRARY_DEBUG
  164. ${PREFIX}_LIBRARY_RELEASE)
  165. endmacro()
  166. #===============================================
  167. # Generate debug names from given release names
  168. #===============================================
  169. macro(get_debug_names PREFIX)
  170. foreach(i ${${PREFIX}})
  171. set(${PREFIX}_DEBUG ${${PREFIX}_DEBUG} ${i}d ${i}D ${i}_d ${i}_D ${i}_debug ${i})
  172. endforeach()
  173. endmacro()
  174. #===============================================
  175. # See if we have env vars to help us find tbb
  176. #===============================================
  177. macro(getenv_path VAR)
  178. set(ENV_${VAR} $ENV{${VAR}})
  179. # replace won't work if var is blank
  180. if (ENV_${VAR})
  181. string( REGEX REPLACE "\\\\" "/" ENV_${VAR} ${ENV_${VAR}} )
  182. endif ()
  183. endmacro()
  184. #===============================================
  185. # Couple a set of release AND debug libraries
  186. #===============================================
  187. macro(make_library_set PREFIX)
  188. if (${PREFIX}_RELEASE AND ${PREFIX}_DEBUG)
  189. set(${PREFIX} optimized ${${PREFIX}_RELEASE} debug ${${PREFIX}_DEBUG})
  190. elseif (${PREFIX}_RELEASE)
  191. set(${PREFIX} ${${PREFIX}_RELEASE})
  192. elseif (${PREFIX}_DEBUG)
  193. set(${PREFIX} ${${PREFIX}_DEBUG})
  194. endif ()
  195. endmacro()
  196. #===============================================
  197. # Ensure that the release & debug libraries found are from the same installation.
  198. #===============================================
  199. macro(find_tbb_library_verifying_release_debug_locations PREFIX)
  200. find_library(${PREFIX}_RELEASE
  201. NAMES ${${PREFIX}_NAMES}
  202. HINTS ${TBB_LIB_SEARCH_PATH})
  203. if (${PREFIX}_RELEASE)
  204. # To avoid finding a mismatched set of release & debug libraries from
  205. # different installations if the first found does not have debug libraries
  206. # by forcing the search for debug to only occur within the detected release
  207. # library directory (if found). Although this would break detection if the
  208. # release & debug libraries were shipped in different directories, this is
  209. # not the case in the official TBB releases for any platform.
  210. get_filename_component(
  211. FOUND_RELEASE_LIB_DIR "${${PREFIX}_RELEASE}" DIRECTORY)
  212. find_library(${PREFIX}_DEBUG
  213. NAMES ${${PREFIX}_NAMES_DEBUG}
  214. HINTS ${FOUND_RELEASE_LIB_DIR}
  215. NO_DEFAULT_PATH)
  216. else()
  217. find_library(${PREFIX}_DEBUG
  218. NAMES ${${PREFIX}_NAMES_DEBUG}
  219. HINTS ${TBB_LIB_SEARCH_PATH})
  220. endif()
  221. endmacro()
  222. #=============================================================================
  223. # Now to actually find TBB
  224. #
  225. # Get path, convert backslashes as ${ENV_${var}}
  226. getenv_path(TBB_ROOT)
  227. # initialize search paths
  228. set(TBB_PREFIX_PATH ${TBB_ROOT} ${ENV_TBB_ROOT})
  229. set(TBB_INC_SEARCH_PATH "")
  230. set(TBB_LIB_SEARCH_PATH "")
  231. # If user built from sources
  232. set(TBB_BUILD_PREFIX $ENV{TBB_BUILD_PREFIX})
  233. if (TBB_BUILD_PREFIX AND ENV_TBB_ROOT)
  234. getenv_path(TBB_BUILD_DIR)
  235. if (NOT ENV_TBB_BUILD_DIR)
  236. set(ENV_TBB_BUILD_DIR ${ENV_TBB_ROOT}/build)
  237. endif ()
  238. # include directory under ${ENV_TBB_ROOT}/include
  239. list(APPEND TBB_LIB_SEARCH_PATH
  240. ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_release
  241. ${ENV_TBB_BUILD_DIR}/${TBB_BUILD_PREFIX}_debug)
  242. endif ()
  243. # For Windows, let's assume that the user might be using the precompiled
  244. # TBB packages from the main website. These use a rather awkward directory
  245. # structure (at least for automatically finding the right files) depending
  246. # on platform and compiler, but we'll do our best to accommodate it.
  247. # Not adding the same effort for the precompiled linux builds, though. Those
  248. # have different versions for CC compiler versions and linux kernels which
  249. # will never adequately match the user's setup, so there is no feasible way
  250. # to detect the "best" version to use. The user will have to manually
  251. # select the right files. (Chances are the distributions are shipping their
  252. # custom version of tbb, anyway, so the problem is probably nonexistent.)
  253. if (WIN32 AND MSVC)
  254. set(COMPILER_PREFIX "vc7.1")
  255. if (MSVC_VERSION EQUAL 1400)
  256. set(COMPILER_PREFIX "vc8")
  257. elseif(MSVC_VERSION EQUAL 1500)
  258. set(COMPILER_PREFIX "vc9")
  259. elseif(MSVC_VERSION EQUAL 1600)
  260. set(COMPILER_PREFIX "vc10")
  261. elseif(MSVC_VERSION EQUAL 1700)
  262. set(COMPILER_PREFIX "vc11")
  263. elseif(MSVC_VERSION EQUAL 1800)
  264. set(COMPILER_PREFIX "vc12")
  265. elseif(MSVC_VERSION GREATER_EQUAL 1900)
  266. set(COMPILER_PREFIX "vc14")
  267. endif ()
  268. # for each prefix path, add ia32/64\${COMPILER_PREFIX}\lib to the lib search path
  269. foreach (dir IN LISTS TBB_PREFIX_PATH)
  270. if (CMAKE_CL_64)
  271. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia64/${COMPILER_PREFIX}/lib)
  272. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia64/${COMPILER_PREFIX})
  273. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${COMPILER_PREFIX}/lib)
  274. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${COMPILER_PREFIX})
  275. else ()
  276. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${COMPILER_PREFIX}/lib)
  277. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${COMPILER_PREFIX})
  278. endif ()
  279. endforeach ()
  280. endif ()
  281. # For OS X binary distribution, choose libc++ based libraries for Mavericks (10.9)
  282. # and above and AppleClang
  283. if (CMAKE_SYSTEM_NAME STREQUAL "Darwin" AND
  284. NOT CMAKE_SYSTEM_VERSION VERSION_LESS 13.0)
  285. set (USE_LIBCXX OFF)
  286. cmake_policy(GET CMP0025 POLICY_VAR)
  287. if (POLICY_VAR STREQUAL "NEW")
  288. if (CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
  289. set (USE_LIBCXX ON)
  290. endif ()
  291. else ()
  292. if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
  293. set (USE_LIBCXX ON)
  294. endif ()
  295. endif ()
  296. if (USE_LIBCXX)
  297. foreach (dir IN LISTS TBB_PREFIX_PATH)
  298. list (APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/libc++ ${dir}/libc++/lib)
  299. endforeach ()
  300. endif ()
  301. endif ()
  302. # check compiler ABI
  303. if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
  304. set(COMPILER_PREFIX)
  305. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.8)
  306. list(APPEND COMPILER_PREFIX "gcc4.8")
  307. endif()
  308. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.7)
  309. list(APPEND COMPILER_PREFIX "gcc4.7")
  310. endif()
  311. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.4)
  312. list(APPEND COMPILER_PREFIX "gcc4.4")
  313. endif()
  314. list(APPEND COMPILER_PREFIX "gcc4.1")
  315. elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
  316. set(COMPILER_PREFIX)
  317. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.0) # Complete guess
  318. list(APPEND COMPILER_PREFIX "gcc4.8")
  319. endif()
  320. if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 3.6)
  321. list(APPEND COMPILER_PREFIX "gcc4.7")
  322. endif()
  323. list(APPEND COMPILER_PREFIX "gcc4.4")
  324. else() # Assume compatibility with 4.4 for other compilers
  325. list(APPEND COMPILER_PREFIX "gcc4.4")
  326. endif ()
  327. # if platform architecture is explicitly specified
  328. set(TBB_ARCH_PLATFORM $ENV{TBB_ARCH_PLATFORM})
  329. if (TBB_ARCH_PLATFORM)
  330. foreach (dir IN LISTS TBB_PREFIX_PATH)
  331. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/${TBB_ARCH_PLATFORM}/lib)
  332. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/${TBB_ARCH_PLATFORM})
  333. endforeach ()
  334. endif ()
  335. foreach (dir IN LISTS TBB_PREFIX_PATH)
  336. foreach (prefix IN LISTS COMPILER_PREFIX)
  337. if (CMAKE_SIZEOF_VOID_P EQUAL 8)
  338. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64)
  339. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/intel64/${prefix})
  340. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/lib)
  341. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/intel64/${prefix}/lib)
  342. else ()
  343. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32)
  344. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib/ia32/${prefix})
  345. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/lib)
  346. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/ia32/${prefix}/lib)
  347. endif ()
  348. endforeach()
  349. endforeach ()
  350. # add general search paths
  351. foreach (dir IN LISTS TBB_PREFIX_PATH)
  352. list(APPEND TBB_LIB_SEARCH_PATH ${dir}/lib ${dir}/Lib ${dir}/lib/tbb
  353. ${dir}/Libs)
  354. list(APPEND TBB_INC_SEARCH_PATH ${dir}/include ${dir}/Include
  355. ${dir}/include/tbb)
  356. endforeach ()
  357. set(TBB_LIBRARY_NAMES tbb)
  358. get_debug_names(TBB_LIBRARY_NAMES)
  359. find_path(TBB_INCLUDE_DIR
  360. NAMES tbb/tbb.h
  361. HINTS ${TBB_INC_SEARCH_PATH})
  362. find_tbb_library_verifying_release_debug_locations(TBB_LIBRARY)
  363. make_library_set(TBB_LIBRARY)
  364. findpkg_finish(TBB tbb)
  365. #if we haven't found TBB no point on going any further
  366. if (NOT TBB_FOUND)
  367. return()
  368. endif ()
  369. #=============================================================================
  370. # Look for TBB's malloc package
  371. set(TBB_MALLOC_LIBRARY_NAMES tbbmalloc)
  372. get_debug_names(TBB_MALLOC_LIBRARY_NAMES)
  373. find_path(TBB_MALLOC_INCLUDE_DIR
  374. NAMES tbb/tbb.h
  375. HINTS ${TBB_INC_SEARCH_PATH})
  376. find_tbb_library_verifying_release_debug_locations(TBB_MALLOC_LIBRARY)
  377. make_library_set(TBB_MALLOC_LIBRARY)
  378. findpkg_finish(TBB_MALLOC tbbmalloc)
  379. #=============================================================================
  380. # Look for TBB's malloc proxy package
  381. set(TBB_MALLOC_PROXY_LIBRARY_NAMES tbbmalloc_proxy)
  382. get_debug_names(TBB_MALLOC_PROXY_LIBRARY_NAMES)
  383. find_path(TBB_MALLOC_PROXY_INCLUDE_DIR
  384. NAMES tbb/tbbmalloc_proxy.h
  385. HINTS ${TBB_INC_SEARCH_PATH})
  386. find_tbb_library_verifying_release_debug_locations(TBB_MALLOC_PROXY_LIBRARY)
  387. make_library_set(TBB_MALLOC_PROXY_LIBRARY)
  388. findpkg_finish(TBB_MALLOC_PROXY tbbmalloc_proxy)
  389. #=============================================================================
  390. #parse all the version numbers from tbb
  391. if(NOT TBB_VERSION)
  392. set(TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1
  393. "${TBB_INCLUDE_DIR}/tbb/tbb_stddef.h")
  394. set(TBB_VERSION_FILE_AFTER_TBB_2021_1
  395. "${TBB_INCLUDE_DIR}/oneapi/tbb/version.h")
  396. if (EXISTS "${TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1}")
  397. set(TBB_VERSION_FILE "${TBB_VERSION_FILE_PRIOR_TO_TBB_2021_1}")
  398. elseif (EXISTS "${TBB_VERSION_FILE_AFTER_TBB_2021_1}")
  399. set(TBB_VERSION_FILE "${TBB_VERSION_FILE_AFTER_TBB_2021_1}")
  400. else()
  401. message(FATAL_ERROR "Found TBB installation: ${TBB_INCLUDE_DIR} "
  402. "missing version header.")
  403. endif()
  404. #only read the start of the file
  405. file(STRINGS
  406. "${TBB_VERSION_FILE}"
  407. TBB_VERSION_CONTENTS
  408. REGEX "VERSION")
  409. string(REGEX REPLACE
  410. ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
  411. TBB_VERSION_MAJOR "${TBB_VERSION_CONTENTS}")
  412. string(REGEX REPLACE
  413. ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
  414. TBB_VERSION_MINOR "${TBB_VERSION_CONTENTS}")
  415. string(REGEX REPLACE
  416. ".*#define TBB_INTERFACE_VERSION ([0-9]+).*" "\\1"
  417. TBB_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
  418. string(REGEX REPLACE
  419. ".*#define TBB_COMPATIBLE_INTERFACE_VERSION ([0-9]+).*" "\\1"
  420. TBB_COMPATIBLE_INTERFACE_VERSION "${TBB_VERSION_CONTENTS}")
  421. endif()