mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-05 21:31:08 -06:00
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:
5
Help/release/dev/FindOpenMP-runtime-msvc.rst
Normal file
5
Help/release/dev/FindOpenMP-runtime-msvc.rst
Normal 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.
|
||||||
@@ -16,8 +16,22 @@ flag to support OpenMP.
|
|||||||
.. versionadded:: 3.5
|
.. versionadded:: 3.5
|
||||||
Clang support.
|
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
|
.. versionadded:: 3.10
|
||||||
The module exposes the components ``C``, ``CXX``, and ``Fortran``.
|
The module exposes the components ``C``, ``CXX``, and ``Fortran``.
|
||||||
@@ -121,7 +135,11 @@ function(_OPENMP_FLAG_CANDIDATES LANG)
|
|||||||
else()
|
else()
|
||||||
set(OMP_FLAG_IntelLLVM "-fiopenmp")
|
set(OMP_FLAG_IntelLLVM "-fiopenmp")
|
||||||
endif()
|
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_PathScale "-openmp")
|
||||||
set(OMP_FLAG_NAG "-openmp")
|
set(OMP_FLAG_NAG "-openmp")
|
||||||
set(OMP_FLAG_Absoft "-openmp")
|
set(OMP_FLAG_Absoft "-openmp")
|
||||||
|
|||||||
@@ -26,8 +26,21 @@ foreach(c C CXX Fortran)
|
|||||||
endif()
|
endif()
|
||||||
endforeach()
|
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)
|
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)
|
foreach(c C CXX Fortran)
|
||||||
if(NOT "${OpenMP_TEST_${c}}")
|
if(NOT "${OpenMP_TEST_${c}}")
|
||||||
continue()
|
continue()
|
||||||
|
|||||||
@@ -98,6 +98,7 @@ linkcheck_allowed_redirects = {
|
|||||||
r'https://cdash\.org': r'https://www\.cdash\.org/',
|
r'https://cdash\.org': r'https://www\.cdash\.org/',
|
||||||
r'https://cmake.org/get-involved/': r'https://cmake.org/documentation/',
|
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://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://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://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/',
|
r'https://www\.sphinx-doc\.org': r'https://www\.sphinx-doc\.org/en/master/',
|
||||||
|
|||||||
Reference in New Issue
Block a user