diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake index 46ab90509d..19adf40bf2 100644 --- a/Modules/FindOpenMP.cmake +++ b/Modules/FindOpenMP.cmake @@ -9,7 +9,7 @@ Finds Open Multi-Processing (OpenMP) support in a compiler: .. code-block:: cmake - find_package(OpenMP [] [COMPONENTS ...] [...]) + find_package(OpenMP [] [COMPONENTS ...] [...]) If the compiler supports OpenMP, the flags required to compile with OpenMP support are returned in variables for the different languages. The variables @@ -26,7 +26,7 @@ syntax: .. code-block:: cmake - find_package(OpenMP [COMPONENTS ...]) + find_package(OpenMP [COMPONENTS ...]) Each of these components controls the various languages to search OpenMP support for. The following components are exposed: @@ -46,7 +46,8 @@ support for. The following components are exposed: The ``CUDA`` language 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. +If no components are specified, module checks for all of them automatically, +depending on the enabled languages in the project. Imported Targets ^^^^^^^^^^^^^^^^ @@ -85,6 +86,8 @@ This module defines the following variables: true if OpenMP settings for all enabled languages were detected. ``OpenMP_VERSION`` + .. versionadded:: 4.2 + Minimal version of the OpenMP standard detected among the requested languages, or all enabled languages if no components were specified. @@ -92,10 +95,44 @@ This module will set the following variables per language in the project, where ```` is one of C, CXX, CUDA, or Fortran: ``OpenMP__FOUND`` - Variable indicating if OpenMP support for ```` was detected. + .. versionadded:: 3.9 + + Boolean indicating whether the (requested version of) OpenMP support for + ```` was detected. + +``OpenMP__VERSION`` + .. versionadded:: 3.9 + + OpenMP version implemented by the ```` compiler, if available. + +``OpenMP__VERSION_MAJOR`` + .. versionadded:: 3.9 + + Major version of OpenMP implemented by the ```` compiler, if + available. + +``OpenMP__VERSION_MINOR`` + .. versionadded:: 3.9 + + Minor version of OpenMP implemented by the ```` compiler, if + available. + +``OpenMP__SPEC_DATE`` + .. versionadded:: 3.7 + + Date of the OpenMP specification implemented by the ```` compiler, + if available. + + The specification date is formatted as given in the OpenMP standard: + ``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of the + OpenMP specification implemented by the ```` compiler. + ``OpenMP__FLAGS`` OpenMP compiler flags for ````, separated by spaces. + ``OpenMP__INCLUDE_DIRS`` + .. versionadded:: 3.16 + Directories that must be added to the header search path for ```` when using OpenMP. @@ -103,46 +140,45 @@ For linking with OpenMP code written in ````, the following variables are provided: ``OpenMP__LIB_NAMES`` - :ref:`semicolon-separated list ` of libraries for - OpenMP programs for ````. + .. versionadded:: 3.9 + + A :ref:`semicolon-separated list ` of OpenMP + programs libraries for ````. + ``OpenMP__LIBRARY`` + .. versionadded:: 3.9 + Location of the individual libraries needed for OpenMP support in - ````. + ````. The ```` names are stored in the + ``OpenMP__LIB_NAMES`` list. + ``OpenMP__LIBRARIES`` + .. versionadded:: 3.9 + A list of libraries needed to link with OpenMP code written in ````. Specifically for Fortran, the module sets the following variables: ``OpenMP_Fortran_HAVE_OMPLIB_HEADER`` - Boolean indicating if OpenMP is accessible through ``omp_lib.h``. + .. versionadded:: 3.9 + + Boolean indicating whether OpenMP is accessible through the ``omp_lib.h`` + Fortran header. + ``OpenMP_Fortran_HAVE_OMPLIB_MODULE`` - Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran - module. + .. versionadded:: 3.9 -The module will also try to provide the OpenMP version variables: - -``OpenMP__SPEC_DATE`` - .. versionadded:: 3.7 - - Date of the OpenMP specification implemented by the ```` compiler. -``OpenMP__VERSION_MAJOR`` - Major version of OpenMP implemented by the ```` compiler. -``OpenMP__VERSION_MINOR`` - Minor version of OpenMP implemented by the ```` compiler. -``OpenMP__VERSION`` - OpenMP version implemented by the ```` compiler. - -The specification date is formatted as given in the OpenMP standard: -``yyyymm`` where ``yyyy`` and ``mm`` represents the year and month of -the OpenMP specification implemented by the ```` compiler. + Boolean indicating whether OpenMP is accessible through the ``omp_lib`` + Fortran 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__INCLUDE_DIR`` cache variable. -Note that this variable is an _input_ control to the module. Project code -should use the ``OpenMP__INCLUDE_DIRS`` _output_ variable if it needs -to know what include directories are needed. +Note that this variable is an *input* control to the module. Project code +should use the ``OpenMP__INCLUDE_DIRS`` *output* variable if it needs +to know what include directories are needed, or preferably the +``OpenMP::OpenMP_`` imported target. Examples ^^^^^^^^ @@ -668,7 +704,7 @@ else() set(OpenMP_FINDLIST ${OpenMP_FIND_COMPONENTS}) endif() -unset(_OpenMP_MIN_VERSION) +unset(OpenMP_VERSION) include(FindPackageHandleStandardArgs) @@ -703,8 +739,8 @@ foreach(LANG IN LISTS OpenMP_FINDLIST) if(OpenMP_${LANG}_FOUND) if(DEFINED OpenMP_${LANG}_VERSION) - if(NOT _OpenMP_MIN_VERSION OR _OpenMP_MIN_VERSION VERSION_GREATER OpenMP_${LANG}_VERSION) - set(_OpenMP_MIN_VERSION OpenMP_${LANG}_VERSION) + if(NOT OpenMP_VERSION OR OpenMP_VERSION VERSION_GREATER OpenMP_${LANG}_VERSION) + set(OpenMP_VERSION "${OpenMP_${LANG}_VERSION}") endif() endif() set(OpenMP_${LANG}_LIBRARIES "") @@ -751,7 +787,7 @@ endforeach() find_package_handle_standard_args(OpenMP REQUIRED_VARS ${_OpenMP_REQ_VARS} - VERSION_VAR ${_OpenMP_MIN_VERSION} + VERSION_VAR OpenMP_VERSION HANDLE_COMPONENTS) if(CMAKE_Fortran_COMPILER_LOADED AND OpenMP_Fortran_FOUND)