FindOpenMP¶
Finds Open Multi-Processing (OpenMP) support in a compiler:
find_package(OpenMP [<version>] [COMPONENTS <langs>...] [...])
If the compiler supports OpenMP, the flags required to compile with OpenMP support are returned in variables for the different languages. The variables may be empty if the compiler does not need a special flag to support OpenMP.
在 3.5 版被加入: Clang support.
Components¶
This module supports components that can be specified using the standard syntax:
find_package(OpenMP [COMPONENTS <langs>...])
Each of these components controls the various languages to search OpenMP support for. The following components are exposed:
C在 3.10 版被加入.
CXX在 3.10 版被加入.
Fortran在 3.10 版被加入.
CUDA在 3.31 版被加入.
The
CUDAlanguage component is supported when using a CUDA compiler that supports OpenMP on the host.
If no components are specified, module checks for all of them automatically, depending on the enabled languages in the project.
Imported Targets¶
This module provides the following Imported Targets:
OpenMP::OpenMP_<lang>在 3.9 版被加入.
Target encapsulating the OpenMP usage requirements for language
<lang>.
輸入變數¶
The following variables may be set to influence this module's behavior:
OpenMP_RUNTIME_MSVC在 3.30 版被加入.
Specify the OpenMP Runtime when compiling with MSVC. If set to a non-empty value, such as
experimentalorllvm, it will be passed as the value of the-openmp:flag.
結果變數¶
該模組定義了以下變數:
OpenMP_FOUND在 3.10 版被加入.
Boolean indicating that OpenMP flags for all requested languages were found. If no components are specified, this variable is set to boolean true if OpenMP settings for all enabled languages were detected.
OpenMP_VERSION在 4.2 版被加入.
Minimal version of the OpenMP standard detected among the requested languages, or all enabled languages if no components were specified.
This module will set the following variables per language in the
project, where <lang> is one of C, CXX, CUDA, or Fortran:
OpenMP_<lang>_FOUND在 3.9 版被加入.
Boolean indicating whether the (requested version of) OpenMP support for
<lang>was detected.OpenMP_<lang>_VERSION在 3.9 版被加入.
OpenMP version implemented by the
<lang>compiler, if available.OpenMP_<lang>_VERSION_MAJOR在 3.9 版被加入.
Major version of OpenMP implemented by the
<lang>compiler, if available.OpenMP_<lang>_VERSION_MINOR在 3.9 版被加入.
Minor version of OpenMP implemented by the
<lang>compiler, if available.OpenMP_<lang>_SPEC_DATE在 3.7 版被加入.
Date of the OpenMP specification implemented by the
<lang>compiler, if available.The specification date is formatted as given in the OpenMP standard:
yyyymmwhereyyyyandmmrepresents the year and month of the OpenMP specification implemented by the<lang>compiler.OpenMP_<lang>_FLAGSOpenMP compiler flags for
<lang>, separated by spaces.OpenMP_<lang>_INCLUDE_DIRS在 3.16 版被加入.
Directories that must be added to the header search path for
<lang>when using OpenMP.
For linking with OpenMP code written in <lang>, the following
variables are provided:
OpenMP_<lang>_LIB_NAMES在 3.9 版被加入.
A semicolon-separated list of OpenMP programs libraries for
<lang>.OpenMP_<libname>_LIBRARY在 3.9 版被加入.
Location of the individual libraries needed for OpenMP support in
<lang>. The<libname>names are stored in theOpenMP_<lang>_LIB_NAMESlist.OpenMP_<lang>_LIBRARIES在 3.9 版被加入.
A list of libraries needed to link with OpenMP code written in
<lang>.
Specifically for Fortran, the module sets the following variables:
OpenMP_Fortran_HAVE_OMPLIB_HEADER在 3.9 版被加入.
Boolean indicating whether OpenMP is accessible through the
omp_lib.hFortran header.OpenMP_Fortran_HAVE_OMPLIB_MODULE在 3.9 版被加入.
Boolean indicating whether OpenMP is accessible through the
omp_libFortran module.
For some compilers, it may be necessary to add a header search path to find
the relevant OpenMP headers. This location may be language-specific. Where
this is needed, the module may attempt to find the location, but it can be
provided directly by setting the OpenMP_<lang>_INCLUDE_DIR cache variable.
Note that this variable is an input control to the module. Project code
should use the OpenMP_<lang>_INCLUDE_DIRS output variable if it needs
to know what include directories are needed, or preferably the
OpenMP::OpenMP_<lang> imported target.
範例¶
Finding OpenMP support and linking the imported target to a project target using the C language component:
find_package(OpenMP)
target_link_libraries(project_target PRIVATE OpenMP::OpenMP_C)