Skip to content

Commit 528f649

Browse files
authored
TBB update version (#20)
* Upadte version * Upadte version 2 * Update version 3
1 parent e61db5d commit 528f649

File tree

3 files changed

+72
-38
lines changed

3 files changed

+72
-38
lines changed

CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ option(USE_TBB OFF)
5252
if( USE_TBB )
5353
if( WIN32 )
5454
include( cmake/TBBGet.cmake )
55-
tbb_get( TBB_ROOT tbb_root RELEASE_TAG "2019_U2" CONFIG_DIR TBB_DIR )
55+
tbb_get( TBB_ROOT tbb_root RELEASE_TAG "v2020.1" CONFIG_DIR TBB_DIR )
5656

5757
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
5858
set(SYSTEM_BIT "intel64")

cmake/FindTBB.cmake

Lines changed: 69 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -68,46 +68,84 @@
6868
# FindTBB helper functions and macros
6969
#
7070

71+
#====================================================
72+
# Fix the library path in case it is a linker script
73+
#====================================================
74+
function(tbb_extract_real_library library real_library)
75+
if(NOT UNIX OR NOT EXISTS ${library})
76+
set(${real_library} "${library}" PARENT_SCOPE)
77+
return()
78+
endif()
79+
80+
#Read in the first 4 bytes and see if they are the ELF magic number
81+
set(_elf_magic "7f454c46")
82+
file(READ ${library} _hex_data OFFSET 0 LIMIT 4 HEX)
83+
if(_hex_data STREQUAL _elf_magic)
84+
#we have opened a elf binary so this is what
85+
#we should link to
86+
set(${real_library} "${library}" PARENT_SCOPE)
87+
return()
88+
endif()
89+
90+
file(READ ${library} _data OFFSET 0 LIMIT 1024)
91+
if("${_data}" MATCHES "INPUT \\(([^(]+)\\)")
92+
#extract out the .so name from REGEX MATCH command
93+
set(_proper_so_name "${CMAKE_MATCH_1}")
94+
95+
#construct path to the real .so which is presumed to be in the same directory
96+
#as the input file
97+
get_filename_component(_so_dir "${library}" DIRECTORY)
98+
set(${real_library} "${_so_dir}/${_proper_so_name}" PARENT_SCOPE)
99+
else()
100+
#unable to determine what this library is so just hope everything works
101+
#and pass it unmodified.
102+
set(${real_library} "${library}" PARENT_SCOPE)
103+
endif()
104+
endfunction()
105+
71106
#===============================================
72107
# Do the final processing for the package find.
73108
#===============================================
74109
macro(findpkg_finish PREFIX TARGET_NAME)
75-
# skip if already processed during this run
76-
if (NOT ${PREFIX}_FOUND)
77-
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
78-
set(${PREFIX}_FOUND TRUE)
79-
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
80-
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
81-
else ()
82-
if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
83-
message(FATAL_ERROR "Required library ${PREFIX} not found.")
84-
endif ()
110+
if (${PREFIX}_INCLUDE_DIR AND ${PREFIX}_LIBRARY)
111+
set(${PREFIX}_FOUND TRUE)
112+
set (${PREFIX}_INCLUDE_DIRS ${${PREFIX}_INCLUDE_DIR})
113+
set (${PREFIX}_LIBRARIES ${${PREFIX}_LIBRARY})
114+
else ()
115+
if (${PREFIX}_FIND_REQUIRED AND NOT ${PREFIX}_FIND_QUIETLY)
116+
message(FATAL_ERROR "Required library ${PREFIX} not found.")
85117
endif ()
118+
endif ()
86119

87-
if (NOT TARGET "TBB::${TARGET_NAME}")
88-
add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED)
120+
if (NOT TARGET "TBB::${TARGET_NAME}")
121+
if (${PREFIX}_LIBRARY_RELEASE)
122+
tbb_extract_real_library(${${PREFIX}_LIBRARY_RELEASE} real_release)
123+
endif ()
124+
if (${PREFIX}_LIBRARY_DEBUG)
125+
tbb_extract_real_library(${${PREFIX}_LIBRARY_DEBUG} real_debug)
126+
endif ()
127+
add_library(TBB::${TARGET_NAME} UNKNOWN IMPORTED)
128+
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
129+
INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}")
130+
if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE)
131+
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
132+
IMPORTED_LOCATION "${real_release}"
133+
IMPORTED_LOCATION_DEBUG "${real_debug}"
134+
IMPORTED_LOCATION_RELEASE "${real_release}")
135+
elseif (${PREFIX}_LIBRARY_RELEASE)
89136
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
90-
INTERFACE_INCLUDE_DIRECTORIES "${${PREFIX}_INCLUDE_DIR}")
91-
if (${PREFIX}_LIBRARY_DEBUG AND ${PREFIX}_LIBRARY_RELEASE)
92-
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
93-
IMPORTED_LOCATION "${${PREFIX}_LIBRARY_RELEASE}"
94-
IMPORTED_LOCATION_DEBUG "${${PREFIX}_LIBRARY_DEBUG}"
95-
IMPORTED_LOCATION_RELEASE "${${PREFIX}_LIBRARY_RELEASE}")
96-
elseif (${PREFIX}_LIBRARY_RELEASE)
97-
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
98-
IMPORTED_LOCATION "${${PREFIX}_LIBRARY_RELEASE}")
99-
elseif (${PREFIX}_LIBRARY_DEBUG)
100-
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
101-
IMPORTED_LOCATION "${${PREFIX}_LIBRARY_DEBUG}")
102-
endif ()
137+
IMPORTED_LOCATION "${real_release}")
138+
elseif (${PREFIX}_LIBRARY_DEBUG)
139+
set_target_properties(TBB::${TARGET_NAME} PROPERTIES
140+
IMPORTED_LOCATION "${real_debug}")
103141
endif ()
104-
105-
#mark the following variables as internal variables
106-
mark_as_advanced(${PREFIX}_INCLUDE_DIR
107-
${PREFIX}_LIBRARY
108-
${PREFIX}_LIBRARY_DEBUG
109-
${PREFIX}_LIBRARY_RELEASE)
110142
endif ()
143+
144+
#mark the following variables as internal variables
145+
mark_as_advanced(${PREFIX}_INCLUDE_DIR
146+
${PREFIX}_LIBRARY
147+
${PREFIX}_LIBRARY_DEBUG
148+
${PREFIX}_LIBRARY_RELEASE)
111149
endmacro()
112150

113151
#===============================================

cmake/TBBGet.cmake

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright (c) 2017-2018 Intel Corporation
1+
# Copyright (c) 2017-2020 Intel Corporation
22
#
33
# Licensed under the Apache License, Version 2.0 (the "License");
44
# you may not use this file except in compliance with the License.
@@ -11,10 +11,6 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14-
#
15-
#
16-
#
17-
#
1814

1915
include(CMakeParseArguments)
2016

@@ -202,7 +198,7 @@ function(_tbb_get_url)
202198
return()
203199
endif()
204200

205-
string(REGEX REPLACE ".*(https.*oss_${tbb_lib_archive_suffix}).*" "\\1" tbb_bin_url "${tbb_release_info}")
201+
string(REGEX REPLACE ".*(https.*${tbb_lib_archive_suffix}).*" "\\1" tbb_bin_url "${tbb_release_info}")
206202

207203
set(${tbb_get_url_URL} ${tbb_bin_url} PARENT_SCOPE)
208204
endif()

0 commit comments

Comments
 (0)