Skip to content

Commit

Permalink
Merge pull request #876 from akashsharma02/develop
Browse files Browse the repository at this point in the history
Better Error message for TBB handling with versions greater than 2021.1 on OS X
  • Loading branch information
varunagrawal authored Sep 20, 2021
2 parents 3097d6a + 42f2436 commit b4b2f41
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
16 changes: 14 additions & 2 deletions cmake/FindTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ if(NOT TBB_FOUND)

elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
# OS X
set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb")
set(TBB_DEFAULT_SEARCH_DIR "/opt/intel/tbb"
"/usr/local/opt/tbb")

# TODO: Check to see which C++ library is being used by the compiler.
if(NOT ${CMAKE_SYSTEM_VERSION} VERSION_LESS 13.0)
Expand Down Expand Up @@ -181,7 +182,18 @@ if(NOT TBB_FOUND)
##################################

if(TBB_INCLUDE_DIRS)
file(READ "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h" _tbb_version_file)
set(_tbb_version_file_prior_to_tbb_2021_1 "${TBB_INCLUDE_DIRS}/tbb/tbb_stddef.h")
set(_tbb_version_file_after_tbb_2021_1 "${TBB_INCLUDE_DIRS}/oneapi/tbb/version.h")

if (EXISTS "${_tbb_version_file_prior_to_tbb_2021_1}")
file(READ "${_tbb_version_file_prior_to_tbb_2021_1}" _tbb_version_file )
elseif (EXISTS "${_tbb_version_file_after_tbb_2021_1}")
file(READ "${_tbb_version_file_after_tbb_2021_1}" _tbb_version_file )
else()
message(FATAL_ERROR "Found TBB installation: ${TBB_INCLUDE_DIRS} "
"missing version header.")
endif()

string(REGEX REPLACE ".*#define TBB_VERSION_MAJOR ([0-9]+).*" "\\1"
TBB_VERSION_MAJOR "${_tbb_version_file}")
string(REGEX REPLACE ".*#define TBB_VERSION_MINOR ([0-9]+).*" "\\1"
Expand Down
7 changes: 6 additions & 1 deletion cmake/HandleTBB.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ if (GTSAM_WITH_TBB)
# Set up variables if we're using TBB
if(TBB_FOUND)
set(GTSAM_USE_TBB 1) # This will go into config.h

if ((${TBB_VERSION} VERSION_GREATER "2021.1") OR (${TBB_VERSION} VERSION_EQUAL "2021.1"))
message(FATAL_ERROR "TBB version greater than 2021.1 (oneTBB API) is not yet supported. Use an older version instead.")
endif()

if ((${TBB_VERSION_MAJOR} GREATER 2020) OR (${TBB_VERSION_MAJOR} EQUAL 2020))
set(TBB_GREATER_EQUAL_2020 1)
else()
Expand All @@ -24,4 +29,4 @@ if (GTSAM_WITH_TBB)
message(FATAL_ERROR "Timing build mode cannot be used together with TBB. Use a sampling profiler such as Instruments or Intel VTune Amplifier instead.")
endif()

endif()
endif()

0 comments on commit b4b2f41

Please sign in to comment.