summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/CPack.cmake24
-rw-r--r--Modules/CPackComponent.cmake87
-rw-r--r--Modules/CheckFortranSourceCompiles.cmake6
-rw-r--r--Modules/CheckFortranSourceRuns.cmake6
-rw-r--r--Modules/CheckTypeSize.c.in8
-rw-r--r--Modules/Compiler/XL-Fortran.cmake1
-rw-r--r--Modules/ExternalProject.cmake9
-rw-r--r--Modules/FetchContent.cmake7
-rw-r--r--Modules/FindHDF5.cmake104
-rw-r--r--Modules/FindOpenCL.cmake6
-rw-r--r--Modules/FindSWIG.cmake71
-rw-r--r--Modules/FortranCInterface/CMakeLists.txt4
-rw-r--r--Modules/FortranCInterface/Detect.cmake10
-rw-r--r--Modules/GoogleTestAddTests.cmake45
-rw-r--r--Modules/Internal/CPack/CPackNuGet.cmake16
-rw-r--r--Modules/Internal/CPack/CPackRPM.cmake18
-rw-r--r--Modules/UseSWIG.cmake20
17 files changed, 303 insertions, 139 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake
index baf7e47..6234b9d 100644
--- a/Modules/CPack.cmake
+++ b/Modules/CPack.cmake
@@ -5,7 +5,7 @@
CPack
-----
-Configure the binary and source package installers.
+Configure generators for binary installers and source packages.
Introduction
^^^^^^^^^^^^
@@ -19,13 +19,17 @@ Depending on the CMake generator, the CPack module may also add two new build
targets, ``package`` and ``package_source``. See the `packaging targets`_
section below for details.
-The generated binary installers contain everything installed via CMake's
-:command:`install` command (and the deprecated commands :command:`install_files`,
-:command:`install_programs`, and :command:`install_targets`).
-For certain kinds of binary installers (including the graphical
-installers on macOS and Windows), CPack generates installers that
-allow users to select individual application components to install.
-See :module:`CPackComponent` module for further details.
+The generated binary installers will contain all files that have been installed
+via CMake's :command:`install` command (and the deprecated commands
+:command:`install_files`, :command:`install_programs`, and
+:command:`install_targets`). Certain kinds of binary installers can be
+configured such that users can select individual application components to
+install. See the :module:`CPackComponent` module for further details.
+
+Source packages (configured through ``CPackSourceConfig.cmake`` and generated
+by the :cpack_gen:`CPack Archive Generator`) will contain all source files in
+the project directory except those specified in
+:variable:`CPACK_SOURCE_IGNORE_FILES`.
CPack Generators
^^^^^^^^^^^^^^^^
@@ -38,10 +42,6 @@ generator. In a :variable:`CPACK_PROJECT_CONFIG_FILE`,
:variable:`CPACK_GENERATOR` is a *string naming a single generator*. If you
need per-cpack-generator logic to control *other* cpack settings, then you
need a :variable:`CPACK_PROJECT_CONFIG_FILE`.
-
-The CMake source tree itself contains a :variable:`CPACK_PROJECT_CONFIG_FILE`.
-See the top level file ``CMakeCPackOptions.cmake.in`` for an example.
-
If set, the :variable:`CPACK_PROJECT_CONFIG_FILE` is included automatically
on a per-generator basis. It only need contain overrides.
diff --git a/Modules/CPackComponent.cmake b/Modules/CPackComponent.cmake
index 211d767..1f8c38c 100644
--- a/Modules/CPackComponent.cmake
+++ b/Modules/CPackComponent.cmake
@@ -5,29 +5,34 @@
CPackComponent
--------------
-Build binary and source package installers
+Configure components for binary installers and source packages.
-Variables concerning CPack Components
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+.. only:: html
-The CPackComponent module is the module which handles the component
-part of CPack. See CPack module for general information about CPack.
+ .. contents::
-For certain kinds of binary installers (including the graphical
-installers on macOS and Windows), CPack generates installers that
-allow users to select individual application components to install.
-The contents of each of the components are identified by the COMPONENT
-argument of CMake's INSTALL command. These components can be
+Introduction
+^^^^^^^^^^^^
+
+This module is automatically included by :module:`CPack`.
+
+Certain binary installers (especially the graphical installers) generated
+by CPack allow users to select individual application *components* to install.
+This module allows developers to configure the packaging of such components.
+
+Contents is assigned to components by the ``COMPONENT``
+argument of CMake's :command:`install` command. Components can be
annotated with user-friendly names and descriptions, inter-component
dependencies, etc., and grouped in various ways to customize the
-resulting installer. See the cpack_add_* commands, described below,
-for more information about component-specific installations.
+resulting installer, using the commands described below.
+
+To specify different groupings for different CPack generators use
+a CPACK_PROJECT_CONFIG_FILE.
-Component-specific installation allows users to select specific sets
-of components to install during the install process. Installation
-components are identified by the COMPONENT argument of CMake's INSTALL
-commands, and should be further described by the following CPack
-commands:
+Variables
+^^^^^^^^^
+
+The following variables influence the component-specific packaging:
.. variable:: CPACK_COMPONENTS_ALL
@@ -61,16 +66,14 @@ commands:
Specify how components are grouped for multi-package component-aware CPack
generators.
- Some generators like RPM or ARCHIVE family (TGZ, ZIP, ...) generates
- several packages files when asked for component packaging. They group
- the component differently depending on the value of this variable:
-
- * ONE_PER_GROUP (default): creates one package file per component group
- * ALL_COMPONENTS_IN_ONE : creates a single package with all (requested) components
- * IGNORE : creates one package per component, i.e. IGNORE component group
+ Some generators like RPM or ARCHIVE (TGZ, ZIP, ...) may generate
+ several packages files when there are components, depending
+ on the value of this variable:
- One can specify different grouping for different CPack generator by
- using a CPACK_PROJECT_CONFIG_FILE.
+ * ONE_PER_GROUP (default): create one package per component group
+ * IGNORE : create one package per component (ignore the groups)
+ * ALL_COMPONENTS_IN_ONE : create a single package with all requested
+ components
.. variable:: CPACK_COMPONENT_<compName>_DISPLAY_NAME
@@ -100,10 +103,15 @@ commands:
True if this component is not selected to be installed by default.
+Commands
+^^^^^^^^
+
+Add component
+"""""""""""""
+
.. command:: cpack_add_component
-Describes a CPack installation
-component named by the COMPONENT argument to a CMake INSTALL command.
+Describe an installation component.
::
@@ -118,13 +126,11 @@ component named by the COMPONENT argument to a CMake INSTALL command.
[ARCHIVE_FILE filename]
[PLIST filename])
-
-
-The cmake_add_component command describes an installation component,
-which the user can opt to install or remove as part of the graphical
-installation process. compname is the name of the component, as
-provided to the COMPONENT argument of one or more CMake INSTALL
-commands.
+``compname`` is the name of an installation component, as defined by the
+``COMPONENT`` argument of one or more CMake :command:`install` commands.
+With the ``cpack_add_component`` command one can set a name, a description,
+and other attributes of an installation component.
+One can also assign a component to a component group.
DISPLAY_NAME is the displayed name of the component, used in graphical
installers to display the component name. This value can be any
@@ -177,6 +183,9 @@ the component. See cpack_configure_downloads for more information.
PLIST gives a filename that is passed to pkgbuild with the
``--component-plist`` argument when using the productbuild generator.
+Add component group
+"""""""""""""""""""
+
.. command:: cpack_add_component_group
Describes a group of related CPack installation components.
@@ -225,6 +234,9 @@ single entry.
BOLD_TITLE indicates that the group title should appear in bold, to
call the user's attention to the group.
+Add installation type
+"""""""""""""""""""""
+
.. command:: cpack_add_install_type
Add a new installation type containing
@@ -249,6 +261,9 @@ DISPLAY_NAME is the displayed name of the install type, which will
typically show up in a drop-down box within a graphical installer.
This value can be any string.
+Configure downloads
+"""""""""""""""""""
+
.. command:: cpack_configure_downloads
Configure CPack to download
@@ -281,8 +296,6 @@ requires the ZipDLL plug-in for NSIS, available at:
http://nsis.sourceforge.net/ZipDLL_plug-in
-
-
On macOS, installers that download components on-the-fly can only
be built and installed on system using macOS 10.5 or later.
diff --git a/Modules/CheckFortranSourceCompiles.cmake b/Modules/CheckFortranSourceCompiles.cmake
index f0fde8d..3354bfb 100644
--- a/Modules/CheckFortranSourceCompiles.cmake
+++ b/Modules/CheckFortranSourceCompiles.cmake
@@ -103,8 +103,6 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
if(NOT _SRC_EXT)
set(_SRC_EXT F)
endif()
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LINK_OPTIONS)
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
@@ -132,10 +130,10 @@ macro(CHECK_Fortran_SOURCE_COMPILES SOURCE VAR)
try_compile(${VAR}
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
OUTPUT_VARIABLE OUTPUT)
diff --git a/Modules/CheckFortranSourceRuns.cmake b/Modules/CheckFortranSourceRuns.cmake
index a3e5d5d..f858b84 100644
--- a/Modules/CheckFortranSourceRuns.cmake
+++ b/Modules/CheckFortranSourceRuns.cmake
@@ -98,8 +98,6 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
if(NOT _SRC_EXT)
set(_SRC_EXT F90)
endif()
- set(MACRO_CHECK_FUNCTION_DEFINITIONS
- "-D${VAR} ${CMAKE_REQUIRED_FLAGS}")
if(CMAKE_REQUIRED_LINK_OPTIONS)
set(CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS
LINK_OPTIONS ${CMAKE_REQUIRED_LINK_OPTIONS})
@@ -127,10 +125,10 @@ macro(CHECK_Fortran_SOURCE_RUNS SOURCE VAR)
try_run(${VAR}_EXITCODE ${VAR}_COMPILED
${CMAKE_BINARY_DIR}
${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/src.${_SRC_EXT}
- COMPILE_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS}
+ COMPILE_DEFINITIONS -D${VAR} ${CMAKE_REQUIRED_DEFINITIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LINK_OPTIONS}
${CHECK_Fortran_SOURCE_COMPILES_ADD_LIBRARIES}
- CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${MACRO_CHECK_FUNCTION_DEFINITIONS}
+ CMAKE_FLAGS -DCOMPILE_DEFINITIONS:STRING=${CMAKE_REQUIRED_FLAGS}
-DCMAKE_SKIP_RPATH:BOOL=${CMAKE_SKIP_RPATH}
"${CHECK_Fortran_SOURCE_COMPILES_ADD_INCLUDES}"
COMPILE_OUTPUT_VARIABLE OUTPUT
diff --git a/Modules/CheckTypeSize.c.in b/Modules/CheckTypeSize.c.in
index 82035a3..fb93073 100644
--- a/Modules/CheckTypeSize.c.in
+++ b/Modules/CheckTypeSize.c.in
@@ -5,10 +5,14 @@
# define KEY '_','_','i','3','8','6'
#elif defined(__x86_64)
# define KEY '_','_','x','8','6','_','6','4'
-#elif defined(__ppc__)
-# define KEY '_','_','p','p','c','_','_'
+#elif defined(__PPC64__)
+# define KEY '_','_','P','P','C','6','4','_','_'
#elif defined(__ppc64__)
# define KEY '_','_','p','p','c','6','4','_','_'
+#elif defined(__PPC__)
+# define KEY '_','_','P','P','C','_','_'
+#elif defined(__ppc__)
+# define KEY '_','_','p','p','c','_','_'
#elif defined(__aarch64__)
# define KEY '_','_','a','a','r','c','h','6','4','_','_'
#elif defined(__ARM_ARCH_7A__)
diff --git a/Modules/Compiler/XL-Fortran.cmake b/Modules/Compiler/XL-Fortran.cmake
index 1683dff..e01ec8e 100644
--- a/Modules/Compiler/XL-Fortran.cmake
+++ b/Modules/Compiler/XL-Fortran.cmake
@@ -8,6 +8,7 @@ set(CMAKE_Fortran_FORMAT_FIXED_FLAG "-qfixed") # [=<right_margin>]
set(CMAKE_Fortran_FORMAT_FREE_FLAG "-qfree") # [=f90|ibm]
set(CMAKE_Fortran_MODDIR_FLAG "-qmoddir=")
+set(CMAKE_Fortran_MODDIR_INCLUDE_FLAG "-I") # -qmoddir= does not affect search path
set(CMAKE_Fortran_DEFINE_FLAG "-WF,-D")
diff --git a/Modules/ExternalProject.cmake b/Modules/ExternalProject.cmake
index 5bac0d8..326ee06 100644
--- a/Modules/ExternalProject.cmake
+++ b/Modules/ExternalProject.cmake
@@ -9,8 +9,11 @@ ExternalProject
.. contents::
+Commands
+^^^^^^^^
+
External Project Definition
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+"""""""""""""""""""""""""""
.. command:: ExternalProject_Add
@@ -665,7 +668,7 @@ External Project Definition
automatic substitutions that are supported for some options.
Obtaining Project Properties
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+""""""""""""""""""""""""""""
.. command:: ExternalProject_Get_Property
@@ -686,7 +689,7 @@ Obtaining Project Properties
message("Source dir of myExtProj = ${SOURCE_DIR}")
Explicit Step Management
-^^^^^^^^^^^^^^^^^^^^^^^^
+""""""""""""""""""""""""
The ``ExternalProject_Add()`` function on its own is often sufficient for
incorporating an external project into the main build. Certain scenarios
diff --git a/Modules/FetchContent.cmake b/Modules/FetchContent.cmake
index f3e1b51..0e98f49 100644
--- a/Modules/FetchContent.cmake
+++ b/Modules/FetchContent.cmake
@@ -76,8 +76,11 @@ sometimes useful as part of implementing some higher level feature or to
populate some content in CMake's script mode.
+Commands
+^^^^^^^^
+
Declaring Content Details
-^^^^^^^^^^^^^^^^^^^^^^^^^
+"""""""""""""""""""""""""
.. command:: FetchContent_Declare
@@ -130,7 +133,7 @@ Declaring Content Details
)
Populating The Content
-^^^^^^^^^^^^^^^^^^^^^^
+""""""""""""""""""""""
For most common scenarios, population means making content available to the
main build according to previously declared details for that dependency.
diff --git a/Modules/FindHDF5.cmake b/Modules/FindHDF5.cmake
index b488418..c1888a4 100644
--- a/Modules/FindHDF5.cmake
+++ b/Modules/FindHDF5.cmake
@@ -19,9 +19,12 @@ The module will optionally accept the ``COMPONENTS`` argument. If no
``COMPONENTS`` are specified, then the find module will default to finding
only the ``HDF5`` C library. If one or more ``COMPONENTS`` are specified, the
module will attempt to find the language bindings for the specified
-components. The only valid components are ``C``, ``CXX``, ``Fortran``, ``HL``,
-and ``Fortran_HL``. If the ``COMPONENTS`` argument is not given, the module will
+components. The valid components are ``C``, ``CXX``, ``Fortran``, ``HL``.
+``HL`` refers to the "high-level" HDF5 functions for C and Fortran.
+If the ``COMPONENTS`` argument is not given, the module will
attempt to find only the C bindings.
+For example, to use Fortran HDF5 and HDF5-HL functions, do:
+``find_package(HDF5 COMPONENTS Fortran HL)``.
This module will read the variable
``HDF5_USE_STATIC_LIBRARIES`` to determine whether or not to prefer a
@@ -29,11 +32,6 @@ static link to a dynamic link for ``HDF5`` and all of it's dependencies.
To use this feature, make sure that the ``HDF5_USE_STATIC_LIBRARIES``
variable is set before the call to find_package.
-To provide the module with a hint about where to find your ``HDF5``
-installation, you can set the environment variable ``HDF5_ROOT``. The
-Find module will then look in this path when searching for ``HDF5``
-executables, paths, and libraries.
-
Both the serial and parallel ``HDF5`` wrappers are considered and the first
directory to contain either one will be used. In the event that both appear
in the same directory the serial version is preferentially selected. This
@@ -115,10 +113,10 @@ also be defined. With all components enabled, the following variables will be d
Hints
^^^^^
-The following variable can be set to guide the search for HDF5 libraries and includes:
+The following variables can be set to guide the search for HDF5 libraries and includes:
-``HDF5_ROOT``
- Specify the path to the HDF5 installation to use.
+``HDF5_PREFER_PARALLEL``
+ set ``true`` to prefer parallel HDF5 (by default, serial is preferred)
``HDF5_FIND_DEBUG``
Set ``true`` to get extra debugging output.
@@ -343,35 +341,46 @@ macro( _HDF5_invoke_compiler language output return_value version is_parallel)
elseif("${language}" STREQUAL "Fortran")
set(test_file ${scratch_dir}/cmake_hdf5_test.f90)
endif()
+ # Verify that the compiler wrapper can actually compile: sometimes the compiler
+ # wrapper exists, but not the compiler. E.g. Miniconda / Anaconda Python
execute_process(
- COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
- OUTPUT_VARIABLE ${output}
- ERROR_VARIABLE ${output}
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} ${test_file}
RESULT_VARIABLE ${return_value}
)
if(NOT ${${return_value}} EQUAL 0)
- message(STATUS
- "Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
- endif()
- execute_process(
- COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig
- OUTPUT_VARIABLE config_output
- ERROR_VARIABLE config_output
- RESULT_VARIABLE config_return
- )
- if(NOT ${return_value} EQUAL 0)
- message( STATUS
- "Unable to determine HDF5 ${language} version from HDF5 wrapper.")
- endif()
- string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}")
- if(version_match)
- string(REPLACE "HDF5 Version: " "" ${version} "${version_match}")
- string(REPLACE "-patch" "." ${version} "${${version}}")
- endif()
- if(config_output MATCHES "Parallel HDF5: yes")
- set(${is_parallel} TRUE)
+ message(STATUS
+ "HDF5 ${language} compiler wrapper is unable to compile a minimal HDF5 program.")
else()
- set(${is_parallel} FALSE)
+ execute_process(
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -show ${lib_type_args} ${test_file}
+ OUTPUT_VARIABLE ${output}
+ ERROR_VARIABLE ${output}
+ RESULT_VARIABLE ${return_value}
+ )
+ if(NOT ${${return_value}} EQUAL 0)
+ message(STATUS
+ "Unable to determine HDF5 ${language} flags from HDF5 wrapper.")
+ endif()
+ execute_process(
+ COMMAND ${HDF5_${language}_COMPILER_EXECUTABLE} -showconfig
+ OUTPUT_VARIABLE config_output
+ ERROR_VARIABLE config_output
+ RESULT_VARIABLE config_return
+ )
+ if(NOT ${return_value} EQUAL 0)
+ message( STATUS
+ "Unable to determine HDF5 ${language} version from HDF5 wrapper.")
+ endif()
+ string(REGEX MATCH "HDF5 Version: ([a-zA-Z0-9\\.\\-]*)" version_match "${config_output}")
+ if(version_match)
+ string(REPLACE "HDF5 Version: " "" ${version} "${version_match}")
+ string(REPLACE "-patch" "." ${version} "${${version}}")
+ endif()
+ if(config_output MATCHES "Parallel HDF5: yes")
+ set(${is_parallel} TRUE)
+ else()
+ set(${is_parallel} FALSE)
+ endif()
endif()
endmacro()
@@ -769,6 +778,17 @@ if( NOT HDF5_FOUND )
set(HDF5_Fortran_LIBRARY_NAMES hdf5_fortran ${HDF5_C_LIBRARY_NAMES})
set(HDF5_Fortran_HL_LIBRARY_NAMES hdf5hl_fortran ${HDF5_C_HL_LIBRARY_NAMES} ${HDF5_Fortran_LIBRARY_NAMES})
+ # suffixes as seen on Linux, MSYS2, ...
+ set(_lib_suffixes hdf5)
+ if(NOT HDF5_PREFER_PARALLEL)
+ list(APPEND _lib_suffixes hdf5/serial)
+ endif()
+ if(HDF5_USE_STATIC_LIBRARIES)
+ set(_inc_suffixes include/static)
+ else()
+ set(_inc_suffixes include/shared)
+ endif()
+
foreach(__lang IN LISTS HDF5_LANGUAGE_BINDINGS)
# find the HDF5 include directories
if("${__lang}" STREQUAL "Fortran")
@@ -782,7 +802,7 @@ if( NOT HDF5_FOUND )
find_path(HDF5_${__lang}_INCLUDE_DIR ${HDF5_INCLUDE_FILENAME}
HINTS ${HDF5_ROOT}
PATHS $ENV{HOME}/.local/include
- PATH_SUFFIXES include Include
+ PATH_SUFFIXES include Include ${_inc_suffixes} ${_lib_suffixes}
${_HDF5_SEARCH_OPTS}
)
mark_as_advanced(HDF5_${__lang}_INCLUDE_DIR)
@@ -811,14 +831,15 @@ if( NOT HDF5_FOUND )
endif()
find_library(HDF5_${LIB}_LIBRARY_DEBUG
NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
- HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib
+ HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes}
${_HDF5_SEARCH_OPTS}
)
- find_library( HDF5_${LIB}_LIBRARY_RELEASE
+ find_library(HDF5_${LIB}_LIBRARY_RELEASE
NAMES ${THIS_LIBRARY_SEARCH_RELEASE}
- HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib
+ HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes}
${_HDF5_SEARCH_OPTS}
)
+
select_library_configurations( HDF5_${LIB} )
list(APPEND HDF5_${__lang}_LIBRARIES ${HDF5_${LIB}_LIBRARY})
endforeach()
@@ -848,14 +869,15 @@ if( NOT HDF5_FOUND )
endif()
find_library(HDF5_${LIB}_LIBRARY_DEBUG
NAMES ${THIS_LIBRARY_SEARCH_DEBUG}
- HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib
+ HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes}
${_HDF5_SEARCH_OPTS}
)
- find_library( HDF5_${LIB}_LIBRARY_RELEASE
+ find_library(HDF5_${LIB}_LIBRARY_RELEASE
NAMES ${THIS_LIBRARY_SEARCH_RELEASE}
- HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib
+ HINTS ${HDF5_ROOT} PATH_SUFFIXES lib Lib ${_lib_suffixes}
${_HDF5_SEARCH_OPTS}
)
+
select_library_configurations( HDF5_${LIB} )
list(APPEND HDF5_${__lang}_HL_LIBRARIES ${HDF5_${LIB}_LIBRARY})
endforeach()
diff --git a/Modules/FindOpenCL.cmake b/Modules/FindOpenCL.cmake
index 9891724..34a203e 100644
--- a/Modules/FindOpenCL.cmake
+++ b/Modules/FindOpenCL.cmake
@@ -78,6 +78,8 @@ find_path(OpenCL_INCLUDE_DIR
ENV CUDA_PATH
ENV ATISTREAMSDKROOT
ENV OCL_ROOT
+ /usr/local/cuda
+ /opt/cuda
PATH_SUFFIXES
include
OpenCL/common/inc
@@ -126,6 +128,8 @@ else()
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
+ /usr/local/cuda
+ /opt/cuda
PATH_SUFFIXES
lib/x86
lib)
@@ -135,6 +139,8 @@ else()
PATHS
ENV AMDAPPSDKROOT
ENV CUDA_PATH
+ /usr/local/cuda
+ /opt/cuda
PATH_SUFFIXES
lib/x86_64
lib/x64
diff --git a/Modules/FindSWIG.cmake b/Modules/FindSWIG.cmake
index ae6ae56..2fded49 100644
--- a/Modules/FindSWIG.cmake
+++ b/Modules/FindSWIG.cmake
@@ -5,25 +5,49 @@
FindSWIG
--------
-Find Simplified Wrapper and Interface Generator (SWIG)
+Find the Simplified Wrapper and Interface Generator (SWIG_) executable.
-This module finds an installed SWIG. It sets the following variables:
-
-::
-
- SWIG_FOUND - set to "True" if SWIG is found
- SWIG_DIR - the directory where swig is installed
- SWIG_EXECUTABLE - the path to the swig executable
- SWIG_VERSION - the version number of the swig executable
+This module finds an installed SWIG and determines its version. If a
+``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` argument is given to ``find_package``,
+it will also determine supported target languages. The module sents the
+following variables:
+``SWIG_FOUND``
+ Whether SWIG and any required components were found on the system.
+``SWIG_EXECUTABLE``
+ Path to the SWIG executable.
+``SWIG_DIR``
+ Path to the installed SWIG ``Lib`` directory (result of ``swig -swiglib``).
+``SWIG_VERSION``
+ SWIG executable version (result of ``swig -version``).
+``SWIG_<lang>_FOUND``
+ If ``COMPONENTS`` or ``OPTIONAL_COMPONENTS`` are requested, each available
+ target language ``<lang>`` (lowercase) will be set to TRUE.
-The minimum required version of SWIG can be specified using the
-standard syntax, e.g. :command:`find_package(SWIG 1.1)`
+Any ``COMPONENTS`` given to ``find_package`` should be the names of supported
+target languages as provided to the LANGUAGE argument of ``swig_add_library``,
+such as ``python`` or ``perl5``. Language names *must* be lowercase.
All information is collected from the ``SWIG_EXECUTABLE``, so the version
to be found can be changed from the command line by means of setting
-``SWIG_EXECUTABLE``
+``SWIG_EXECUTABLE``.
+
+Example usage requiring SWIG 4.0 or higher and Python language support, with
+optional Fortran support:
+
+.. code-block:: cmake
+
+ find_package(SWIG 4.0 COMPONENTS python OPTIONAL_COMPONENTS fortran)
+ if(SWIG_FOUND)
+ message("SWIG found: ${SWIG_EXECUTABLE}")
+ if(NOT SWIG_fortran_FOUND)
+ message(WARNING "SWIG Fortran bindings cannot be generated")
+ endif()
+ endif()
+
+.. _`SWIG`: http://swig.org
+
#]=======================================================================]
find_program(SWIG_EXECUTABLE NAMES swig4.0 swig3.0 swig2.0 swig)
@@ -58,10 +82,29 @@ if(SWIG_EXECUTABLE)
endif()
endif()
endif()
+
+ if(SWIG_FIND_COMPONENTS)
+ execute_process(COMMAND ${SWIG_EXECUTABLE} -help
+ OUTPUT_VARIABLE SWIG_swighelp_output
+ ERROR_VARIABLE SWIG_swighelp_error
+ RESULT_VARIABLE SWIG_swighelp_result)
+ if(SWIG_swighelp_result)
+ message(SEND_ERROR "Command \"${SWIG_EXECUTABLE} -help\" failed with output:\n${SWIG_swiglib_error}")
+ else()
+ string(REPLACE "\n" ";" SWIG_swighelp_output "${SWIG_swighelp_output}")
+ foreach(SWIG_line IN LISTS SWIG_swighelp_output)
+ if(SWIG_line MATCHES "-([A-Za-z0-9_]+) +- *Generate.*wrappers")
+ set(SWIG_${CMAKE_MATCH_1}_FOUND TRUE)
+ endif()
+ endforeach()
+ endif()
+ endif()
endif()
include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake)
-FIND_PACKAGE_HANDLE_STANDARD_ARGS(SWIG REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
- VERSION_VAR SWIG_VERSION )
+find_package_handle_standard_args(
+ SWIG HANDLE_COMPONENTS
+ REQUIRED_VARS SWIG_EXECUTABLE SWIG_DIR
+ VERSION_VAR SWIG_VERSION)
mark_as_advanced(SWIG_DIR SWIG_VERSION SWIG_EXECUTABLE)
diff --git a/Modules/FortranCInterface/CMakeLists.txt b/Modules/FortranCInterface/CMakeLists.txt
index 381080b..13e4498 100644
--- a/Modules/FortranCInterface/CMakeLists.txt
+++ b/Modules/FortranCInterface/CMakeLists.txt
@@ -101,3 +101,7 @@ set_property(TARGET symbols PROPERTY POSITION_INDEPENDENT_CODE 1)
# Require symbols through Fortran.
add_executable(FortranCInterface main.F call_sub.f ${call_mod})
target_link_libraries(FortranCInterface PUBLIC symbols)
+
+file(GENERATE OUTPUT exe-$<CONFIG>.cmake CONTENT [[
+set(FortranCInterface_EXE "$<TARGET_FILE:FortranCInterface>")
+]])
diff --git a/Modules/FortranCInterface/Detect.cmake b/Modules/FortranCInterface/Detect.cmake
index 33de6c6..c75067b 100644
--- a/Modules/FortranCInterface/Detect.cmake
+++ b/Modules/FortranCInterface/Detect.cmake
@@ -43,17 +43,11 @@ set(FortranCInterface_COMPILED ${FortranCInterface_COMPILED})
unset(FortranCInterface_COMPILED CACHE)
# Locate the sample project executable.
+set(FortranCInterface_EXE)
if(FortranCInterface_COMPILED)
- find_program(FortranCInterface_EXE
- NAMES FortranCInterface${CMAKE_EXECUTABLE_SUFFIX}
- PATHS ${FortranCInterface_BINARY_DIR} ${FortranCInterface_BINARY_DIR}/Release
- NO_DEFAULT_PATH
- )
- set(FortranCInterface_EXE ${FortranCInterface_EXE})
- unset(FortranCInterface_EXE CACHE)
+ include(${FortranCInterface_BINARY_DIR}/exe-Release.cmake OPTIONAL)
else()
set(_result "Failed to compile")
- set(FortranCInterface_EXE)
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Fortran/C interface test project failed with the following output:\n"
"${FortranCInterface_OUTPUT}\n")
diff --git a/Modules/GoogleTestAddTests.cmake b/Modules/GoogleTestAddTests.cmake
index 4abbbec..4f52ad2 100644
--- a/Modules/GoogleTestAddTests.cmake
+++ b/Modules/GoogleTestAddTests.cmake
@@ -1,6 +1,8 @@
# Distributed under the OSI-approved BSD 3-Clause License. See accompanying
# file Copyright.txt or https://cmake.org/licensing for details.
+cmake_minimum_required(VERSION ${CMAKE_VERSION})
+
set(prefix "${TEST_PREFIX}")
set(suffix "${TEST_SUFFIX}")
set(extra_args ${TEST_EXTRA_ARGS})
@@ -8,18 +10,41 @@ set(properties ${TEST_PROPERTIES})
set(script)
set(suite)
set(tests)
+set(tests_buffer)
+
+# Overwrite possibly existing ${CTEST_FILE} with empty file
+file(WRITE "${CTEST_FILE}" "")
+
+# Flushes script to ${CTEST_FILE}
+macro(flush_script)
+ file(APPEND "${CTEST_FILE}" "${script}")
+ set(script "")
+endmacro()
+
+# Flushes tests_buffer to tests
+macro(flush_tests_buffer)
+ list(APPEND tests "${tests_buffer}")
+ set(tests_buffer "")
+endmacro()
-function(add_command NAME)
+macro(add_command NAME)
set(_args "")
foreach(_arg ${ARGN})
if(_arg MATCHES "[^-./:a-zA-Z0-9_]")
- set(_args "${_args} [==[${_arg}]==]")
+ string(APPEND _args " [==[${_arg}]==]")
else()
- set(_args "${_args} ${_arg}")
+ string(APPEND _args " ${_arg}")
endif()
endforeach()
- set(script "${script}${NAME}(${_args})\n" PARENT_SCOPE)
-endfunction()
+ string(APPEND script "${NAME}(${_args})\n")
+ string(LENGTH "${script}" _script_len)
+ if(${_script_len} GREATER "50000")
+ flush_script()
+ endif()
+ # Unsets macro local variables to prevent leakage outside of this macro.
+ unset(_args)
+ unset(_script_len)
+endmacro()
# Run test executable to get list of available tests
if(NOT EXISTS "${TEST_EXECUTABLE}")
@@ -93,14 +118,20 @@ foreach(line ${output})
WORKING_DIRECTORY "${TEST_WORKING_DIR}"
${properties}
)
- list(APPEND tests "${prefix}${pretty_suite}.${pretty_test}${suffix}")
+ list(APPEND tests_buffer "${prefix}${pretty_suite}.${pretty_test}${suffix}")
+ list(LENGTH tests_buffer tests_buffer_length)
+ if(${tests_buffer_length} GREATER "250")
+ flush_tests_buffer()
+ endif()
endif()
endif()
endforeach()
+
# Create a list of all discovered tests, which users may use to e.g. set
# properties on the tests
+flush_tests_buffer()
add_command(set ${TEST_LIST} ${tests})
# Write CTest script
-file(WRITE "${CTEST_FILE}" "${script}")
+flush_script()
diff --git a/Modules/Internal/CPack/CPackNuGet.cmake b/Modules/Internal/CPack/CPackNuGet.cmake
index 1f4bcfd..20eed2e 100644
--- a/Modules/Internal/CPack/CPackNuGet.cmake
+++ b/Modules/Internal/CPack/CPackNuGet.cmake
@@ -287,7 +287,11 @@ if(CPACK_NUGET_ORDINAL_MONOLITIC)
execute_process(
COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ RESULT_VARIABLE _nuget_result
)
+ if(NOT _nuget_result EQUAL 0)
+ message(FATAL_ERROR "Nuget pack failed")
+ endif()
elseif(CPACK_NUGET_ALL_IN_ONE)
# This variable `CPACK_NUGET_ALL_IN_ONE` set by C++ code:
@@ -300,7 +304,11 @@ elseif(CPACK_NUGET_ALL_IN_ONE)
execute_process(
COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ RESULT_VARIABLE _nuget_result
)
+ if(NOT _nuget_result EQUAL 0)
+ message(FATAL_ERROR "Nuget pack failed")
+ endif()
else()
# Is there any grouped component?
@@ -322,7 +330,11 @@ else()
execute_process(
COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ RESULT_VARIABLE _nuget_result
)
+ if(NOT _nuget_result EQUAL 0)
+ message(FATAL_ERROR "Nuget pack failed")
+ endif()
endforeach()
endif()
# Is there any single component package needed?
@@ -341,7 +353,11 @@ else()
execute_process(
COMMAND "${NUGET_EXECUTABLE}" pack ${CPACK_NUGET_PACK_ADDITIONAL_OPTIONS}
WORKING_DIRECTORY "${CPACK_TEMPORARY_DIRECTORY}"
+ RESULT_VARIABLE _nuget_result
)
+ if(NOT _nuget_result EQUAL 0)
+ message(FATAL_ERROR "Nuget pack failed")
+ endif()
endforeach()
endif()
endif()
diff --git a/Modules/Internal/CPack/CPackRPM.cmake b/Modules/Internal/CPack/CPackRPM.cmake
index 3485e7d..08bbc68 100644
--- a/Modules/Internal/CPack/CPackRPM.cmake
+++ b/Modules/Internal/CPack/CPackRPM.cmake
@@ -1099,16 +1099,18 @@ function(cpack_rpm_generate_package)
# CPACK_RPM_POST_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_INSTALL_SCRIPT_FILE)
# CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_UNINSTALL_SCRIPT_FILE)
- # May be used to embed a post (un)installation script in the spec file.
+ # CPACK_RPM_POST_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_POST_TRANS_SCRIPT_FILE)
+ # May be used to embed a post installation/uninstallation/transaction script in the spec file.
# The referred script file(s) will be read and directly
- # put after the %post or %postun section
+ # put after the %post or %postun or %posttrans section
# ----------------------------------------------------------------
# CPACK_RPM_PRE_INSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_INSTALL_SCRIPT_FILE)
# CPACK_RPM_PRE_UNINSTALL_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_UNINSTALL_SCRIPT_FILE)
- # May be used to embed a pre (un)installation script in the spec file.
+ # CPACK_RPM_PRE_TRANS_SCRIPT_FILE (or CPACK_RPM_<COMPONENT>_PRE_TRANS_SCRIPT_FILE)
+ # May be used to embed a pre installation/uninstallation/transaction script in the spec file.
# The referred script file(s) will be read and directly
- # put after the %pre or %preun section
- foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL")
+ # put after the %pre or %preun or %pretrans section
+ foreach(RPM_SCRIPT_FILE_TYPE_ "INSTALL" "UNINSTALL" "TRANS")
foreach(RPM_SCRIPT_FILE_TIME_ "PRE" "POST")
set("CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_READ_FILE"
"${CPACK_RPM_${RPM_SCRIPT_FILE_TIME_}_${RPM_SCRIPT_FILE_TYPE_}_SCRIPT_FILE}")
@@ -1727,12 +1729,18 @@ mv %_topdir/tmpBBroot $RPM_BUILD_ROOT
\@RPM_SYMLINK_POSTINSTALL\@
\@CPACK_RPM_SPEC_POSTINSTALL\@
+%posttrans
+\@CPACK_RPM_SPEC_POSTTRANS\@
+
%postun
\@CPACK_RPM_SPEC_POSTUNINSTALL\@
%pre
\@CPACK_RPM_SPEC_PREINSTALL\@
+%pretrans
+\@CPACK_RPM_SPEC_PRETRANS\@
+
%preun
\@CPACK_RPM_SPEC_PREUNINSTALL\@
diff --git a/Modules/UseSWIG.cmake b/Modules/UseSWIG.cmake
index 78522da..f6a20f8 100644
--- a/Modules/UseSWIG.cmake
+++ b/Modules/UseSWIG.cmake
@@ -341,6 +341,23 @@ function(SWIG_GET_EXTRA_OUTPUT_FILES language outfiles generatedpath infile)
list(APPEND files "${extra_file}")
endforeach()
+ if (language STREQUAL "FORTRAN" AND CMAKE_Fortran_COMPILER_LOADED)
+ # Process possible user-supplied extension in flags (obtained via parent
+ # scope variable) to determine the source file name.
+ list(FIND SWIG_COMPILATION_FLAGS "-fext" fext_idx)
+ if (fext_idx EQUAL -1)
+ # Default Fortran generated extension
+ set(fext "f90")
+ else()
+ # Get extension from user-provided flag
+ math(EXPR fext_idx "${fext_idx} + 1")
+ list(GET SWIG_COMPILATION_FLAGS "${fext_idx}" fext)
+ endif()
+ set(extra_file "${generatedpath}/${module_basename}.${fext}")
+ set_source_files_properties("${extra_file}" PROPERTIES LANGUAGE "Fortran")
+ list(APPEND files "${extra_file}")
+ endif()
+
set (${outfiles} ${files} PARENT_SCOPE)
endfunction()
@@ -415,6 +432,7 @@ function(SWIG_ADD_SOURCE_TO_MODULE name outfiles infile)
get_filename_component(swig_source_file_fullname "${infile}" ABSOLUTE)
if (NOT SWIG_MODULE_${name}_NOPROXY)
+ set(SWIG_COMPILATION_FLAGS ${swig_source_file_flags})
SWIG_GET_EXTRA_OUTPUT_FILES(${SWIG_MODULE_${name}_LANGUAGE}
swig_extra_generated_files
"${outdir}"
@@ -787,6 +805,8 @@ function(SWIG_ADD_LIBRARY name)
if (APPLE)
set_target_properties (${target_name} PROPERTIES SUFFIX ".dylib")
endif ()
+ elseif (swig_lowercase_language STREQUAL "fortran")
+ # Do *not* override the target's library prefix
else()
# assume empty prefix because we expect the module to be dynamically loaded
set_target_properties (${target_name} PROPERTIES PREFIX "")