Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRay Molenkamp <github@lazydodo.com>2019-10-07 19:24:13 +0300
committerRay Molenkamp <github@lazydodo.com>2019-10-07 19:24:13 +0300
commitd2e4b13b9c4a9fa61cfcdc26a8d1dd8e5a4ac557 (patch)
tree3066d1cc859d60fa83b7bcb353180751481fa1d5
parentfc9e921495312ace23af11a69e738a8a7adbaeed (diff)
CMake: Add support for building with OpenMP support for clang on windows.
mostly minor c/cxx/linker flags, only tested with clang 9.0.0 Differential Revision: https://developer.blender.org/D5976 Reviewers: brecht, jesterking
-rw-r--r--build_files/cmake/macros.cmake4
-rw-r--r--build_files/cmake/platform/platform_win32.cmake16
-rw-r--r--source/creator/CMakeLists.txt7
3 files changed, 26 insertions, 1 deletions
diff --git a/build_files/cmake/macros.cmake b/build_files/cmake/macros.cmake
index e159dd9e5ee..f642a199915 100644
--- a/build_files/cmake/macros.cmake
+++ b/build_files/cmake/macros.cmake
@@ -1209,7 +1209,9 @@ macro(openmp_delayload
)
if(MSVC)
if(WITH_OPENMP)
- if(MSVC_VERSION EQUAL 1800)
+ if(MSVC_CLANG)
+ set(OPENMP_DLL_NAME "libomp")
+ elseif(MSVC_VERSION EQUAL 1800)
set(OPENMP_DLL_NAME "vcomp120")
else()
set(OPENMP_DLL_NAME "vcomp140")
diff --git a/build_files/cmake/platform/platform_win32.cmake b/build_files/cmake/platform/platform_win32.cmake
index b2277c440fe..7e0fff00a37 100644
--- a/build_files/cmake/platform/platform_win32.cmake
+++ b/build_files/cmake/platform/platform_win32.cmake
@@ -35,6 +35,22 @@ if(CMAKE_C_COMPILER_ID MATCHES "Clang")
else()
message("Unable to detect the Visual Studio redist directory, copying of the runtime dlls will not work, try running from the visual studio developer prompt.")
endif()
+ # 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
+ 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)
+ set(CLANG_OPENMP_DLL "${LLVMROOT}/bin/libomp.dll")
+ set(CLANG_OPENMP_LIB "${LLVMROOT}/lib/libomp.lib")
+ if(NOT EXISTS "${CLANG_OPENMP_DLL}")
+ message(FATAL_ERROR "Clang OpenMP library (${CLANG_OPENMP_DLL}) not found.")
+ endif()
+ set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} \"${CLANG_OPENMP_LIB}\"")
+ endif()
endif()
set_property(GLOBAL PROPERTY USE_FOLDERS ${WINDOWS_USE_VISUAL_STUDIO_PROJECT_FOLDERS})
diff --git a/source/creator/CMakeLists.txt b/source/creator/CMakeLists.txt
index 8fb4d2905f4..52d930143da 100644
--- a/source/creator/CMakeLists.txt
+++ b/source/creator/CMakeLists.txt
@@ -674,6 +674,13 @@ elseif(WIN32)
set(BLENDER_TEXT_FILES_DESTINATION ".")
+ if(WITH_OPENMP AND MSVC_CLANG)
+ install(
+ FILES ${CLANG_OPENMP_DLL}
+ DESTINATION "."
+ )
+ endif()
+
if(WITH_PYTHON)
string(REPLACE "." "" _PYTHON_VERSION_NO_DOTS ${PYTHON_VERSION})