Cmake: Improve finding openmp with clang-cl compiler on windows
When having several clang versions installed cmake would default to the last llvm directory in the registry when finding the openmp libraries. Two problems with that are : 1- The registry entry may not exist 2- Even if it exists it may not point to the right folder for the Current compiler. This PR changes the behaviour to look relative to the clang binary to find the openmp libraries. Pull Request: https://projects.blender.org/blender/blender/pulls/125101
This commit is contained in:
@@ -26,12 +26,15 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
|
||||
# 1) CMake has issues detecting openmp support in clang-cl so we have to provide
|
||||
# the right switches here.
|
||||
# 2) While the /openmp switch *should* work, it currently doesn't as for clang 9.0.0
|
||||
# 3) Using the registry to locate llvmroot doesn't work on some installs. When this happens,
|
||||
# attempt to locate openmp in the lib directory of the parent of the clang-cl binary
|
||||
if(WITH_OPENMP)
|
||||
set(OPENMP_CUSTOM ON)
|
||||
set(OPENMP_FOUND ON)
|
||||
set(OpenMP_C_FLAGS "/clang:-fopenmp")
|
||||
set(OpenMP_CXX_FLAGS "/clang:-fopenmp")
|
||||
get_filename_component(LLVMROOT "[HKEY_LOCAL_MACHINE\\SOFTWARE\\WOW6432Node\\LLVM\\LLVM;]" ABSOLUTE CACHE)
|
||||
get_filename_component(LLVMBIN ${CMAKE_CXX_COMPILER} DIRECTORY)
|
||||
get_filename_component(LLVMROOT ${LLVMBIN} DIRECTORY)
|
||||
set(CLANG_OPENMP_DLL "${LLVMROOT}/bin/libomp.dll")
|
||||
set(CLANG_OPENMP_LIB "${LLVMROOT}/lib/libomp.lib")
|
||||
if(NOT EXISTS "${CLANG_OPENMP_DLL}")
|
||||
|
||||
Reference in New Issue
Block a user