diff options
author | Brad King <brad.king@kitware.com> | 2020-02-11 13:22:40 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-02-11 13:22:49 (GMT) |
commit | 00cd7269e10b0a6f0205898dc19e7c93864f5892 (patch) | |
tree | 742d7e4ceb60565c168c0d7ee10b9c779a8d1149 /Modules | |
parent | bdd4fb32adebaa2fc47ebd281d441203d8ef4baa (diff) | |
parent | ceb5ee4a7bda3f61167124b22242504964437e06 (diff) | |
download | CMake-00cd7269e10b0a6f0205898dc19e7c93864f5892.zip CMake-00cd7269e10b0a6f0205898dc19e7c93864f5892.tar.gz CMake-00cd7269e10b0a6f0205898dc19e7c93864f5892.tar.bz2 |
Merge topic 'FindOpenMP-clang-windows' into release-3.17
ceb5ee4a7b FindOpenMP: Add support for Clang on Windows
2dbff623f9 FindOpenMP: Save flags/libs in cache entries each time they are detected
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !4327
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/FindOpenMP.cmake | 32 |
1 files changed, 25 insertions, 7 deletions
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 26fed41..a4b1e1e 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -96,7 +96,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG) unset(OpenMP_FLAG_CANDIDATES) set(OMP_FLAG_GNU "-fopenmp") - set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp") + set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp" "-Xclang -fopenmp") set(OMP_FLAG_AppleClang "-Xclang -fopenmp") set(OMP_FLAG_HP "+Oopenmp") if(WIN32) @@ -299,6 +299,25 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR) break() endif() endif() + elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "Clang" AND WIN32) + # Check for separate OpenMP library for Clang on Windows + find_library(OpenMP_libomp_LIBRARY + NAMES libomp libgomp libiomp5 + HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES} + ) + mark_as_advanced(OpenMP_libomp_LIBRARY) + if(OpenMP_libomp_LIBRARY) + try_compile( OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG} ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC} + CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}" + LINK_LIBRARIES ${CMAKE_${LANG}_VERBOSE_FLAG} ${OpenMP_libomp_LIBRARY} + OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT + ) + if(OpenMP_COMPILE_RESULT_${FLAG_MODE}_${OPENMP_PLAIN_FLAG}) + set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE) + set("${OPENMP_LIB_NAMES_VAR}" "libomp" PARENT_SCOPE) + break() + endif() + endif() else() file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log "Detecting ${LANG} OpenMP failed with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n") @@ -425,13 +444,12 @@ foreach(LANG IN ITEMS C CXX) if(NOT DEFINED OpenMP_${LANG}_FLAGS OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND" OR NOT DEFINED OpenMP_${LANG}_LIB_NAMES OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND") _OPENMP_GET_FLAGS("${LANG}" "${LANG}" OpenMP_${LANG}_FLAGS_WORK OpenMP_${LANG}_LIB_NAMES_WORK) + set(OpenMP_${LANG}_FLAGS "${OpenMP_${LANG}_FLAGS_WORK}" + CACHE STRING "${LANG} compiler flags for OpenMP parallelization" FORCE) + set(OpenMP_${LANG}_LIB_NAMES "${OpenMP_${LANG}_LIB_NAMES_WORK}" + CACHE STRING "${LANG} compiler libraries for OpenMP parallelization" FORCE) + mark_as_advanced(OpenMP_${LANG}_FLAGS OpenMP_${LANG}_LIB_NAMES) endif() - - set(OpenMP_${LANG}_FLAGS "${OpenMP_${LANG}_FLAGS_WORK}" - CACHE STRING "${LANG} compiler flags for OpenMP parallelization") - set(OpenMP_${LANG}_LIB_NAMES "${OpenMP_${LANG}_LIB_NAMES_WORK}" - CACHE STRING "${LANG} compiler libraries for OpenMP parallelization") - mark_as_advanced(OpenMP_${LANG}_FLAGS OpenMP_${LANG}_LIB_NAMES) endif() endforeach() |