summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/AutogenInfo.cmake.in1
-rw-r--r--Modules/CMakeDetermineCompilerId.cmake14
-rw-r--r--Modules/CPackRPM.cmake13
-rw-r--r--Modules/Compiler/Intel.cmake2
-rw-r--r--Modules/CompilerId/Xcode-1.pbxproj.in120
-rw-r--r--Modules/CompilerId/Xcode-2.pbxproj.in119
-rw-r--r--Modules/FindMPI.cmake104
-rw-r--r--Modules/FindOpenMP.cmake535
-rw-r--r--Modules/FindwxWidgets.cmake22
-rw-r--r--Modules/GNUInstallDirs.cmake44
-rw-r--r--Modules/Platform/Linux-GNU.cmake1
-rw-r--r--Modules/UseJava.cmake36
12 files changed, 474 insertions, 537 deletions
diff --git a/Modules/AutogenInfo.cmake.in b/Modules/AutogenInfo.cmake.in
index fcecb6c..5e945bc 100644
--- a/Modules/AutogenInfo.cmake.in
+++ b/Modules/AutogenInfo.cmake.in
@@ -21,6 +21,7 @@ set(AM_MOC_INCLUDES @_moc_incs@)
set(AM_MOC_OPTIONS @_moc_options@)
set(AM_MOC_RELAXED_MODE @_moc_relaxed_mode@)
set(AM_MOC_DEPEND_FILTERS @_moc_depend_filters@)
+set(AM_MOC_PREDEFS_CMD @_moc_predefs_cmd@)
# UIC settings
set(AM_UIC_SKIP @_uic_skip@)
set(AM_UIC_TARGET_OPTIONS @_uic_target_options@)
diff --git a/Modules/CMakeDetermineCompilerId.cmake b/Modules/CMakeDetermineCompilerId.cmake
index 687263a..eeb806f 100644
--- a/Modules/CMakeDetermineCompilerId.cmake
+++ b/Modules/CMakeDetermineCompilerId.cmake
@@ -324,18 +324,8 @@ Id flags: ${testflags} ${CMAKE_${lang}_COMPILER_ID_FLAGS_ALWAYS}
else()
set(id_sdkroot "")
endif()
- if(NOT ${XCODE_VERSION} VERSION_LESS 3)
- set(v 3)
- set(ext xcodeproj)
- elseif(NOT ${XCODE_VERSION} VERSION_LESS 2)
- set(v 2)
- set(ext xcodeproj)
- else()
- set(v 1)
- set(ext xcode)
- endif()
- configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-${v}.pbxproj.in
- ${id_dir}/CompilerId${lang}.${ext}/project.pbxproj @ONLY)
+ configure_file(${CMAKE_ROOT}/Modules/CompilerId/Xcode-3.pbxproj.in
+ ${id_dir}/CompilerId${lang}.xcodeproj/project.pbxproj @ONLY)
unset(_ENV_MACOSX_DEPLOYMENT_TARGET)
if(DEFINED ENV{MACOSX_DEPLOYMENT_TARGET})
set(_ENV_MACOSX_DEPLOYMENT_TARGET "$ENV{MACOSX_DEPLOYMENT_TARGET}")
diff --git a/Modules/CPackRPM.cmake b/Modules/CPackRPM.cmake
index cc54032..fa2a6e4 100644
--- a/Modules/CPackRPM.cmake
+++ b/Modules/CPackRPM.cmake
@@ -911,6 +911,19 @@
#
# * Mandatory : YES
# * Default : "/"
+#
+# .. VARIABLE:: CPACK_RPM_BUILDREQUIRES
+#
+# List of source rpm build dependencies.
+#
+# * Mandatory : NO
+# * Default : -
+#
+# May be used to set source RPM build dependencies (BuildRequires). Note that
+# you must enclose the complete build requirements string between quotes, for
+# example::
+#
+# set(CPACK_RPM_BUILDREQUIRES "python >= 2.5.0, cmake >= 2.8")
# Author: Eric Noulard with the help of Alexander Neundorf.
diff --git a/Modules/Compiler/Intel.cmake b/Modules/Compiler/Intel.cmake
index 02968b4..06d01f1 100644
--- a/Modules/Compiler/Intel.cmake
+++ b/Modules/Compiler/Intel.cmake
@@ -22,5 +22,7 @@ else()
string(APPEND CMAKE_${lang}_FLAGS_MINSIZEREL_INIT " -Os")
string(APPEND CMAKE_${lang}_FLAGS_RELEASE_INIT " -O3")
string(APPEND CMAKE_${lang}_FLAGS_RELWITHDEBINFO_INIT " -O2 -g")
+
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-QdM" "-P" "-Za" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
endif()
diff --git a/Modules/CompilerId/Xcode-1.pbxproj.in b/Modules/CompilerId/Xcode-1.pbxproj.in
deleted file mode 100644
index 793ad02..0000000
--- a/Modules/CompilerId/Xcode-1.pbxproj.in
+++ /dev/null
@@ -1,120 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 39;
- objects = {
- 014CEA460018CE2711CA2923 = {
- buildSettings = {
- };
- isa = PBXBuildStyle;
- name = Development;
- };
- 08FB7793FE84155DC02AAC07 = {
- buildSettings = {
- };
- buildStyles = (
- 014CEA460018CE2711CA2923,
- );
- hasScannedForEncodings = 1;
- isa = PBXProject;
- mainGroup = 08FB7794FE84155DC02AAC07;
- projectDirPath = "";
- targets = (
- 8DD76FA90486AB0100D96B5E,
- );
- };
- 08FB7794FE84155DC02AAC07 = {
- children = (
- 08FB7795FE84155DC02AAC07,
- 1AB674ADFE9D54B511CA2CBB,
- );
- isa = PBXGroup;
- name = CompilerId@id_lang@;
- refType = 4;
- sourceTree = "<group>";
- };
- 08FB7795FE84155DC02AAC07 = {
- children = (
- 2C18F0B415DC1DC700593670,
- );
- isa = PBXGroup;
- name = Source;
- refType = 4;
- sourceTree = "<group>";
- };
- 1AB674ADFE9D54B511CA2CBB = {
- children = (
- 8DD76F6C0486A84900D96B5E,
- );
- isa = PBXGroup;
- name = Products;
- refType = 4;
- sourceTree = "<group>";
- };
- 2C18F0B415DC1DC700593670 = {
- fileEncoding = 30;
- isa = PBXFileReference;
- explicitFileType = @id_type@;
- path = @id_src@;
- refType = 4;
- sourceTree = "<group>";
- };
- 2C18F0B615DC1E0300593670 = {
- fileRef = 2C18F0B415DC1DC700593670;
- isa = PBXBuildFile;
- settings = {
- };
- };
- 2C8FEB8E15DC1A1A00E56A5D = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "echo \"GCC_VERSION=$GCC_VERSION\"";
- };
- 8DD76FA90486AB0100D96B5E = {
- buildPhases = (
- 2C18F0B515DC1DCE00593670,
- 2C8FEB8E15DC1A1A00E56A5D,
- );
- buildRules = (
- );
- buildSettings = {
- PRODUCT_NAME = CompilerId@id_lang@;
- SYMROOT = .;
- };
- dependencies = (
- );
- isa = PBXNativeTarget;
- name = CompilerId@id_lang@;
- productName = CompilerId@id_lang@;
- productReference = 8DD76F6C0486A84900D96B5E;
- productType = "com.apple.product-type.tool";
- };
- 2C18F0B515DC1DCE00593670 = {
- buildActionMask = 2147483647;
- files = (
- 2C18F0B615DC1E0300593670,
- );
- isa = PBXSourcesBuildPhase;
- runOnlyForDeploymentPostprocessing = 0;
- };
- 8DD76F6C0486A84900D96B5E = {
- explicitFileType = "compiled.mach-o.executable";
- includeInIndex = 0;
- isa = PBXFileReference;
- path = CompilerId@id_lang@;
- refType = 3;
- sourceTree = BUILT_PRODUCTS_DIR;
- };
- };
- rootObject = 08FB7793FE84155DC02AAC07;
-}
diff --git a/Modules/CompilerId/Xcode-2.pbxproj.in b/Modules/CompilerId/Xcode-2.pbxproj.in
deleted file mode 100644
index 226b413..0000000
--- a/Modules/CompilerId/Xcode-2.pbxproj.in
+++ /dev/null
@@ -1,119 +0,0 @@
-// !$*UTF8*$!
-{
- archiveVersion = 1;
- classes = {
- };
- objectVersion = 42;
- objects = {
-
- 2C18F0B615DC1E0300593670 = {isa = PBXBuildFile; fileRef = 2C18F0B415DC1DC700593670; };
- 2C18F0B415DC1DC700593670 = {isa = PBXFileReference; fileEncoding = 4; explicitFileType = @id_type@; path = @id_src@; sourceTree = "<group>"; };
- 8DD76F6C0486A84900D96B5E = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.executable"; includeInIndex = 0; path = CompilerId@id_lang@; sourceTree = BUILT_PRODUCTS_DIR; };
-
- 08FB7794FE84155DC02AAC07 = {
- isa = PBXGroup;
- children = (
- 08FB7795FE84155DC02AAC07,
- 1AB674ADFE9D54B511CA2CBB,
- );
- name = CompilerId@id_lang@;
- sourceTree = "<group>";
- };
- 08FB7795FE84155DC02AAC07 = {
- isa = PBXGroup;
- children = (
- 2C18F0B415DC1DC700593670,
- );
- name = Source;
- sourceTree = "<group>";
- };
- 1AB674ADFE9D54B511CA2CBB = {
- isa = PBXGroup;
- children = (
- 8DD76F6C0486A84900D96B5E,
- );
- name = Products;
- sourceTree = "<group>";
- };
-
- 8DD76FA90486AB0100D96B5E = {
- isa = PBXNativeTarget;
- buildConfigurationList = 1DEB928508733DD80010E9CD;
- buildPhases = (
- 2C18F0B515DC1DCE00593670,
- 2C8FEB8E15DC1A1A00E56A5D,
- );
- buildRules = (
- );
- dependencies = (
- );
- name = CompilerId@id_lang@;
- productName = CompilerId@id_lang@;
- productReference = 8DD76F6C0486A84900D96B5E;
- productType = "com.apple.product-type.tool";
- };
- 08FB7793FE84155DC02AAC07 = {
- isa = PBXProject;
- buildConfigurationList = 1DEB928908733DD80010E9CD;
- hasScannedForEncodings = 1;
- mainGroup = 08FB7794FE84155DC02AAC07;
- projectDirPath = "";
- targets = (
- 8DD76FA90486AB0100D96B5E,
- );
- };
- 2C8FEB8E15DC1A1A00E56A5D = {
- isa = PBXShellScriptBuildPhase;
- buildActionMask = 2147483647;
- files = (
- );
- inputPaths = (
- );
- outputPaths = (
- );
- runOnlyForDeploymentPostprocessing = 0;
- shellPath = /bin/sh;
- shellScript = "echo \"GCC_VERSION=$GCC_VERSION\"";
- };
- 2C18F0B515DC1DCE00593670 = {
- isa = PBXSourcesBuildPhase;
- buildActionMask = 2147483647;
- files = (
- 2C18F0B615DC1E0300593670,
- );
- runOnlyForDeploymentPostprocessing = 0;
- };
- 1DEB928608733DD80010E9CD = {
- isa = XCBuildConfiguration;
- buildSettings = {
- PRODUCT_NAME = CompilerId@id_lang@;
- };
- name = Debug;
- };
- 1DEB928A08733DD80010E9CD = {
- isa = XCBuildConfiguration;
- buildSettings = {
- CONFIGURATION_BUILD_DIR = "$(BUILD_DIR)";
- SYMROOT = .;
- };
- name = Debug;
- };
- 1DEB928508733DD80010E9CD = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1DEB928608733DD80010E9CD,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Debug;
- };
- 1DEB928908733DD80010E9CD = {
- isa = XCConfigurationList;
- buildConfigurations = (
- 1DEB928A08733DD80010E9CD,
- );
- defaultConfigurationIsVisible = 0;
- defaultConfigurationName = Debug;
- };
- };
- rootObject = 08FB7793FE84155DC02AAC07;
-}
diff --git a/Modules/FindMPI.cmake b/Modules/FindMPI.cmake
index 3e8be5b..fab53cb 100644
--- a/Modules/FindMPI.cmake
+++ b/Modules/FindMPI.cmake
@@ -10,77 +10,78 @@
# The Message Passing Interface (MPI) is a library used to write
# high-performance distributed-memory parallel applications, and is
# typically deployed on a cluster. MPI is a standard interface (defined
-# by the MPI forum) for which many implementations are available. All
-# of them have somewhat different include paths, libraries to link
-# against, etc., and this module tries to smooth out those differences.
+# by the MPI forum) for which many implementations are available.
#
# Variables
# ^^^^^^^^^
#
# This module will set the following variables per language in your
-# project, where <lang> is one of C, CXX, or Fortran:
-#
-# ::
-#
-# MPI_<lang>_FOUND TRUE if FindMPI found MPI flags for <lang>
-# MPI_<lang>_COMPILER MPI Compiler wrapper for <lang>
-# MPI_<lang>_COMPILE_FLAGS Compilation flags for MPI programs
-# MPI_<lang>_INCLUDE_PATH Include path(s) for MPI header
-# MPI_<lang>_LINK_FLAGS Linking flags for MPI programs
-# MPI_<lang>_LIBRARIES All libraries to link MPI programs against
+# project, where ``<lang>`` is one of C, CXX, or Fortran:
+#
+# ``MPI_<lang>_FOUND``
+# Variable indicating the MPI settings for ``<lang>`` were found.
+# ``MPI_<lang>_COMPILER``
+# MPI Compiler wrapper for ``<lang>``.
+# ``MPI_<lang>_COMPILE_FLAGS``
+# Compilation flags for MPI programs, separated by spaces.
+# This is *not* a :ref:`;-list <CMake Language Lists>`.
+# ``MPI_<lang>_INCLUDE_PATH``
+# Include path(s) for MPI header.
+# ``MPI_<lang>_LINK_FLAGS``
+# Linker flags for MPI programs.
+# ``MPI_<lang>_LIBRARIES``
+# All libraries to link MPI programs against.
#
# Additionally, the following :prop_tgt:`IMPORTED` targets are defined:
#
-# ::
-#
-# MPI::MPI_<lang> Target for using MPI from <lang>
+# ``MPI::MPI_<lang>``
+# Target for using MPI from ``<lang>``.
#
# Additionally, FindMPI sets the following variables for running MPI
# programs from the command line:
#
-# ::
-#
-# MPIEXEC Executable for running MPI programs
-# MPIEXEC_NUMPROC_FLAG Flag to pass to MPIEXEC before giving
-# it the number of processors to run on
-# MPIEXEC_PREFLAGS Flags to pass to MPIEXEC directly
-# before the executable to run.
-# MPIEXEC_POSTFLAGS Flags to pass to MPIEXEC after other flags
+# ``MPIEXEC``
+# Executable for running MPI programs, if provided.
+# ``MPIEXEC_NUMPROC_FLAG``
+# Flag to pass to ``MPIEXEC`` before giving it the number of processors to run on.
+# ``MPIEXEC_MAX_NUMPROCS``
+# Number of MPI processors to utilize. Defaults to the number
+# of processors detected on the host system.
+# ``MPIEXEC_PREFLAGS``
+# Flags to pass to ``MPIEXEC`` directly before the executable to run.
+# ``MPIEXEC_POSTFLAGS``
+# Flags to pass to ``MPIEXEC`` after other flags.
#
# Usage
# ^^^^^
#
-# To use this module, simply call FindMPI from a CMakeLists.txt file, or
-# run ``find_package(MPI)``, then run CMake. If you are happy with the
+# To use this module, call ``find_package(MPI)``. If you are happy with the
# auto-detected configuration for your language, then you're done. If
# not, you have two options:
#
-# ::
-#
-# 1. Set MPI_<lang>_COMPILER to the MPI wrapper (mpicc, etc.) of your
-# choice and reconfigure. FindMPI will attempt to determine all the
-# necessary variables using THAT compiler's compile and link flags.
-# 2. If this fails, or if your MPI implementation does not come with
-# a compiler wrapper, then set both MPI_<lang>_LIBRARIES and
-# MPI_<lang>_INCLUDE_PATH. You may also set any other variables
-# listed above, but these two are required. This will circumvent
-# autodetection entirely.
+# 1. Set ``MPI_<lang>_COMPILER`` to the MPI wrapper (e.g. ``mpicc``) of your
+# choice and reconfigure. FindMPI will attempt to determine all the
+# necessary variables using *that* compiler's compile and link flags.
+# 2. If this fails, or if your MPI implementation does not come with
+# a compiler wrapper, then set both ``MPI_<lang>_LIBRARIES`` and
+# ``MPI_<lang>_INCLUDE_PATH``. You may also set any other variables
+# listed above, but these two are required. This will circumvent
+# autodetection entirely.
#
# When configuration is successful, ``MPI_<lang>_COMPILER`` will be set to
-# the compiler wrapper for <lang>, if it was found. ``MPI_<lang>_FOUND``
+# the compiler wrapper for ``<lang>``, if it was found. ``MPI_<lang>_FOUND``
# and other variables above will be set if any MPI implementation was
-# found for <lang>, regardless of whether a compiler was found.
+# found for ``<lang>``, regardless of whether a compiler was found.
#
# When using ``MPIEXEC`` to execute MPI applications, you should typically
# use all of the ``MPIEXEC`` flags as follows:
#
# ::
#
-# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} PROCS
+# ${MPIEXEC} ${MPIEXEC_NUMPROC_FLAG} ${MPIEXEC_MAX_NUMPROCS}
# ${MPIEXEC_PREFLAGS} EXECUTABLE ${MPIEXEC_POSTFLAGS} ARGS
#
-# where ``PROCS`` is the number of processors on which to execute the
-# program, ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
+# where ``EXECUTABLE`` is the MPI program, and ``ARGS`` are the arguments to
# pass to the MPI program.
#
# Backward Compatibility
@@ -106,12 +107,12 @@ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
# The compilers are detected in this order:
#
# 1. Try to find the most generic available MPI compiler, as this is usually set up by
-# cluster admins. e.g., if plain old mpicc is available, we'll use it and assume it's
+# cluster admins, e.g. if plain old mpicc is available, we'll use it and assume it's
# the right compiler.
#
# 2. If a generic mpicc is NOT found, then we attempt to find one that matches
# CMAKE_<lang>_COMPILER_ID. e.g. if you are using XL compilers, we'll try to find mpixlc
-# and company, but not mpiicc. This hopefully prevents toolchain mismatches.
+# and company, but not mpiicc. This hopefully prevents toolchain mismatches.
#
# If you want to force a particular MPI compiler other than what we autodetect (e.g. if you
# want to compile regular stuff with GNU and parallel stuff with Intel), you can always set
@@ -482,7 +483,7 @@ function (interrogate_mpi_compiler lang try_libs)
set(MPI_${lang}_LIBRARIES ${MPI_LIBRARIES_WORK} CACHE STRING "MPI ${lang} libraries to link against" FORCE)
mark_as_advanced(MPI_${lang}_COMPILE_FLAGS MPI_${lang}_INCLUDE_PATH MPI_${lang}_LINK_FLAGS MPI_${lang}_LIBRARIES)
- # clear out our temporary lib/header detectionv variable here.
+ # clear out our temporary lib/header detection variable here.
set(MPI_LIB "MPI_LIB-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI lib detection" FORCE)
set(MPI_HEADER_PATH "MPI_HEADER_PATH-NOTFOUND" CACHE INTERNAL "Scratch variable for MPI header detection" FORCE)
endif()
@@ -552,10 +553,21 @@ find_program(MPIEXEC
get_filename_component(_MPI_BASE_DIR "${MPIEXEC}" PATH)
get_filename_component(_MPI_BASE_DIR "${_MPI_BASE_DIR}" PATH)
-set(MPIEXEC_NUMPROC_FLAG "-np" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.")
+# According to the MPI standard, section 8.8 -n is a guaranteed, and the only guaranteed way to
+# launch an MPI process using mpiexec if such a program exists.
+set(MPIEXEC_NUMPROC_FLAG "-n" CACHE STRING "Flag used by MPI to specify the number of processes for MPIEXEC; the next option will be the number of processes.")
set(MPIEXEC_PREFLAGS "" CACHE STRING "These flags will be directly before the executable that is being run by MPIEXEC.")
set(MPIEXEC_POSTFLAGS "" CACHE STRING "These flags will come after all flags given to MPIEXEC.")
-set(MPIEXEC_MAX_NUMPROCS "2" CACHE STRING "Maximum number of processors available to run MPI applications.")
+
+# Set the number of processes to the processor count and the previous default
+# of 2 if that couldn't be determined.
+include(${CMAKE_CURRENT_LIST_DIR}/ProcessorCount.cmake)
+ProcessorCount(_MPIEXEC_NUMPROCS)
+if("${_MPIEXEC_NUMPROCS}" EQUAL "0")
+ set(_MPIEXEC_NUMPROCS 2)
+endif()
+set(MPIEXEC_MAX_NUMPROCS "${_MPIEXEC_NUMPROCS}" CACHE STRING "Maximum number of processors available to run MPI applications.")
+unset(_MPIEXEC_NUMPROCS)
mark_as_advanced(MPIEXEC MPIEXEC_NUMPROC_FLAG MPIEXEC_PREFLAGS MPIEXEC_POSTFLAGS MPIEXEC_MAX_NUMPROCS)
diff --git a/Modules/FindOpenMP.cmake b/Modules/FindOpenMP.cmake
index f399836..8c1b018 100644
--- a/Modules/FindOpenMP.cmake
+++ b/Modules/FindOpenMP.cmake
@@ -13,112 +13,215 @@
# The variables may be empty if the compiler does not need a special
# flag to support OpenMP.
#
-# The following variables are set:
+# Variables
+# ^^^^^^^^^
#
-# ``OpenMP_C_FLAGS``
-# Flags to add to the C compiler for OpenMP support.
-# ``OpenMP_CXX_FLAGS``
-# Flags to add to the CXX compiler for OpenMP support.
-# ``OpenMP_Fortran_FLAGS``
-# Flags to add to the Fortran compiler for OpenMP support.
-# ``OPENMP_FOUND``
-# True if openmp is detected.
+# This module will set the following variables per language in your
+# project, where ``<lang>`` is one of C, CXX, or Fortran:
#
-# The following internal variables are set, if detected:
+# ``OpenMP_<lang>_FOUND``
+# Variable indicating if OpenMP support for ``<lang>`` was detected.
+# ``OpenMP_<lang>_FLAGS``
+# OpenMP compiler flags for ``<lang>``, separated by spaces.
#
-# ``OpenMP_C_SPEC_DATE``
-# Specification date of OpenMP version of C compiler.
-# ``OpenMP_CXX_SPEC_DATE``
-# Specification date of OpenMP version of CXX compiler.
-# ``OpenMP_Fortran_SPEC_DATE``
-# Specification date of OpenMP version of Fortran compiler.
+# For linking with OpenMP code written in ``<lang>``, the following
+# variables are provided:
#
-# The specification dates are formatted as integers of the form
-# ``CCYYMM`` where these represent the decimal digits of the century,
-# year, and month.
+# ``OpenMP_<lang>_LIB_NAMES``
+# :ref:`;-list <CMake Language Lists>` of libraries for OpenMP programs for ``<lang>``.
+# ``OpenMP_<libname>_LIBRARY``
+# Location of the individual libraries needed for OpenMP support in ``<lang>``.
+# ``OpenMP_<lang>_LIBRARIES``
+# A list of libraries needed to link with OpenMP code written in ``<lang>``.
+#
+# Additionally, the module provides :prop_tgt:`IMPORTED` targets:
+#
+# ``OpenMP::OpenMP_<lang>``
+# Target for using OpenMP from ``<lang>``.
+#
+# Specifically for Fortran, the module sets the following variables:
+#
+# ``OpenMP_Fortran_HAVE_OMPLIB_HEADER``
+# Boolean indicating if OpenMP is accessible through ``omp_lib.h``.
+# ``OpenMP_Fortran_HAVE_OMPLIB_MODULE``
+# Boolean indicating if OpenMP is accessible through the ``omp_lib`` Fortran module.
+#
+# The module will also try to provide the OpenMP version variables:
+#
+# ``OpenMP_<lang>_SPEC_DATE``
+# Date of the OpenMP specification implemented by the ``<lang>`` compiler.
+# ``OpenMP_<lang>_VERSION_MAJOR``
+# Major version of OpenMP implemented by the ``<lang>`` compiler.
+# ``OpenMP_<lang>_VERSION_MINOR``
+# Minor version of OpenMP implemented by the ``<lang>`` compiler.
+# ``OpenMP_<lang>_VERSION``
+# OpenMP version implemented by the ``<lang>`` 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 ``<lang>`` compiler.
+#
+# Backward Compatibility
+# ^^^^^^^^^^^^^^^^^^^^^^
+#
+# For backward compatibility with older versions of FindOpenMP, these
+# variables are set, but deprecated::
+#
+# OpenMP_FOUND
+#
+# In new projects, please use the ``OpenMP_<lang>_XXX`` equivalents.
-set(_OPENMP_REQUIRED_VARS)
-set(CMAKE_REQUIRED_QUIET_SAVE ${CMAKE_REQUIRED_QUIET})
-set(CMAKE_REQUIRED_QUIET ${OpenMP_FIND_QUIETLY})
+cmake_policy(PUSH)
+cmake_policy(SET CMP0057 NEW) # if IN_LIST
function(_OPENMP_FLAG_CANDIDATES LANG)
- set(OpenMP_FLAG_CANDIDATES
- #Empty, if compiler automatically accepts openmp
- " "
- #GNU
- "-fopenmp"
- #Clang
- "-fopenmp=libiomp5"
- "-fopenmp=libomp"
- #Microsoft Visual Studio
- "/openmp"
- #Intel windows
- "-Qopenmp"
- #PathScale, Intel
- "-openmp"
- #Sun
- "-xopenmp"
- #HP
- "+Oopenmp"
- #IBM XL C/c++
- "-qsmp"
- #Portland Group, MIPSpro
- "-mp"
- )
+ if(NOT OpenMP_${LANG}_FLAG)
+ set(OpenMP_FLAG_CANDIDATES "")
+
+ set(OMP_FLAG_GNU "-fopenmp")
+ set(OMP_FLAG_Clang "-fopenmp=libomp" "-fopenmp=libiomp5")
+ set(OMP_FLAG_HP "+Oopenmp")
+ if(WIN32)
+ set(OMP_FLAG_Intel "-Qopenmp")
+ elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "Intel" AND
+ "${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
+ set(OMP_FLAG_Intel "-openmp")
+ else()
+ set(OMP_FLAG_Intel "-qopenmp")
+ endif()
+ set(OMP_FLAG_MIPSpro "-mp")
+ set(OMP_FLAG_MSVC "-openmp")
+ set(OMP_FLAG_PathScale "-openmp")
+ set(OMP_FLAG_PGI "-mp")
+ set(OMP_FLAG_SunPro "-xopenmp")
+ set(OMP_FLAG_XL "-qsmp=omp")
+ # Cray compiles with OpenMP automatically
+
+ if(DEFINED OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID})
+ list(APPEND OpenMP_FLAG_CANDIDATES "${OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}}")
+ endif()
- set(OMP_FLAG_GNU "-fopenmp")
- set(OMP_FLAG_Clang "-fopenmp=libomp")
- set(OMP_FLAG_HP "+Oopenmp")
- if(WIN32)
- set(OMP_FLAG_Intel "-Qopenmp")
- elseif(CMAKE_${LANG}_COMPILER_ID STREQUAL "Intel" AND
- "${CMAKE_${LANG}_COMPILER_VERSION}" VERSION_LESS "15.0.0.20140528")
- set(OMP_FLAG_Intel "-openmp")
+ list(APPEND OpenMP_FLAG_CANDIDATES " ")
+ set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_FLAG_CANDIDATES}" PARENT_SCOPE)
else()
- set(OMP_FLAG_Intel "-qopenmp")
- endif()
- set(OMP_FLAG_MIPSpro "-mp")
- set(OMP_FLAG_MSVC "/openmp")
- set(OMP_FLAG_PathScale "-openmp")
- set(OMP_FLAG_PGI "-mp")
- set(OMP_FLAG_SunPro "-xopenmp")
- set(OMP_FLAG_XL "-qsmp")
- set(OMP_FLAG_Cray " ")
-
- # Move the flag that matches the compiler to the head of the list,
- # this is faster and doesn't clutter the output that much. If that
- # flag doesn't work we will still try all.
- if(OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID})
- list(REMOVE_ITEM OpenMP_FLAG_CANDIDATES "${OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}}")
- list(INSERT OpenMP_FLAG_CANDIDATES 0 "${OMP_FLAG_${CMAKE_${LANG}_COMPILER_ID}}")
+ set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_${LANG}_FLAG}" PARENT_SCOPE)
endif()
-
- set(OpenMP_${LANG}_FLAG_CANDIDATES "${OpenMP_FLAG_CANDIDATES}" PARENT_SCOPE)
endfunction()
# sample openmp source code to test
-set(OpenMP_C_TEST_SOURCE
+set(OpenMP_C_CXX_TEST_SOURCE
"
#include <omp.h>
int main() {
-#ifdef _OPENMP
- return 0;
-#else
+#ifndef _OPENMP
breaks_on_purpose
#endif
}
")
-# same in Fortran
+# in Fortran, an implementation may provide an omp_lib.h header
+# or omp_lib module, or both (OpenMP standard, section 3.1)
+# Furthmore !$ is the Fortran equivalent of #ifdef _OPENMP (OpenMP standard, 2.2.2)
+# Without the conditional compilation, some compilers (e.g. PGI) might compile OpenMP code
+# while not actually enabling OpenMP, building code sequentially
set(OpenMP_Fortran_TEST_SOURCE
"
program test
- use omp_lib
- integer :: n
+ @OpenMP_Fortran_INCLUDE_LINE@
+ !$ integer :: n
n = omp_get_num_threads()
end program test
"
- )
+)
+
+function(_OPENMP_WRITE_SOURCE_FILE LANG SRC_FILE_CONTENT_VAR SRC_FILE_NAME SRC_FILE_FULLPATH)
+ set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP)
+ if("${LANG}" STREQUAL "C")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.c")
+ file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}")
+ elseif("${LANG}" STREQUAL "CXX")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.cpp")
+ file(WRITE "${SRC_FILE}" "${OpenMP_C_CXX_${SRC_FILE_CONTENT_VAR}}")
+ elseif("${LANG}" STREQUAL "Fortran")
+ set(SRC_FILE "${WORK_DIR}/${SRC_FILE_NAME}.f90")
+ file(WRITE "${SRC_FILE}_in" "${OpenMP_Fortran_${SRC_FILE_CONTENT_VAR}}")
+ configure_file("${SRC_FILE}_in" "${SRC_FILE}" @ONLY)
+ endif()
+ set(${SRC_FILE_FULLPATH} "${SRC_FILE}" PARENT_SCOPE)
+endfunction()
+
+include(${CMAKE_ROOT}/Modules/CMakeParseImplicitLinkInfo.cmake)
+
+function(_OPENMP_GET_FLAGS LANG OPENMP_FLAG_VAR OPENMP_LIB_NAMES_VAR)
+ _OPENMP_FLAG_CANDIDATES("${LANG}")
+ _OPENMP_WRITE_SOURCE_FILE("${LANG}" "TEST_SOURCE" OpenMPTryFlag _OPENMP_TEST_SRC)
+
+ foreach(OPENMP_FLAG IN LISTS OpenMP_${LANG}_FLAG_CANDIDATES)
+ set(OPENMP_FLAGS_TEST "${OPENMP_FLAG}")
+ if(CMAKE_${LANG}_VERBOSE_FLAG)
+ string(APPEND OPENMP_FLAGS_TEST " ${CMAKE_${LANG}_VERBOSE_FLAG}")
+ endif()
+ try_compile( OpenMP_TRY_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${_OPENMP_TEST_SRC}
+ CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OPENMP_FLAGS_TEST}"
+ OUTPUT_VARIABLE OpenMP_TRY_COMPILE_OUTPUT
+ )
+
+ if(OpenMP_TRY_COMPILE_RESULT)
+ unset(OpenMP_TRY_COMPILE_RESULT CACHE)
+ set("${OPENMP_FLAG_VAR}" "${OPENMP_FLAG}" PARENT_SCOPE)
+
+ if(CMAKE_${LANG}_VERBOSE_FLAG)
+ unset(OpenMP_${LANG}_IMPLICIT_LIBRARIES)
+ unset(OpenMP_${LANG}_IMPLICIT_LINK_DIRS)
+ unset(OpenMP_${LANG}_IMPLICIT_FWK_DIRS)
+ unset(OpenMP_${LANG}_LOG_VAR)
+
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Detecting ${LANG} OpenMP compiler ABI info compiled with the following output:\n${OpenMP_TRY_COMPILE_OUTPUT}\n\n")
+
+ cmake_parse_implicit_link_info("${OpenMP_TRY_COMPILE_OUTPUT}"
+ OpenMP_${LANG}_IMPLICIT_LIBRARIES
+ OpenMP_${LANG}_IMPLICIT_LINK_DIRS
+ OpenMP_${LANG}_IMPLICIT_FWK_DIRS
+ OpenMP_${LANG}_LOG_VAR
+ "${CMAKE_${LANG}_IMPLICIT_OBJECT_REGEX}"
+ )
+
+ file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
+ "Parsed ${LANG} OpenMP implicit link information from above output:\n${OpenMP_${LANG}_LOG_VAR}\n\n")
+
+ unset(_OPENMP_LIB_NAMES)
+ foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_IMPLICIT_LIBRARIES)
+ if(NOT "${_OPENMP_IMPLICIT_LIB}" IN_LIST CMAKE_${LANG}_IMPLICIT_LINK_LIBRARIES)
+ find_library(OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY
+ NAMES "${_OPENMP_IMPLICIT_LIB}"
+ HINTS ${OpenMP_${LANG}_IMPLICIT_LINK_DIRS}
+ )
+ mark_as_advanced(OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY)
+ list(APPEND _OPENMP_LIB_NAMES ${_OPENMP_IMPLICIT_LIB})
+ endif()
+ endforeach()
+ set("${OPENMP_LIB_NAMES_VAR}" "${_OPENMP_LIB_NAMES}" PARENT_SCOPE)
+ else()
+ # The Intel compiler on windows has no verbose mode, so we need to treat it explicitly
+ if("${CMAKE_${LANG}_COMPILER_ID}" STREQUAL "Intel" AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
+ set("${OPENMP_LIB_NAMES_VAR}" "libiomp5md" PARENT_SCOPE)
+ find_library(OpenMP_libiomp5md_LIBRARY
+ NAMES "libiomp5md"
+ HINTS ${CMAKE_${LANG}_IMPLICIT_LINK_DIRECTORIES}
+ )
+ mark_as_advanced(OpenMP_libiomp5md_LIBRARY)
+ else()
+ set("${OPENMP_LIB_NAMES_VAR}" "" PARENT_SCOPE)
+ endif()
+ endif()
+ break()
+ endif()
+ set("${OPENMP_LIB_NAMES_VAR}" "NOTFOUND" PARENT_SCOPE)
+ set("${OPENMP_FLAG_VAR}" "NOTFOUND" PARENT_SCOPE)
+ unset(OpenMP_TRY_COMPILE_RESULT CACHE)
+ endforeach()
+endfunction()
set(OpenMP_C_CXX_CHECK_VERSION_SOURCE
"
@@ -133,17 +236,16 @@ const char ompver_str[] = { 'I', 'N', 'F', 'O', ':', 'O', 'p', 'e', 'n', 'M',
('0' + ((_OPENMP/10)%10)),
('0' + ((_OPENMP/1)%10)),
']', '\\0' };
-int main(int argc, char *argv[])
+int main()
{
- printf(\"%s\\n\", ompver_str);
- return 0;
+ puts(ompver_str);
}
")
set(OpenMP_Fortran_CHECK_VERSION_SOURCE
"
program omp_ver
- use omp_lib
+ @OpenMP_Fortran_INCLUDE_LINE@
integer, parameter :: zero = ichar('0')
integer, parameter :: ompv = openmp_version
character, dimension(24), parameter :: ompver_str =&
@@ -160,20 +262,10 @@ set(OpenMP_Fortran_CHECK_VERSION_SOURCE
")
function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE)
- set(WORK_DIR ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP)
- if("${LANG}" STREQUAL "C")
- set(SRC_FILE ${WORK_DIR}/ompver.c)
- file(WRITE ${SRC_FILE} "${OpenMP_C_CXX_CHECK_VERSION_SOURCE}")
- elseif("${LANG}" STREQUAL "CXX")
- set(SRC_FILE ${WORK_DIR}/ompver.cpp)
- file(WRITE ${SRC_FILE} "${OpenMP_C_CXX_CHECK_VERSION_SOURCE}")
- else() # ("${LANG}" STREQUAL "Fortran")
- set(SRC_FILE ${WORK_DIR}/ompver.f90)
- file(WRITE ${SRC_FILE} "${OpenMP_Fortran_CHECK_VERSION_SOURCE}")
- endif()
+ _OPENMP_WRITE_SOURCE_FILE("${LANG}" "CHECK_VERSION_SOURCE" OpenMPCheckVersion _OPENMP_TEST_SRC)
- set(BIN_FILE ${WORK_DIR}/ompver_${LANG}.bin)
- try_compile(OpenMP_TRY_COMPILE_RESULT ${CMAKE_BINARY_DIR} ${SRC_FILE}
+ set(BIN_FILE "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/FindOpenMP/ompver_${LANG}.bin")
+ try_compile(OpenMP_TRY_COMPILE_RESULT "${CMAKE_BINARY_DIR}" "${_OPENMP_TEST_SRC}"
CMAKE_FLAGS "-DCOMPILE_DEFINITIONS:STRING=${OpenMP_${LANG}_FLAGS}"
COPY_FILE ${BIN_FILE})
@@ -188,144 +280,173 @@ function(_OPENMP_GET_SPEC_DATE LANG SPEC_DATE)
unset(OpenMP_TRY_COMPILE_RESULT CACHE)
endfunction()
+macro(_OPENMP_SET_VERSION_BY_SPEC_DATE LANG)
+ set(OpenMP_SPEC_DATE_MAP
+ # Combined versions, 2.5 onwards
+ "201511=4.5"
+ "201307=4.0"
+ "201107=3.1"
+ "200805=3.0"
+ "200505=2.5"
+ # C/C++ version 2.0
+ "200203=2.0"
+ # Fortran version 2.0
+ "200011=2.0"
+ # Fortran version 1.1
+ "199911=1.1"
+ # C/C++ version 1.0 (there's no 1.1 for C/C++)
+ "199810=1.0"
+ # Fortran version 1.0
+ "199710=1.0"
+ )
-# check c compiler
-if(CMAKE_C_COMPILER_LOADED)
- # if these are set then do not try to find them again,
- # by avoiding any try_compiles for the flags
- if(OpenMP_C_FLAGS)
- unset(OpenMP_C_FLAG_CANDIDATES)
+ string(REGEX MATCHALL "${OpenMP_${LANG}_SPEC_DATE}=([0-9]+)\\.([0-9]+)" _version_match "${OpenMP_SPEC_DATE_MAP}")
+ if(NOT _version_match STREQUAL "")
+ set(OpenMP_${LANG}_VERSION_MAJOR ${CMAKE_MATCH_1})
+ set(OpenMP_${LANG}_VERSION_MINOR ${CMAKE_MATCH_2})
+ set(OpenMP_${LANG}_VERSION "${OpenMP_${LANG}_VERSION_MAJOR}.${OpenMP_${LANG}_VERSION_MINOR}")
else()
- _OPENMP_FLAG_CANDIDATES("C")
- include(${CMAKE_CURRENT_LIST_DIR}/CheckCSourceCompiles.cmake)
+ unset(OpenMP_${LANG}_VERSION_MAJOR)
+ unset(OpenMP_${LANG}_VERSION_MINOR)
+ unset(OpenMP_${LANG}_VERSION)
endif()
-
- foreach(FLAG IN LISTS OpenMP_C_FLAG_CANDIDATES)
- set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_REQUIRED_FLAGS "${FLAG}")
- unset(OpenMP_FLAG_DETECTED CACHE)
- if(NOT CMAKE_REQUIRED_QUIET)
- message(STATUS "Try OpenMP C flag = [${FLAG}]")
- endif()
- check_c_source_compiles("${OpenMP_C_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
- set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
- if(OpenMP_FLAG_DETECTED)
- set(OpenMP_C_FLAGS_INTERNAL "${FLAG}")
- break()
+ unset(_version_match)
+ unset(OpenMP_SPEC_DATE_MAP)
+endmacro()
+
+foreach(LANG IN ITEMS C CXX)
+ if(CMAKE_${LANG}_COMPILER_LOADED)
+ if(NOT DEFINED OpenMP_${LANG}_FLAGS OR "${OpenMP_${LANG}_FLAGS}" STREQUAL "NOTFOUND"
+ OR NOT DEFINED OpenMP_${LANG}_LIB_NAMES OR "${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND")
+ _OPENMP_GET_FLAGS("${LANG}" OpenMP_${LANG}_FLAGS_WORK OpenMP_${LANG}_LIB_NAMES_WORK)
endif()
- endforeach()
-
- set(OpenMP_C_FLAGS "${OpenMP_C_FLAGS_INTERNAL}"
- CACHE STRING "C compiler flags for OpenMP parallization")
- list(APPEND _OPENMP_REQUIRED_VARS OpenMP_C_FLAGS)
- unset(OpenMP_C_FLAG_CANDIDATES)
-
- if (NOT OpenMP_C_SPEC_DATE)
- _OPENMP_GET_SPEC_DATE("C" OpenMP_C_SPEC_DATE_INTERNAL)
- set(OpenMP_C_SPEC_DATE "${OpenMP_C_SPEC_DATE_INTERNAL}" CACHE
- INTERNAL "C compiler's OpenMP specification date")
+ set(OpenMP_${LANG}_FLAGS "${OpenMP_${LANG}_FLAGS_WORK}"
+ CACHE STRING "${LANG} compiler flags for OpenMP parallelization")
+ set(OpenMP_${LANG}_LIB_NAMES "${OpenMP_${LANG}_LIB_NAMES_WORK}"
+ CACHE STRING "${LANG} compiler libraries for OpenMP parallelization")
+ mark_as_advanced(OpenMP_${LANG}_FLAGS OpenMP_${LANG}_LIB_NAMES)
endif()
-endif()
+endforeach()
-# check cxx compiler
-if(CMAKE_CXX_COMPILER_LOADED)
- # if these are set then do not try to find them again,
- # by avoiding any try_compiles for the flags
- if(OpenMP_CXX_FLAGS)
- unset(OpenMP_CXX_FLAG_CANDIDATES)
- else()
- _OPENMP_FLAG_CANDIDATES("CXX")
- include(${CMAKE_CURRENT_LIST_DIR}/CheckCXXSourceCompiles.cmake)
+if(CMAKE_Fortran_COMPILER_LOADED)
+ if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND"
+ OR NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND"
+ OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE)
+ set(OpenMP_Fortran_INCLUDE_LINE "use omp_lib\n implicit none")
+ _OPENMP_GET_FLAGS("Fortran" OpenMP_Fortran_FLAGS_WORK OpenMP_Fortran_LIB_NAMES_WORK)
+ if(OpenMP_Fortran_FLAGS_WORK)
+ set(OpenMP_Fortran_HAVE_OMPLIB_MODULE TRUE CACHE BOOL INTERNAL "")
+ endif()
- # use the same source for CXX as C for now
- set(OpenMP_CXX_TEST_SOURCE ${OpenMP_C_TEST_SOURCE})
+ set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}"
+ CACHE STRING "Fortran compiler flags for OpenMP parallelization")
+ set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES_WORK}"
+ CACHE STRING "Fortran compiler libraries for OpenMP parallelization")
+ mark_as_advanced(OpenMP_Fortran_FLAGS OpenMP_Fortran_LIB_NAMES)
endif()
- foreach(FLAG IN LISTS OpenMP_CXX_FLAG_CANDIDATES)
- set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_REQUIRED_FLAGS "${FLAG}")
- unset(OpenMP_FLAG_DETECTED CACHE)
- if(NOT CMAKE_REQUIRED_QUIET)
- message(STATUS "Try OpenMP CXX flag = [${FLAG}]")
- endif()
- check_cxx_source_compiles("${OpenMP_CXX_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
- set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
- if(OpenMP_FLAG_DETECTED)
- set(OpenMP_CXX_FLAGS_INTERNAL "${FLAG}")
- break()
+ if(NOT DEFINED OpenMP_Fortran_FLAGS OR "${OpenMP_Fortran_FLAGS}" STREQUAL "NOTFOUND"
+ OR NOT DEFINED OpenMP_Fortran_LIB_NAMES OR "${OpenMP_Fortran_LIB_NAMES}" STREQUAL "NOTFOUND"
+ OR NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_HEADER)
+ set(OpenMP_Fortran_INCLUDE_LINE "implicit none\n include 'omp_lib.h'")
+ _OPENMP_GET_FLAGS("Fortran" OpenMP_Fortran_FLAGS_WORK OpenMP_Fortran_LIB_NAMES_WORK)
+ if(OpenMP_Fortran_FLAGS_WORK)
+ set(OpenMP_Fortran_HAVE_OMPLIB_HEADER TRUE CACHE BOOL INTERNAL "")
endif()
- endforeach()
- set(OpenMP_CXX_FLAGS "${OpenMP_CXX_FLAGS_INTERNAL}"
- CACHE STRING "C++ compiler flags for OpenMP parallization")
+ set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_WORK}"
+ CACHE STRING "Fortran compiler flags for OpenMP parallelization")
- list(APPEND _OPENMP_REQUIRED_VARS OpenMP_CXX_FLAGS)
- unset(OpenMP_CXX_FLAG_CANDIDATES)
-
- if (NOT OpenMP_CXX_SPEC_DATE)
- _OPENMP_GET_SPEC_DATE("CXX" OpenMP_CXX_SPEC_DATE_INTERNAL)
- set(OpenMP_CXX_SPEC_DATE "${OpenMP_CXX_SPEC_DATE_INTERNAL}" CACHE
- INTERNAL "C++ compiler's OpenMP specification date")
+ set(OpenMP_Fortran_LIB_NAMES "${OpenMP_Fortran_LIB_NAMES}"
+ CACHE STRING "Fortran compiler libraries for OpenMP parallelization")
endif()
-endif()
-# check Fortran compiler
-if(CMAKE_Fortran_COMPILER_LOADED)
- # if these are set then do not try to find them again,
- # by avoiding any try_compiles for the flags
- if(OpenMP_Fortran_FLAGS)
- unset(OpenMP_Fortran_FLAG_CANDIDATES)
+ if(OpenMP_Fortran_HAVE_OMPLIB_MODULE)
+ set(OpenMP_Fortran_INCLUDE_LINE "use omp_lib\n implicit none")
else()
- _OPENMP_FLAG_CANDIDATES("Fortran")
- include(${CMAKE_CURRENT_LIST_DIR}/CheckFortranSourceCompiles.cmake)
+ set(OpenMP_Fortran_INCLUDE_LINE "implicit none\n include 'omp_lib.h'")
endif()
+endif()
- foreach(FLAG IN LISTS OpenMP_Fortran_FLAG_CANDIDATES)
- set(SAFE_CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS}")
- set(CMAKE_REQUIRED_FLAGS "${FLAG}")
- unset(OpenMP_FLAG_DETECTED CACHE)
- if(NOT CMAKE_REQUIRED_QUIET)
- message(STATUS "Try OpenMP Fortran flag = [${FLAG}]")
- endif()
- check_fortran_source_compiles("${OpenMP_Fortran_TEST_SOURCE}" OpenMP_FLAG_DETECTED)
- set(CMAKE_REQUIRED_FLAGS "${SAFE_CMAKE_REQUIRED_FLAGS}")
- if(OpenMP_FLAG_DETECTED)
- set(OpenMP_Fortran_FLAGS_INTERNAL "${FLAG}")
- break()
- endif()
- endforeach()
+set(OPENMP_FOUND TRUE)
- set(OpenMP_Fortran_FLAGS "${OpenMP_Fortran_FLAGS_INTERNAL}"
- CACHE STRING "Fortran compiler flags for OpenMP parallization")
+foreach(LANG IN ITEMS C CXX Fortran)
+ if(CMAKE_${LANG}_COMPILER_LOADED)
+ if (NOT OpenMP_${LANG}_SPEC_DATE)
+ _OPENMP_GET_SPEC_DATE("${LANG}" OpenMP_${LANG}_SPEC_DATE_INTERNAL)
+ set(OpenMP_${LANG}_SPEC_DATE "${OpenMP_${LANG}_SPEC_DATE_INTERNAL}" CACHE
+ INTERNAL "${LANG} compiler's OpenMP specification date")
+ _OPENMP_SET_VERSION_BY_SPEC_DATE("${LANG}")
+ endif()
- list(APPEND _OPENMP_REQUIRED_VARS OpenMP_Fortran_FLAGS)
- unset(OpenMP_Fortran_FLAG_CANDIDATES)
+ include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
- if (NOT OpenMP_Fortran_SPEC_DATE)
- _OPENMP_GET_SPEC_DATE("Fortran" OpenMP_Fortran_SPEC_DATE_INTERNAL)
- set(OpenMP_Fortran_SPEC_DATE "${OpenMP_Fortran_SPEC_DATE_INTERNAL}" CACHE
- INTERNAL "Fortran compiler's OpenMP specification date")
- endif()
-endif()
+ set(OpenMP_${LANG}_FIND_QUIETLY ${OpenMP_FIND_QUIETLY})
+ set(OpenMP_${LANG}_FIND_REQUIRED ${OpenMP_FIND_REQUIRED})
+ set(OpenMP_${LANG}_FIND_VERSION ${OpenMP_FIND_VERSION})
+ set(OpenMP_${LANG}_FIND_VERSION_EXACT ${OpenMP_FIND_VERSION_EXACT})
-set(CMAKE_REQUIRED_QUIET ${CMAKE_REQUIRED_QUIET_SAVE})
-
-if(_OPENMP_REQUIRED_VARS)
- include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
+ set(_OPENMP_${LANG}_REQUIRED_VARS OpenMP_${LANG}_FLAGS)
+ if("${OpenMP_${LANG}_LIB_NAMES}" STREQUAL "NOTFOUND")
+ set(_OPENMP_${LANG}_REQUIRED_LIB_VARS OpenMP_${LANG}_LIB_NAMES)
+ else()
+ foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES)
+ list(APPEND _OPENMP_${LANG}_REQUIRED_LIB_VARS OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY)
+ endforeach()
+ endif()
- find_package_handle_standard_args(OpenMP
- REQUIRED_VARS ${_OPENMP_REQUIRED_VARS})
+ find_package_handle_standard_args(OpenMP_${LANG}
+ REQUIRED_VARS OpenMP_${LANG}_FLAGS ${_OPENMP_${LANG}_REQUIRED_LIB_VARS}
+ VERSION_VAR OpenMP_${LANG}_VERSION
+ )
+
+ if(OpenMP_${LANG}_FOUND)
+ set(OpenMP_${LANG}_LIBRARIES "")
+ foreach(_OPENMP_IMPLICIT_LIB IN LISTS OpenMP_${LANG}_LIB_NAMES)
+ list(APPEND OpenMP_${LANG}_LIBRARIES "${OpenMP_${_OPENMP_IMPLICIT_LIB}_LIBRARY}")
+ endforeach()
+
+ if(NOT TARGET OpenMP::OpenMP_${LANG})
+ add_library(OpenMP::OpenMP_${LANG} INTERFACE IMPORTED)
+ endif()
+ if(OpenMP_${LANG}_FLAGS)
+ if(CMAKE_HOST_WIN32)
+ separate_arguments(_OpenMP_${LANG}_OPTIONS WINDOWS_COMMAND "${OpenMP_${LANG}_FLAGS}")
+ else()
+ separate_arguments(_OpenMP_${LANG}_OPTIONS UNIX_COMMAND "${OpenMP_${LANG}_FLAGS}")
+ endif()
+ set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
+ INTERFACE_COMPILE_OPTIONS "${_OpenMP_${LANG}_OPTIONS}")
+ unset(_OpenMP_${LANG}_OPTIONS)
+ endif()
+ if(OpenMP_${LANG}_LIBRARIES)
+ set_property(TARGET OpenMP::OpenMP_${LANG} PROPERTY
+ INTERFACE_LINK_LIBRARIES "${OpenMP_${LANG}_LIBRARIES}")
+ endif()
+ else()
+ set(OPENMP_FOUND FALSE)
+ endif()
+ endif()
+endforeach()
- mark_as_advanced(${_OPENMP_REQUIRED_VARS})
+if(CMAKE_Fortran_COMPILER_LOADED AND OpenMP_Fortran_FOUND)
+ if(NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_MODULE)
+ set(OpenMP_Fortran_HAVE_OMPLIB_MODULE FALSE CACHE BOOL INTERNAL "")
+ endif()
+ if(NOT DEFINED OpenMP_Fortran_HAVE_OMPLIB_HEADER)
+ set(OpenMP_Fortran_HAVE_OMPLIB_HEADER FALSE CACHE BOOL INTERNAL "")
+ endif()
+endif()
- unset(_OPENMP_REQUIRED_VARS)
-else()
- message(SEND_ERROR "FindOpenMP requires C or CXX language to be enabled")
+if(NOT ( CMAKE_C_COMPILER_LOADED OR CMAKE_CXX_COMPILER_LOADED OR CMAKE_Fortran_COMPILER_LOADED ))
+ message(SEND_ERROR "FindOpenMP requires the C, CXX or Fortran languages to be enabled")
endif()
-unset(OpenMP_C_TEST_SOURCE)
-unset(OpenMP_CXX_TEST_SOURCE)
+unset(OpenMP_C_CXX_TEST_SOURCE)
unset(OpenMP_Fortran_TEST_SOURCE)
unset(OpenMP_C_CXX_CHECK_VERSION_SOURCE)
unset(OpenMP_Fortran_CHECK_VERSION_SOURCE)
+unset(OpenMP_Fortran_INCLUDE_LINE)
+
+cmake_policy(POP)
diff --git a/Modules/FindwxWidgets.cmake b/Modules/FindwxWidgets.cmake
index bc906e5..af4daf0 100644
--- a/Modules/FindwxWidgets.cmake
+++ b/Modules/FindwxWidgets.cmake
@@ -893,6 +893,28 @@ else()
endif()
endif()
+# Check that all libraries are present, as wx-config does not check it
+set(_wx_lib_missing "")
+foreach(_wx_lib_ ${wxWidgets_LIBRARIES})
+ if("${_wx_lib_}" MATCHES "^-l(.*)")
+ set(_wx_lib_name "${CMAKE_MATCH_1}")
+ unset(_wx_lib_found CACHE)
+ find_library(_wx_lib_found NAMES ${_wx_lib_name} HINTS ${wxWidgets_LIBRARY_DIRS})
+ if(_wx_lib_found STREQUAL _wx_lib_found-NOTFOUND)
+ list(APPEND _wx_lib_missing ${_wx_lib_name})
+ endif()
+ unset(_wx_lib_found CACHE)
+ endif()
+endforeach()
+
+if (_wx_lib_missing)
+ string(REPLACE ";" " " _wx_lib_missing "${_wx_lib_missing}")
+ DBG_MSG_V("wxWidgets not found due to following missing libraries: ${_wx_lib_missing}")
+ set(wxWidgets_FOUND FALSE)
+ unset(wxWidgets_LIBRARIES)
+endif()
+unset(_wx_lib_missing)
+
# Check if a specfic version was requested by find_package().
if(wxWidgets_FOUND)
find_file(_filename wx/version.h PATHS ${wxWidgets_INCLUDE_DIRS} NO_DEFAULT_PATH)
diff --git a/Modules/GNUInstallDirs.cmake b/Modules/GNUInstallDirs.cmake
index 9599f27..64bd09e 100644
--- a/Modules/GNUInstallDirs.cmake
+++ b/Modules/GNUInstallDirs.cmake
@@ -45,6 +45,8 @@
# modifiable architecture-independent data (``com``)
# ``LOCALSTATEDIR``
# modifiable single-machine data (``var``)
+# ``RUNSTATEDIR``
+# run-time variable data (``LOCALSTATEDIR/run``)
# ``LIBDIR``
# object code libraries (``lib`` or ``lib64``
# or ``lib/<multiarch-tuple>`` on Debian)
@@ -75,10 +77,10 @@
#
# ``/``
#
-# For ``<dir>`` other than the ``SYSCONFDIR`` and ``LOCALSTATEDIR``,
-# the value of ``CMAKE_INSTALL_<dir>`` is prefixed with ``usr/`` if
-# it is not user-specified as an absolute path. For example, the
-# ``INCLUDEDIR`` value ``include`` becomes ``usr/include``.
+# For ``<dir>`` other than the ``SYSCONFDIR``, ``LOCALSTATEDIR`` and
+# ``RUNSTATEDIR``, the value of ``CMAKE_INSTALL_<dir>`` is prefixed
+# with ``usr/`` if it is not user-specified as an absolute path.
+# For example, the ``INCLUDEDIR`` value ``include`` becomes ``usr/include``.
# This is required by the `GNU Coding Standards`_, which state:
#
# When building the complete GNU system, the prefix will be empty
@@ -86,20 +88,21 @@
#
# ``/usr``
#
-# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the
-# ``CMAKE_INSTALL_FULL_<dir>`` is computed by prepending just ``/``
-# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified
-# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc``
-# becomes ``/etc``. This is required by the `GNU Coding Standards`_.
+# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
+# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
+# prepending just ``/`` to the value of ``CMAKE_INSTALL_<dir>``
+# if it is not user-specified as an absolute path.
+# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc``.
+# This is required by the `GNU Coding Standards`_.
#
# ``/opt/...``
#
-# For ``<dir>`` equal to ``SYSCONFDIR`` or ``LOCALSTATEDIR``, the
-# ``CMAKE_INSTALL_FULL_<dir>`` is computed by *appending* the prefix
-# to the value of ``CMAKE_INSTALL_<dir>`` if it is not user-specified
-# as an absolute path. For example, the ``SYSCONFDIR`` value ``etc``
-# becomes ``/etc/opt/...``. This is defined by the
-# `Filesystem Hierarchy Standard`_.
+# For ``<dir>`` equal to ``SYSCONFDIR``, ``LOCALSTATEDIR`` or
+# ``RUNSTATEDIR``, the ``CMAKE_INSTALL_FULL_<dir>`` is computed by
+# *appending* the prefix to the value of ``CMAKE_INSTALL_<dir>``
+# if it is not user-specified as an absolute path.
+# For example, the ``SYSCONFDIR`` value ``etc`` becomes ``/etc/opt/...``.
+# This is defined by the `Filesystem Hierarchy Standard`_.
#
# .. _`Filesystem Hierarchy Standard`: https://refspecs.linuxfoundation.org/FHS_3.0/fhs/index.html
#
@@ -287,6 +290,9 @@ _GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_LOCALEDIR "${CMAKE_INSTALL_DAT
_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc/${PROJECT_NAME}"
"Documentation root (DATAROOTDIR/doc/PROJECT_NAME)")
+_GNUInstallDirs_cache_path_fallback(CMAKE_INSTALL_RUNSTATEDIR "${CMAKE_INSTALL_LOCALSTATEDIR}/run"
+ "Run-time variable data (LOCALSTATEDIR/run)")
+
#-----------------------------------------------------------------------------
mark_as_advanced(
@@ -296,6 +302,7 @@ mark_as_advanced(
CMAKE_INSTALL_SYSCONFDIR
CMAKE_INSTALL_SHAREDSTATEDIR
CMAKE_INSTALL_LOCALSTATEDIR
+ CMAKE_INSTALL_RUNSTATEDIR
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_INCLUDEDIR
CMAKE_INSTALL_OLDINCLUDEDIR
@@ -314,7 +321,7 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var)
# - CMAKE_INSTALL_PREFIX == /usr
# - CMAKE_INSTALL_PREFIX == /opt/...
if("${CMAKE_INSTALL_PREFIX}" STREQUAL "/")
- if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR")
+ if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR")
set(${absvar} "/${${var}}")
else()
if (NOT "${${var}}" MATCHES "^usr/")
@@ -323,13 +330,13 @@ macro(GNUInstallDirs_get_absolute_install_dir absvar var)
set(${absvar} "/${${var}}")
endif()
elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/usr/?$")
- if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR")
+ if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR")
set(${absvar} "/${${var}}")
else()
set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
endif()
elseif("${CMAKE_INSTALL_PREFIX}" MATCHES "^/opt/.*")
- if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR")
+ if("${dir}" STREQUAL "SYSCONFDIR" OR "${dir}" STREQUAL "LOCALSTATEDIR" OR "${dir}" STREQUAL "RUNSTATEDIR")
set(${absvar} "/${${var}}${CMAKE_INSTALL_PREFIX}")
else()
set(${absvar} "${CMAKE_INSTALL_PREFIX}/${${var}}")
@@ -351,6 +358,7 @@ foreach(dir
SYSCONFDIR
SHAREDSTATEDIR
LOCALSTATEDIR
+ RUNSTATEDIR
LIBDIR
INCLUDEDIR
OLDINCLUDEDIR
diff --git a/Modules/Platform/Linux-GNU.cmake b/Modules/Platform/Linux-GNU.cmake
index 6878254..ce30a26 100644
--- a/Modules/Platform/Linux-GNU.cmake
+++ b/Modules/Platform/Linux-GNU.cmake
@@ -12,4 +12,5 @@ macro(__linux_compiler_gnu lang)
# We pass this for historical reasons. Projects may have
# executables that use dlopen but do not set ENABLE_EXPORTS.
set(CMAKE_SHARED_LIBRARY_LINK_${lang}_FLAGS "-rdynamic")
+ set(CMAKE_${lang}_COMPILER_PREDEFINES_COMMAND "${CMAKE_${lang}_COMPILER}" "-dM" "-E" "-c" "${CMAKE_ROOT}/Modules/CMakeCXXCompilerABI.cpp")
endmacro()
diff --git a/Modules/UseJava.cmake b/Modules/UseJava.cmake
index 93255ae..8ae3720 100644
--- a/Modules/UseJava.cmake
+++ b/Modules/UseJava.cmake
@@ -244,21 +244,23 @@
#
# ::
#
-# install_jar_exports(TARGETS jar1 [jar2 ...]
-# FILE export_filename
-# DESTINATION destination [COMPONENT component])
+# install_jar_exports(TARGETS jars...
+# [NAMESPACE <namespace>]
+# FILE <filename>
+# DESTINATION <dir> [COMPONENT <component>])
#
-# This command installs a target export file export_filename for the named jar
-# targets to the given DESTINATION. Its function is similar to that of
-# install(EXPORTS).
+# This command installs a target export file ``<filename>`` for the named jar
+# targets to the given ``DESTINATION``. Its function is similar to that of
+# :command:`install(EXPORTS ...)`.
#
# ::
#
-# export_jars(TARGETS jar1 [jar2 ...]
-# FILE export_filename)
+# export_jars(TARGETS jars...
+# [NAMESPACE <namespace>]
+# FILE <filename>)
#
-# This command writes a target export file export_filename for the named jar
-# targets. Its function is similar to that of export().
+# This command writes a target export file ``<filename>`` for the named jar
+# targets. Its function is similar to that of :command:`export(...)`.
#
# ::
#
@@ -424,10 +426,12 @@ endfunction()
function(__java_export_jar VAR TARGET PATH)
get_target_property(_jarpath ${TARGET} JAR_FILE)
get_filename_component(_jarname ${_jarpath} NAME)
+ set(_target "${_jar_NAMESPACE}${TARGET}")
__java_lcat(${VAR}
- "# Create imported target ${TARGET}"
- "add_custom_target(${TARGET})"
- "set_target_properties(${TARGET} PROPERTIES"
+ "# Create imported target ${_target}"
+ "add_library(${_target} IMPORTED STATIC)"
+ "set_target_properties(${_target} PROPERTIES"
+ " IMPORTED_LOCATION \"${PATH}/${_jarname}\""
" JAR_FILE \"${PATH}/${_jarname}\")"
""
)
@@ -1341,7 +1345,7 @@ function(export_jars)
# Parse and validate arguments
cmake_parse_arguments(_export_jars
""
- "FILE"
+ "FILE;NAMESPACE"
"TARGETS"
${ARGN}
)
@@ -1351,6 +1355,7 @@ function(export_jars)
if (NOT _export_jars_TARGETS)
message(SEND_ERROR "export_jars: TARGETS must be specified.")
endif()
+ set(_jar_NAMESPACE "${_export_jars_NAMESPACE}")
# Set content of generated exports file
string(REPLACE ";" " " __targets__ "${_export_jars_TARGETS}")
@@ -1373,7 +1378,7 @@ function(install_jar_exports)
# Parse and validate arguments
cmake_parse_arguments(_install_jar_exports
""
- "FILE;DESTINATION;COMPONENT"
+ "FILE;DESTINATION;COMPONENT;NAMESPACE"
"TARGETS"
${ARGN}
)
@@ -1386,6 +1391,7 @@ function(install_jar_exports)
if (NOT _install_jar_exports_TARGETS)
message(SEND_ERROR "install_jar_exports: TARGETS must be specified.")
endif()
+ set(_jar_NAMESPACE "${_install_jar_exports_NAMESPACE}")
if (_install_jar_exports_COMPONENT)
set (_COMPONENT COMPONENT ${_install_jar_exports_COMPONENT})