summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2018-03-07 13:33:18 (GMT)
committerKitware Robot <kwrobot@kitware.com>2018-03-07 13:33:33 (GMT)
commit9ceafdfd4deec57c3a7f8650b2466da1d0aa0d3f (patch)
tree66703620786849c4b72de2be2165524746a4bb19
parent29b41babdb78b5e305ed9fc6b84dd69c1795dc69 (diff)
parente3cd7c1e014aa48b72d414104b9c1bd6bc03fd64 (diff)
downloadCMake-9ceafdfd4deec57c3a7f8650b2466da1d0aa0d3f.zip
CMake-9ceafdfd4deec57c3a7f8650b2466da1d0aa0d3f.tar.gz
CMake-9ceafdfd4deec57c3a7f8650b2466da1d0aa0d3f.tar.bz2
Merge topic 'FindOpenMP-AppleClang'
e3cd7c1e01 FindOpenMP: Add support for AppleClang compiler b4c539e651 FindOpenMP: Verify in test source that OMP library is linked 7dd8c7a680 FindOpenMP: Improve inclusion of helper modules Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !1812
-rw-r--r--Modules/FindOpenMP.cmake30
1 files changed, 27 insertions, 3 deletions
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index ced092e..e252ba5 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -85,6 +85,7 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
set(OMP_FLAG_GNU "-fopenmp")
set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5" "-fopenmp")
+ set(OMP_FLAG_AppleClang "-Xclang -fopenmp")
set(OMP_FLAG_HP "+Oopenmp")
if(WIN32)
set(OMP_FLAG_Intel "-Qopenmp")
@@ -125,6 +126,7 @@ set(OpenMP_C_CXX_TEST_SOURCE
#include <omp.h>
int main() {
#ifdef _OPENMP
+ int n = omp_get_max_threads();
return 0;
#else
breaks_on_purpose
@@ -163,7 +165,7 @@ function(_OPENMP_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_F
set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE)
endfunction()
-include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseImplicitLinkInfo.cmake)
function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
_OPENMP_FLAG_CANDIDATES("${LANG}")
@@ -255,6 +257,28 @@ function(_OPENMP_GET_FLAGS LANG FLAG_MODE OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
endif()
endif()
break()
+ elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "AppleClang"
+ AND CMAKE_${LANG}_COMPILER_VERSION VERSION_GREATER_EQUAL "7.0")
+
+ # Check for separate OpenMP library on AppleClang 7+
+ find_library(OpenMP_libomp_LIBRARY
+ NAMES omp gomp iomp5
+ 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()
endif()
set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE)
set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE)
@@ -423,6 +447,8 @@ endif()
unset(_OpenMP_MIN_VERSION)
+include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+
foreach(LANG IN LISTS OpenMP_FINDLIST)
if(CMAKE_${LANG}_COMPILER_LOADED)
if (NOT OpenMP_${LANG}_SPEC_DATE AND OpenMP_${LANG}_FLAGS)
@@ -432,8 +458,6 @@ foreach(LANG IN LISTS OpenMP_FINDLIST)
_OPENMP_SET_VERSION_BY_SPEC_DATE("${LANG}")
endif()
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-
set(OpenMP_${LANG}_FIND_QUIETLY ${OpenMP_FIND_QUIETLY})
set(OpenMP_${LANG}_FIND_REQUIRED ${OpenMP_FIND_REQUIRED})
set(OpenMP_${LANG}_FIND_VERSION ${OpenMP_FIND_VERSION})