File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -58,6 +58,18 @@ endif()
5858# libstdc++. Without it the parallel STL example still builds and covers
5959# seq/unseq; par policies are compiled in only when TBB is present.
6060find_package (TBB QUIET )
61+ if (NOT TBB_FOUND)
62+ # Fallback probe: conda-distributed CMake does not search the Debian
63+ # multiarch cmake-config directory where apt installs TBBConfig.cmake.
64+ find_file (HPC_TBB_CONFIG_FILE TBBConfig.cmake PATHS
65+ /usr/lib/x86_64-linux-gnu/cmake/TBB
66+ /usr/lib64/cmake/TBB
67+ /usr/lib/cmake/TBB )
68+ if (HPC_TBB_CONFIG_FILE)
69+ get_filename_component (TBB_DIR "${HPC_TBB_CONFIG_FILE} " DIRECTORY )
70+ find_package (TBB QUIET )
71+ endif ()
72+ endif ()
6173if (TBB_FOUND)
6274 message (STATUS "TBB found: parallel STL example includes par/par_unseq" )
6375endif ()
Original file line number Diff line number Diff line change @@ -30,10 +30,30 @@ hpc_add_example(
3030# Parallel STL execution policies. seq/unseq always build; par/par_unseq
3131# require Intel TBB (GCC libstdc++ implements them on top of it).
3232if (TBB_FOUND)
33+ # TBB headers reach the targets through a shim directory, mirroring the
34+ # numa pattern: TBB::tbb's /usr/include is silently dropped by CMake on
35+ # sysroot toolchains (conda) and would shadow the toolchain's own
36+ # headers if forced. Symlinking only the tbb/ and oneapi/ subtrees keeps
37+ # the rest of the include resolution untouched.
38+ get_target_property (_hpc_tbb_includes TBB::tbb INTERFACE_INCLUDE_DIRECTORIES )
39+ set (_hpc_tbb_shim "${CMAKE_BINARY_DIR } /tbb-headers" )
40+ file (MAKE_DIRECTORY "${_hpc_tbb_shim} " )
41+ foreach (_hpc_tbb_inc ${_hpc_tbb_includes} )
42+ foreach (_hpc_tbb_sub tbb oneapi)
43+ if (EXISTS "${_hpc_tbb_inc} /${_hpc_tbb_sub} "
44+ AND NOT EXISTS "${_hpc_tbb_shim} /${_hpc_tbb_sub} " )
45+ execute_process (COMMAND ${CMAKE_COMMAND } -E create_symlink
46+ "${_hpc_tbb_inc} /${_hpc_tbb_sub} "
47+ "${_hpc_tbb_shim} /${_hpc_tbb_sub} " )
48+ endif ()
49+ endforeach ()
50+ endforeach ()
51+
3352 hpc_add_example (
3453 NAME parallel_stl
3554 SOURCES src/parallel_stl.cpp
3655 BENCHMARK_SOURCES bench/parallel_stl_bench.cpp
56+ INCLUDE_DIRS ${_hpc_tbb_shim}
3757 LIBRARIES TBB::tbb
3858 )
3959 target_compile_definitions (parallel_stl PRIVATE HPC_HAS_TBB )
You can’t perform that action at this time.
0 commit comments