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
merge-requests/9509/head
Brad King 2024-05-02 13:34:15 +00:00 committed by Kitware Robot
commit 1d8848c4ce
4 changed files with 40 additions and 3 deletions

View File

@ -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.

View File

@ -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")

View File

@ -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()

View File

@ -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/',