diff options
author | Brad King <brad.king@kitware.com> | 2024-05-02 13:34:15 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2024-05-02 13:34:29 (GMT) |
commit | 1d8848c4ce2e1b030f7d6129aa741d0db5a4b3cf (patch) | |
tree | 85c8e4261a793191f848cbae2e3cbc1de10e5de4 | |
parent | 8382fdd2e9b71ceec82a4893834e73b56ecd9aba (diff) | |
parent | b07c637e42bb20410eebbfba693145b672451aaa (diff) | |
download | CMake-1d8848c4ce2e1b030f7d6129aa741d0db5a4b3cf.zip CMake-1d8848c4ce2e1b030f7d6129aa741d0db5a4b3cf.tar.gz CMake-1d8848c4ce2e1b030f7d6129aa741d0db5a4b3cf.tar.bz2 |
Merge topic 'FindOpenMP-runtime-msvc'
b07c637e42 FindOpenMP: Add option to control OpenMP runtime with MSVC
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !9475
-rw-r--r-- | Help/release/dev/FindOpenMP-runtime-msvc.rst | 5 | ||||
-rw-r--r-- | Modules/FindOpenMP.cmake | 24 | ||||
-rw-r--r-- | Tests/FindOpenMP/Test/CMakeLists.txt | 13 | ||||
-rw-r--r-- | Utilities/Sphinx/conf.py.in | 1 |
4 files changed, 40 insertions, 3 deletions
diff --git a/Help/release/dev/FindOpenMP-runtime-msvc.rst b/Help/release/dev/FindOpenMP-runtime-msvc.rst new file mode 100644 index 0000000..76df237 --- /dev/null +++ b/Help/release/dev/FindOpenMP-runtime-msvc.rst @@ -0,0 +1,5 @@ +FindOpenMP-runtime-msvc +----------------------- + +* The :module:`FindOpenMP` module gained a ``OpenMP_RUNTIME_MSVC`` + option to control the OpenMP runtime used with MSVC. diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 077a239..f88e43c 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -16,8 +16,22 @@ flag to support OpenMP. .. versionadded:: 3.5 Clang support. -Variables -^^^^^^^^^ +Input Variables +^^^^^^^^^^^^^^^ + +The following variables may be set to influence this module's behavior: + +``OpenMP_RUNTIME_MSVC`` + .. versionadded:: 3.30 + + Specify the `OpenMP Runtime <msvc-openmp_>`_ when compiling with MSVC. + If set to a non-empty value, such as ``experimental`` or ``llvm``, it + will be passed as the value of the ``-openmp:`` flag. + +.. _`msvc-openmp`: https://learn.microsoft.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support + +Result Variables +^^^^^^^^^^^^^^^^ .. versionadded:: 3.10 The module exposes the components ``C``, ``CXX``, and ``Fortran``. @@ -121,7 +135,11 @@ function(_OPENMP_FLAG_CANDIDATES LANG) else() set(OMP_FLAG_IntelLLVM "-fiopenmp") endif() - set(OMP_FLAG_MSVC "-openmp") + if(OpenMP_RUNTIME_MSVC) + set(OMP_FLAG_MSVC "-openmp:${OpenMP_RUNTIME_MSVC}") + else() + set(OMP_FLAG_MSVC "-openmp") + endif() set(OMP_FLAG_PathScale "-openmp") set(OMP_FLAG_NAG "-openmp") set(OMP_FLAG_Absoft "-openmp") diff --git a/Tests/FindOpenMP/Test/CMakeLists.txt b/Tests/FindOpenMP/Test/CMakeLists.txt index ebdb6b8..7ead835 100644 --- a/Tests/FindOpenMP/Test/CMakeLists.txt +++ b/Tests/FindOpenMP/Test/CMakeLists.txt @@ -26,8 +26,21 @@ foreach(c C CXX Fortran) endif() endforeach() +if(CMAKE_C_COMPILER_ID STREQUAL "MSVC" + AND CMAKE_C_COMPILER_VERSION VERSION_GREATER_EQUAL 19.30 + AND NOT CMAKE_C_COMPILER_ARCHITECTURE_ID STREQUAL "ARM64") + set(test_msvc_runtime 1) + set(OpenMP_RUNTIME_MSVC "llvm") +endif() + find_package(OpenMP REQUIRED) +if(test_msvc_runtime) + if(NOT OpenMP_C_FLAGS STREQUAL "-openmp:llvm") + message(FATAL_ERROR "OpenMP_RUNTIME_MSVC='${OpenMP_RUNTIME_MSVC}' not honored: '${OpenMP_C_FLAGS}'") + endif() +endif() + foreach(c C CXX Fortran) if(NOT "${OpenMP_TEST_${c}}") continue() diff --git a/Utilities/Sphinx/conf.py.in b/Utilities/Sphinx/conf.py.in index 20e1340..09a7d5a 100644 --- a/Utilities/Sphinx/conf.py.in +++ b/Utilities/Sphinx/conf.py.in @@ -98,6 +98,7 @@ linkcheck_allowed_redirects = { r'https://cdash\.org': r'https://www\.cdash\.org/', r'https://cmake.org/get-involved/': r'https://cmake.org/documentation/', r'https://docs\.nvidia\.com/cuda/': r'https://docs\.nvidia\.com/cuda/index\.html', + r'https://learn\.microsoft\.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support': r'https://learn\.microsoft\.com/en-us/cpp/build/reference/openmp-enable-openmp-2-0-support\?.*', r'https://learn\.microsoft\.com/en-us/cpp/c-language/parsing-c-command-line-arguments': r'https://learn\.microsoft\.com/en-us/cpp/c-language/parsing-c-command-line-arguments\?.*', r'https://openjdk\.java\.net/jeps/313': r'https://openjdk\.org:443/jeps/313', r'https://www\.sphinx-doc\.org': r'https://www\.sphinx-doc\.org/en/master/', |