FindOpenMP: Add option to control OpenMP runtime with MSVC

The MSVC compiler's `-openmp` flag accepts `:{experimental,llvm}`
values.  Add an option to specify one.

Closes: #25570
This commit is contained in:
Axel Huebl
2024-04-29 19:03:35 -07:00
committed by Brad King
parent 01e138a7b7
commit b07c637e42
4 changed files with 40 additions and 3 deletions

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