Skip to content

Commit bd4981e

Browse files
authored
[CMake] Add hack to find LLVM's OpenMP with GCC (#984)
This should replace #960. It worked on my Ubuntu for both Clang and GCC. @dbabokin please check that this works for you, too. Fixes #959.
1 parent 8d0da95 commit bd4981e

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

cmake/modules/openmp.cmake

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,19 @@
11
option(USE_OpenMP "Use OpenMP" ON)
22

3+
# We don't want GOMP because its performance sinks for large core count, so we force libomp
4+
# This finds the library path from the system's clang for OpenMP
5+
#
6+
# On Fedora, it's at the same place as others, so we don't need to look elsewhere
7+
# On Ubuntu, it's in /usr/lib/llvm-${version}, so find_package finds GOMP for GCC instead.
8+
execute_process (
9+
COMMAND bash -c "for lib in $(clang -lomp -### 2>&1); do echo $lib | grep -o \"\\/.*llvm.*\\w\"; done"
10+
OUTPUT_VARIABLE LLVM_OMP_PATH
11+
)
12+
# Only if we found an "llvm" path that we need to add
13+
if (LLVM_OMP_PATH)
14+
set(CMAKE_PREFIX_PATH ${LLVM_OMP_PATH})
15+
endif()
16+
317
if(USE_OpenMP)
418
find_package(OpenMP)
519
if(OPENMP_FOUND)

0 commit comments

Comments
 (0)