summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
Diffstat (limited to 'Modules')
-rw-r--r--Modules/FeatureSummary.cmake677
-rw-r--r--Modules/FindMatlab.cmake51
-rw-r--r--Modules/FindPythonInterp.cmake2
-rw-r--r--Modules/FindPythonLibs.cmake2
-rw-r--r--Modules/GenerateExportHeader.cmake2
-rw-r--r--Modules/MatlabTestsRedirect.cmake41
6 files changed, 407 insertions, 368 deletions
diff --git a/Modules/FeatureSummary.cmake b/Modules/FeatureSummary.cmake
index 764a5f7..548d12a 100644
--- a/Modules/FeatureSummary.cmake
+++ b/Modules/FeatureSummary.cmake
@@ -1,268 +1,27 @@
-#.rst:
-# FeatureSummary
-# --------------
-#
-# Macros for generating a summary of enabled/disabled features
-#
-#
-#
-# This module provides the macros feature_summary(),
-# set_package_properties() and add_feature_info(). For compatibility it
-# also still provides set_package_info(), set_feature_info(),
-# print_enabled_features() and print_disabled_features().
-#
-# These macros can be used to generate a summary of enabled and disabled
-# packages and/or feature for a build tree:
-#
-# ::
-#
-# -- The following OPTIONAL packages have been found:
-# LibXml2 (required version >= 2.4), XML processing lib, <http://xmlsoft.org>
-# * Enables HTML-import in MyWordProcessor
-# * Enables odt-export in MyWordProcessor
-# PNG , A PNG image library. , <http://www.libpng.org/pub/png/>
-# * Enables saving screenshots
-# -- The following OPTIONAL packages have not been found:
-# Lua51 , The Lua scripting language. , <http://www.lua.org>
-# * Enables macros in MyWordProcessor
-# Foo , Foo provides cool stuff.
-#
-#
-#
-#
-#
-# ::
-#
-# FEATURE_SUMMARY( [FILENAME <file>]
-# [APPEND]
-# [VAR <variable_name>]
-# [INCLUDE_QUIET_PACKAGES]
-# [FATAL_ON_MISSING_REQUIRED_PACKAGES]
-# [DESCRIPTION "Found packages:"]
-# WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND
-# | ENABLED_FEATURES | DISABLED_FEATURES)
-# )
-#
-#
-#
-# The FEATURE_SUMMARY() macro can be used to print information about
-# enabled or disabled packages or features of a project. By default,
-# only the names of the features/packages will be printed and their
-# required version when one was specified. Use SET_PACKAGE_PROPERTIES()
-# to add more useful information, like e.g. a download URL for the
-# respective package or their purpose in the project.
-#
-# The WHAT option is the only mandatory option. Here you specify what
-# information will be printed:
-#
-# ``ALL``
-# print everything
-# ``ENABLED_FEATURES``
-# the list of all features which are enabled
-# ``DISABLED_FEATURES``
-# the list of all features which are disabled
-# ``PACKAGES_FOUND``
-# the list of all packages which have been found
-# ``PACKAGES_NOT_FOUND``
-# the list of all packages which have not been found
-# ``OPTIONAL_PACKAGES_FOUND``
-# only those packages which have been found which have the type OPTIONAL
-# ``OPTIONAL_PACKAGES_NOT_FOUND``
-# only those packages which have not been found which have the type OPTIONAL
-# ``RECOMMENDED_PACKAGES_FOUND``
-# only those packages which have been found which have the type RECOMMENDED
-# ``RECOMMENDED_PACKAGES_NOT_FOUND``
-# only those packages which have not been found which have the type RECOMMENDED
-# ``REQUIRED_PACKAGES_FOUND``
-# only those packages which have been found which have the type REQUIRED
-# ``REQUIRED_PACKAGES_NOT_FOUND``
-# only those packages which have not been found which have the type REQUIRED
-# ``RUNTIME_PACKAGES_FOUND``
-# only those packages which have been found which have the type RUNTIME
-# ``RUNTIME_PACKAGES_NOT_FOUND``
-# only those packages which have not been found which have the type RUNTIME
-#
-# With the exception of the ``ALL`` value, these values can be combined
-# in order to customize the output. For example:
-#
-# ::
-#
-# feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
-#
-#
-#
-# If a FILENAME is given, the information is printed into this file. If
-# APPEND is used, it is appended to this file, otherwise the file is
-# overwritten if it already existed. If the VAR option is used, the
-# information is "printed" into the specified variable. If FILENAME is
-# not used, the information is printed to the terminal. Using the
-# DESCRIPTION option a description or headline can be set which will be
-# printed above the actual content. If INCLUDE_QUIET_PACKAGES is given,
-# packages which have been searched with find_package(... QUIET) will
-# also be listed. By default they are skipped. If
-# FATAL_ON_MISSING_REQUIRED_PACKAGES is given, CMake will abort if a
-# package which is marked as REQUIRED has not been found.
-#
-# Example 1, append everything to a file:
-#
-# ::
-#
-# feature_summary(WHAT ALL
-# FILENAME ${CMAKE_BINARY_DIR}/all.log APPEND)
-#
-#
-#
-# Example 2, print the enabled features into the variable
-# enabledFeaturesText, including QUIET packages:
-#
-# ::
-#
-# feature_summary(WHAT ENABLED_FEATURES
-# INCLUDE_QUIET_PACKAGES
-# DESCRIPTION "Enabled Features:"
-# VAR enabledFeaturesText)
-# message(STATUS "${enabledFeaturesText}")
-#
-#
-#
-#
-#
-# ::
-#
-# SET_PACKAGE_PROPERTIES(<name> PROPERTIES
-# [ URL <url> ]
-# [ DESCRIPTION <description> ]
-# [ TYPE (RUNTIME|OPTIONAL|RECOMMENDED|REQUIRED) ]
-# [ PURPOSE <purpose> ]
-# )
-#
-#
-#
-# Use this macro to set up information about the named package, which
-# can then be displayed via FEATURE_SUMMARY(). This can be done either
-# directly in the Find-module or in the project which uses the module
-# after the find_package() call. The features for which information can
-# be set are added automatically by the find_package() command.
-#
-# URL: this should be the homepage of the package, or something similar.
-# Ideally this is set already directly in the Find-module.
-#
-# DESCRIPTION: A short description what that package is, at most one
-# sentence. Ideally this is set already directly in the Find-module.
-#
-# TYPE: What type of dependency has the using project on that package.
-# Default is OPTIONAL. In this case it is a package which can be used
-# by the project when available at buildtime, but it also work without.
-# RECOMMENDED is similar to OPTIONAL, i.e. the project will build if
-# the package is not present, but the functionality of the resulting
-# binaries will be severly limited. If a REQUIRED package is not
-# available at buildtime, the project may not even build. This can be
-# combined with the FATAL_ON_MISSING_REQUIRED_PACKAGES argument for
-# feature_summary(). Last, a RUNTIME package is a package which is
-# actually not used at all during the build, but which is required for
-# actually running the resulting binaries. So if such a package is
-# missing, the project can still be built, but it may not work later on.
-# If set_package_properties() is called multiple times for the same
-# package with different TYPEs, the TYPE is only changed to higher TYPEs
-# ( RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED ), lower TYPEs are
-# ignored. The TYPE property is project-specific, so it cannot be set
-# by the Find-module, but must be set in the project.
-#
-# PURPOSE: This describes which features this package enables in the
-# project, i.e. it tells the user what functionality he gets in the
-# resulting binaries. If set_package_properties() is called multiple
-# times for a package, all PURPOSE properties are appended to a list of
-# purposes of the package in the project. As the TYPE property, also
-# the PURPOSE property is project-specific, so it cannot be set by the
-# Find-module, but must be set in the project.
-#
-#
-#
-# Example for setting the info for a package:
-#
-# ::
-#
-# find_package(LibXml2)
-# set_package_properties(LibXml2 PROPERTIES
-# DESCRIPTION "A XML processing library."
-# URL "http://xmlsoft.org/")
-#
-#
-#
-# ::
-#
-# set_package_properties(LibXml2 PROPERTIES
-# TYPE RECOMMENDED
-# PURPOSE "Enables HTML-import in MyWordProcessor")
-# ...
-# set_package_properties(LibXml2 PROPERTIES
-# TYPE OPTIONAL
-# PURPOSE "Enables odt-export in MyWordProcessor")
-#
-#
-#
-# ::
-#
-# find_package(DBUS)
-# set_package_properties(DBUS PROPERTIES
-# TYPE RUNTIME
-# PURPOSE "Necessary to disable the screensaver during a presentation" )
-#
-#
-#
-# ::
-#
-# ADD_FEATURE_INFO(<name> <enabled> <description>)
-#
-# Use this macro to add information about a feature with the given
-# <name>. <enabled> contains whether this feature is enabled or not,
-# <description> is a text describing the feature. The information can
-# be displayed using feature_summary() for ENABLED_FEATURES and
-# DISABLED_FEATURES respectively.
-#
-# Example for setting the info for a feature:
-#
-# ::
-#
-# option(WITH_FOO "Help for foo" ON)
-# add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
-#
-#
-#
-#
-#
-# The following macros are provided for compatibility with previous
-# CMake versions:
-#
-# ::
-#
-# SET_PACKAGE_INFO(<name> <description> [<url> [<purpose>] ] )
-#
-# Use this macro to set up information about the named package, which
-# can then be displayed via FEATURE_SUMMARY(). This can be done either
-# directly in the Find-module or in the project which uses the module
-# after the find_package() call. The features for which information can
-# be set are added automatically by the find_package() command.
-#
-# ::
-#
-# PRINT_ENABLED_FEATURES()
-#
-# Does the same as FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION
-# "Enabled features:")
-#
-# ::
-#
-# PRINT_DISABLED_FEATURES()
-#
-# Does the same as FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION
-# "Disabled features:")
-#
-# ::
-#
-# SET_FEATURE_INFO(<name> <description> [<url>] )
-#
-# Does the same as SET_PACKAGE_INFO(<name> <description> <url> )
+#[=======================================================================[.rst:
+FeatureSummary
+--------------
+
+Functions for generating a summary of enabled/disabled features.
+
+These functions can be used to generate a summary of enabled and disabled
+packages and/or feature for a build tree such as::
+
+ -- The following OPTIONAL packages have been found:
+ LibXml2 (required version >= 2.4), XML processing lib, <http://xmlsoft.org>
+ * Enables HTML-import in MyWordProcessor
+ * Enables odt-export in MyWordProcessor
+ PNG , A PNG image library. , <http://www.libpng.org/pub/png/>
+ * Enables saving screenshots
+ -- The following OPTIONAL packages have not been found:
+ Lua51 , The Lua scripting language. , <http://www.lua.org>
+ * Enables macros in MyWordProcessor
+ Foo , Foo provides cool stuff.
+
+Functions
+^^^^^^^^^
+
+#]=======================================================================]
#=============================================================================
# Copyright 2007-2015 Kitware, Inc.
@@ -280,83 +39,6 @@
include("${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake")
-function(ADD_FEATURE_INFO _name _enabled _desc)
- if (${_enabled})
- set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
- else ()
- set_property(GLOBAL APPEND PROPERTY DISABLED_FEATURES "${_name}")
- endif ()
-
- set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
-endfunction()
-
-
-
-function(SET_PACKAGE_PROPERTIES _name _props)
- if(NOT "${_props}" STREQUAL "PROPERTIES")
- message(FATAL_ERROR "PROPERTIES keyword is missing in SET_PACKAGE_PROPERTIES() call.")
- endif()
-
- set(options ) # none
- set(oneValueArgs DESCRIPTION URL TYPE PURPOSE )
- set(multiValueArgs ) # none
-
- CMAKE_PARSE_ARGUMENTS(_SPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
-
- if(_SPP_UNPARSED_ARGUMENTS)
- message(FATAL_ERROR "Unknown keywords given to SET_PACKAGE_PROPERTIES(): \"${_SPP_UNPARSED_ARGUMENTS}\"")
- endif()
-
- if(_SPP_DESCRIPTION)
- get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION)
- if(_info AND NOT "${_info}" STREQUAL "${_SPP_DESCRIPTION}")
- message(STATUS "Warning: Property DESCRIPTION for package ${_name} already set to \"${_info}\", overriding it with \"${_SPP_DESCRIPTION}\"")
- endif()
-
- set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_SPP_DESCRIPTION}" )
- endif()
-
-
- if(_SPP_URL)
- get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_URL)
- if(_info AND NOT "${_info}" STREQUAL "${_SPP_URL}")
- message(STATUS "Warning: Property URL already set to \"${_info}\", overriding it with \"${_SPP_URL}\"")
- endif()
-
- set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_SPP_URL}" )
- endif()
-
-
- # handle the PURPOSE: use APPEND, since there can be multiple purposes for one package inside a project
- if(_SPP_PURPOSE)
- set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_SPP_PURPOSE}" )
- endif()
-
- # handle the TYPE
- if(NOT _SPP_TYPE)
- set(_SPP_TYPE OPTIONAL)
- endif()
-
- # List the supported types, according to their priority
- set(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" )
- list(FIND validTypes ${_SPP_TYPE} _typeIndexInList)
- if("${_typeIndexInList}" STREQUAL "-1" )
- message(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). "
- "Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." )
- endif()
-
- get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE)
- list(FIND validTypes "${_previousType}" _prevTypeIndexInList)
-
- # make sure a previously set TYPE is not overridden with a lower new TYPE:
- if("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}")
- set_property(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" )
- endif()
-
-endfunction()
-
-
-
function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
set(_type "ANY")
@@ -439,6 +121,97 @@ function(_FS_GET_FEATURE_SUMMARY _property _var _includeQuiet)
endfunction()
+#[=======================================================================[.rst:
+.. command:: feature_summary
+
+ ::
+
+ feature_summary( [FILENAME <file>]
+ [APPEND]
+ [VAR <variable_name>]
+ [INCLUDE_QUIET_PACKAGES]
+ [FATAL_ON_MISSING_REQUIRED_PACKAGES]
+ [DESCRIPTION "Found packages:"]
+ WHAT (ALL | PACKAGES_FOUND | PACKAGES_NOT_FOUND
+ | ENABLED_FEATURES | DISABLED_FEATURES)
+ )
+
+ The ``feature_summary()`` macro can be used to print information about
+ enabled or disabled packages or features of a project. By default,
+ only the names of the features/packages will be printed and their
+ required version when one was specified. Use ``set_package_properties()``
+ to add more useful information, like e.g. a download URL for the
+ respective package or their purpose in the project.
+
+ The ``WHAT`` option is the only mandatory option. Here you specify what
+ information will be printed:
+
+ ``ALL``
+ print everything
+ ``ENABLED_FEATURES``
+ the list of all features which are enabled
+ ``DISABLED_FEATURES``
+ the list of all features which are disabled
+ ``PACKAGES_FOUND``
+ the list of all packages which have been found
+ ``PACKAGES_NOT_FOUND``
+ the list of all packages which have not been found
+ ``OPTIONAL_PACKAGES_FOUND``
+ only those packages which have been found which have the type OPTIONAL
+ ``OPTIONAL_PACKAGES_NOT_FOUND``
+ only those packages which have not been found which have the type OPTIONAL
+ ``RECOMMENDED_PACKAGES_FOUND``
+ only those packages which have been found which have the type RECOMMENDED
+ ``RECOMMENDED_PACKAGES_NOT_FOUND``
+ only those packages which have not been found which have the type RECOMMENDED
+ ``REQUIRED_PACKAGES_FOUND``
+ only those packages which have been found which have the type REQUIRED
+ ``REQUIRED_PACKAGES_NOT_FOUND``
+ only those packages which have not been found which have the type REQUIRED
+ ``RUNTIME_PACKAGES_FOUND``
+ only those packages which have been found which have the type RUNTIME
+ ``RUNTIME_PACKAGES_NOT_FOUND``
+ only those packages which have not been found which have the type RUNTIME
+
+ With the exception of the ``ALL`` value, these values can be combined
+ in order to customize the output. For example:
+
+ .. code-block:: cmake
+
+ feature_summary(WHAT ENABLED_FEATURES DISABLED_FEATURES)
+
+ If a ``FILENAME`` is given, the information is printed into this file. If
+ ``APPEND`` is used, it is appended to this file, otherwise the file is
+ overwritten if it already existed. If the VAR option is used, the
+ information is "printed" into the specified variable. If ``FILENAME`` is
+ not used, the information is printed to the terminal. Using the
+ ``DESCRIPTION`` option a description or headline can be set which will be
+ printed above the actual content. If ``INCLUDE_QUIET_PACKAGES`` is given,
+ packages which have been searched with ``find_package(... QUIET)`` will
+ also be listed. By default they are skipped. If
+ ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` is given, CMake will abort if a
+ package which is marked as ``REQUIRED`` has not been found.
+
+ Example 1, append everything to a file:
+
+ .. code-block:: cmake
+
+ include(FeatureSummary)
+ feature_summary(WHAT ALL
+ FILENAME ${CMAKE_BINARY_DIR}/all.log APPEND)
+
+ Example 2, print the enabled features into the variable
+ enabledFeaturesText, including QUIET packages:
+
+ .. code-block:: cmake
+
+ include(FeatureSummary)
+ feature_summary(WHAT ENABLED_FEATURES
+ INCLUDE_QUIET_PACKAGES
+ DESCRIPTION "Enabled Features:"
+ VAR enabledFeaturesText)
+ message(STATUS "${enabledFeaturesText}")
+#]=======================================================================]
function(FEATURE_SUMMARY)
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
@@ -558,9 +331,198 @@ function(FEATURE_SUMMARY)
endfunction()
+#[=======================================================================[.rst:
+.. command:: set_package_properties
+
+ ::
+
+ set_package_properties(<name> PROPERTIES
+ [ URL <url> ]
+ [ DESCRIPTION <description> ]
+ [ TYPE (RUNTIME|OPTIONAL|RECOMMENDED|REQUIRED) ]
+ [ PURPOSE <purpose> ]
+ )
+
+ Use this macro to set up information about the named package, which
+ can then be displayed via FEATURE_SUMMARY(). This can be done either
+ directly in the Find-module or in the project which uses the module
+ after the find_package() call. The features for which information can
+ be set are added automatically by the find_package() command.
+
+ ``URL <url>``
+ This should be the homepage of the package, or something similar.
+ Ideally this is set already directly in the Find-module.
+
+ ``DESCRIPTION <description>``
+ A short description what that package is, at most one sentence.
+ Ideally this is set already directly in the Find-module.
+
+ ``TYPE <type>``
+ What type of dependency has the using project on that package.
+ Default is ``OPTIONAL``. In this case it is a package which can be used
+ by the project when available at buildtime, but it also work without.
+ ``RECOMMENDED`` is similar to ``OPTIONAL``, i.e. the project will build if
+ the package is not present, but the functionality of the resulting
+ binaries will be severly limited. If a ``REQUIRED`` package is not
+ available at buildtime, the project may not even build. This can be
+ combined with the ``FATAL_ON_MISSING_REQUIRED_PACKAGES`` argument for
+ ``feature_summary()``. Last, a ``RUNTIME`` package is a package which is
+ actually not used at all during the build, but which is required for
+ actually running the resulting binaries. So if such a package is
+ missing, the project can still be built, but it may not work later on.
+ If ``set_package_properties()`` is called multiple times for the same
+ package with different TYPEs, the ``TYPE`` is only changed to higher
+ TYPEs (``RUNTIME < OPTIONAL < RECOMMENDED < REQUIRED``), lower TYPEs are
+ ignored. The ``TYPE`` property is project-specific, so it cannot be set
+ by the Find-module, but must be set in the project.
+
+
+ ``PURPOSE <purpose>``
+ This describes which features this package enables in the
+ project, i.e. it tells the user what functionality he gets in the
+ resulting binaries. If set_package_properties() is called multiple
+ times for a package, all PURPOSE properties are appended to a list of
+ purposes of the package in the project. As the TYPE property, also
+ the PURPOSE property is project-specific, so it cannot be set by the
+ Find-module, but must be set in the project.
+
+ Example for setting the info for a package:
+
+ .. code-block:: cmake
+
+ find_package(LibXml2)
+ set_package_properties(LibXml2 PROPERTIES
+ DESCRIPTION "A XML processing library."
+ URL "http://xmlsoft.org/")
+ # or
+ set_package_properties(LibXml2 PROPERTIES
+ TYPE RECOMMENDED
+ PURPOSE "Enables HTML-import in MyWordProcessor")
+ # or
+ set_package_properties(LibXml2 PROPERTIES
+ TYPE OPTIONAL
+ PURPOSE "Enables odt-export in MyWordProcessor")
+
+ find_package(DBUS)
+ set_package_properties(DBUS PROPERTIES
+ TYPE RUNTIME
+ PURPOSE "Necessary to disable the screensaver during a presentation")
+#]=======================================================================]
+function(SET_PACKAGE_PROPERTIES _name _props)
+ if(NOT "${_props}" STREQUAL "PROPERTIES")
+ message(FATAL_ERROR "PROPERTIES keyword is missing in SET_PACKAGE_PROPERTIES() call.")
+ endif()
+
+ set(options ) # none
+ set(oneValueArgs DESCRIPTION URL TYPE PURPOSE )
+ set(multiValueArgs ) # none
+
+ CMAKE_PARSE_ARGUMENTS(_SPP "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
+
+ if(_SPP_UNPARSED_ARGUMENTS)
+ message(FATAL_ERROR "Unknown keywords given to SET_PACKAGE_PROPERTIES(): \"${_SPP_UNPARSED_ARGUMENTS}\"")
+ endif()
+
+ if(_SPP_DESCRIPTION)
+ get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION)
+ if(_info AND NOT "${_info}" STREQUAL "${_SPP_DESCRIPTION}")
+ message(STATUS "Warning: Property DESCRIPTION for package ${_name} already set to \"${_info}\", overriding it with \"${_SPP_DESCRIPTION}\"")
+ endif()
+
+ set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_SPP_DESCRIPTION}" )
+ endif()
+
+
+ if(_SPP_URL)
+ get_property(_info GLOBAL PROPERTY _CMAKE_${_name}_URL)
+ if(_info AND NOT "${_info}" STREQUAL "${_SPP_URL}")
+ message(STATUS "Warning: Property URL already set to \"${_info}\", overriding it with \"${_SPP_URL}\"")
+ endif()
+
+ set_property(GLOBAL PROPERTY _CMAKE_${_name}_URL "${_SPP_URL}" )
+ endif()
+
+
+ # handle the PURPOSE: use APPEND, since there can be multiple purposes for one package inside a project
+ if(_SPP_PURPOSE)
+ set_property(GLOBAL APPEND PROPERTY _CMAKE_${_name}_PURPOSE "${_SPP_PURPOSE}" )
+ endif()
+
+ # handle the TYPE
+ if(NOT _SPP_TYPE)
+ set(_SPP_TYPE OPTIONAL)
+ endif()
+
+ # List the supported types, according to their priority
+ set(validTypes "RUNTIME" "OPTIONAL" "RECOMMENDED" "REQUIRED" )
+ list(FIND validTypes ${_SPP_TYPE} _typeIndexInList)
+ if("${_typeIndexInList}" STREQUAL "-1" )
+ message(FATAL_ERROR "Bad package property type ${_SPP_TYPE} used in SET_PACKAGE_PROPERTIES(). "
+ "Valid types are OPTIONAL, RECOMMENDED, REQUIRED and RUNTIME." )
+ endif()
+
+ get_property(_previousType GLOBAL PROPERTY _CMAKE_${_name}_TYPE)
+ list(FIND validTypes "${_previousType}" _prevTypeIndexInList)
+
+ # make sure a previously set TYPE is not overridden with a lower new TYPE:
+ if("${_typeIndexInList}" GREATER "${_prevTypeIndexInList}")
+ set_property(GLOBAL PROPERTY _CMAKE_${_name}_TYPE "${_SPP_TYPE}" )
+ endif()
+
+endfunction()
+
+#[=======================================================================[.rst:
+.. command:: add_feature_info
+
+ ::
+
+ add_feature_info(<name> <enabled> <description>)
+
+ Use this macro to add information about a feature with the given ``<name>``.
+ ``<enabled>`` contains whether this feature is enabled or not.
+ ``<description>`` is a text describing the feature. The information can
+ be displayed using ``feature_summary()`` for ``ENABLED_FEATURES`` and
+ ``DISABLED_FEATURES`` respectively.
+
+ Example for setting the info for a feature:
+
+ .. code-block:: cmake
+
+ option(WITH_FOO "Help for foo" ON)
+ add_feature_info(Foo WITH_FOO "The Foo feature provides very cool stuff.")
+#]=======================================================================]
+function(ADD_FEATURE_INFO _name _enabled _desc)
+ if (${_enabled})
+ set_property(GLOBAL APPEND PROPERTY ENABLED_FEATURES "${_name}")
+ else ()
+ set_property(GLOBAL APPEND PROPERTY DISABLED_FEATURES "${_name}")
+ endif ()
+
+ set_property(GLOBAL PROPERTY _CMAKE_${_name}_DESCRIPTION "${_desc}" )
+endfunction()
+
# The stuff below is only kept for compatibility
+#[=======================================================================[.rst:
+Legacy Macros
+^^^^^^^^^^^^^
+
+The following macros are provided for compatibility with previous
+CMake versions:
+
+.. command:: set_package_info
+
+ ::
+
+ set_package_info(<name> <description> [ <url> [<purpose>] ])
+
+ Use this macro to set up information about the named package, which
+ can then be displayed via ``feature_summary()``. This can be done either
+ directly in the Find-module or in the project which uses the module
+ after the :command:`find_package` call. The features for which information
+ can be set are added automatically by the ``find_package()`` command.
+#]=======================================================================]
function(SET_PACKAGE_INFO _name _desc)
unset(_url)
unset(_purpose)
@@ -579,20 +541,51 @@ function(SET_PACKAGE_INFO _name _desc)
endif()
endfunction()
+#[=======================================================================[.rst:
+.. command:: set_feature_info
+ ::
+ set_feature_info(<name> <description> [<url>])
+
+ Does the same as::
+
+ set_package_info(<name> <description> <url>)
+#]=======================================================================]
function(SET_FEATURE_INFO)
SET_PACKAGE_INFO(${ARGN})
endfunction()
+#[=======================================================================[.rst:
+.. command:: print_enabled_features
+
+ ::
+
+ print_enabled_features()
+ Does the same as
+ .. code-block:: cmake
+
+ feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
+#]=======================================================================]
function(PRINT_ENABLED_FEATURES)
FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
endfunction()
+#[=======================================================================[.rst:
+.. command:: print_disabled_features
+
+ ::
+
+ print_disabled_features()
+
+ Does the same as
+ .. code-block:: cmake
+ feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
+#]=======================================================================]
function(PRINT_DISABLED_FEATURES)
FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")
endfunction()
diff --git a/Modules/FindMatlab.cmake b/Modules/FindMatlab.cmake
index b501599..c813f8f 100644
--- a/Modules/FindMatlab.cmake
+++ b/Modules/FindMatlab.cmake
@@ -635,7 +635,7 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
set(devnull INPUT_FILE NUL)
endif()
- # timeout set to 30 seconds, in case it does not start
+ # timeout set to 120 seconds, in case it does not start
# note as said before OUTPUT_VARIABLE cannot be used in a platform
# independent manner however, not setting it would flush the output of Matlab
# in the current console (unix variant)
@@ -644,11 +644,18 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
OUTPUT_VARIABLE _matlab_version_from_cmd_dummy
RESULT_VARIABLE _matlab_result_version_call
ERROR_VARIABLE _matlab_result_version_call_error
- TIMEOUT 30
+ TIMEOUT 120
WORKING_DIRECTORY "${_matlab_temporary_folder}"
${devnull}
)
+ if("${_matlab_result_version_call}" MATCHES "timeout")
+ if(MATLAB_FIND_DEBUG)
+ message(WARNING "[MATLAB] Unable to determine the version of Matlab."
+ " Matlab call timed out after 120 seconds.")
+ endif()
+ return()
+ endif()
if(${_matlab_result_version_call})
if(MATLAB_FIND_DEBUG)
@@ -698,7 +705,6 @@ function(matlab_get_version_from_matlab_run matlab_binary_program matlab_list_ve
endfunction()
-
#.rst:
# .. command:: matlab_add_unit_test
#
@@ -720,6 +726,7 @@ endfunction()
# matlab_add_unit_test(
# NAME <name>
# UNITTEST_FILE matlab_file_containing_unittest.m
+# [CUSTOM_MATLAB_COMMAND matlab_command_to_run_as_test]
# [UNITTEST_PRECOMMAND matlab_command_to_run]
# [TIMEOUT timeout]
# [ADDITIONAL_PATH path1 [path2 ...]]
@@ -735,6 +742,11 @@ endfunction()
# ``UNITTEST_FILE``
# the matlab unittest file. Its path will be automatically
# added to the Matlab path.
+# ``CUSTOM_MATLAB_COMMAND``
+# Matlab script command to run as the test.
+# IIf this is not set, then the following is run:
+# "runtests('matlab_file_name'), exit(max([ans(1,:).Failed]))
+# matlab_file_name comes from UNITTEST_FILE without the .m.
# ``UNITTEST_PRECOMMAND``
# Matlab script command to be ran before the file
# containing the test (eg. GPU device initialisation based on CMake
@@ -748,12 +760,18 @@ endfunction()
# ``MATLAB_ADDITIONAL_STARTUP_OPTIONS``
# a list of additional option in order
# to run Matlab from the command line.
+# -nosplash -nodesktop -nodisplay are always added.
# ``TEST_ARGS``
# Additional options provided to the add_test command. These
# options are added to the default options (eg. "CONFIGURATIONS Release")
# ``NO_UNITTEST_FRAMEWORK``
# when set, indicates that the test should not
# use the unittest framework of Matlab (available for versions >= R2013a).
+# ``WORKING_DIRECTORY``
+# This will be the working directory for the test. If specified it will
+# also be the output directory used for the log file of the test run.
+# If not specifed the temporary directory ${CMAKE_BINARY_DIR}/Matlab will
+# be used as the working directory and the log location.
#
function(matlab_add_unit_test)
@@ -762,11 +780,12 @@ function(matlab_add_unit_test)
endif()
set(options NO_UNITTEST_FRAMEWORK)
- set(oneValueArgs NAME UNITTEST_PRECOMMAND UNITTEST_FILE TIMEOUT)
+ set(oneValueArgs NAME UNITTEST_FILE TIMEOUT WORKING_DIRECTORY
+ UNITTEST_PRECOMMAND CUSTOM_TEST_COMMAND)
set(multiValueArgs ADDITIONAL_PATH MATLAB_ADDITIONAL_STARTUP_OPTIONS TEST_ARGS)
set(prefix _matlab_unittest_prefix)
- cmake_parse_arguments(${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
+ cmake_parse_arguments(PARSE_ARGV 0 ${prefix} "${options}" "${oneValueArgs}" "${multiValueArgs}" )
if(NOT ${prefix}_NAME)
message(FATAL_ERROR "[MATLAB] The Matlab test name cannot be empty")
@@ -774,15 +793,17 @@ function(matlab_add_unit_test)
add_test(NAME ${${prefix}_NAME}
COMMAND ${CMAKE_COMMAND}
- -Dtest_name=${${prefix}_NAME}
- -Dadditional_paths=${${prefix}_ADDITIONAL_PATH}
- -Dtest_timeout=${${prefix}_TIMEOUT}
- -Doutput_directory=${_matlab_temporary_folder}
- -DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}
- -Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}
- -DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}
- -Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}
- -Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}
+ "-Dtest_name=${${prefix}_NAME}"
+ "-Dadditional_paths=${${prefix}_ADDITIONAL_PATH}"
+ "-Dtest_timeout=${${prefix}_TIMEOUT}"
+ "-Doutput_directory=${_matlab_temporary_folder}"
+ "-Dworking_directory=${${prefix}_WORKING_DIRECTORY}"
+ "-DMatlab_PROGRAM=${Matlab_MAIN_PROGRAM}"
+ "-Dno_unittest_framework=${${prefix}_NO_UNITTEST_FRAMEWORK}"
+ "-DMatlab_ADDITIONNAL_STARTUP_OPTIONS=${${prefix}_MATLAB_ADDITIONAL_STARTUP_OPTIONS}"
+ "-Dunittest_file_to_run=${${prefix}_UNITTEST_FILE}"
+ "-Dcustom_Matlab_test_command=${${prefix}_CUSTOM_TEST_COMMAND}"
+ "-Dcmd_to_run_before_test=${${prefix}_UNITTEST_PRECOMMAND}"
-P ${_FindMatlab_SELF_DIR}/MatlabTestsRedirect.cmake
${${prefix}_TEST_ARGS}
${${prefix}_UNPARSED_ARGUMENTS}
@@ -1034,7 +1055,7 @@ function(_Matlab_get_version_from_root matlab_root matlab_known_version matlab_f
if(${list_of_all_versions_length} GREATER 0)
list(GET matlab_list_of_all_versions 0 _matlab_version_tmp)
else()
- set(_matlab_version_tmp "")
+ set(_matlab_version_tmp "unknown")
endif()
# set the version into the cache
diff --git a/Modules/FindPythonInterp.cmake b/Modules/FindPythonInterp.cmake
index e194185..4d726f2 100644
--- a/Modules/FindPythonInterp.cmake
+++ b/Modules/FindPythonInterp.cmake
@@ -52,7 +52,7 @@ unset(_Python_NAMES)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
-set(_PYTHON3_VERSIONS 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+set(_PYTHON3_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(PythonInterp_FIND_VERSION)
if(PythonInterp_FIND_VERSION_COUNT GREATER 1)
diff --git a/Modules/FindPythonLibs.cmake b/Modules/FindPythonLibs.cmake
index ab92f86..d9916a1 100644
--- a/Modules/FindPythonLibs.cmake
+++ b/Modules/FindPythonLibs.cmake
@@ -84,7 +84,7 @@ set(CMAKE_FIND_FRAMEWORK LAST)
set(_PYTHON1_VERSIONS 1.6 1.5)
set(_PYTHON2_VERSIONS 2.7 2.6 2.5 2.4 2.3 2.2 2.1 2.0)
-set(_PYTHON3_VERSIONS 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
+set(_PYTHON3_VERSIONS 3.7 3.6 3.5 3.4 3.3 3.2 3.1 3.0)
if(PythonLibs_FIND_VERSION)
if(PythonLibs_FIND_VERSION_COUNT GREATER 1)
diff --git a/Modules/GenerateExportHeader.cmake b/Modules/GenerateExportHeader.cmake
index e33b927..bacf137 100644
--- a/Modules/GenerateExportHeader.cmake
+++ b/Modules/GenerateExportHeader.cmake
@@ -208,7 +208,7 @@ macro(_test_compiler_hidden_visibility)
if(CMAKE_COMPILER_IS_GNUCXX AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "4.2")
set(GCC_TOO_OLD TRUE)
- elseif(CMAKE_COMPILER_IS_GNUC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.2")
+ elseif(CMAKE_COMPILER_IS_GNUCC AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.2")
set(GCC_TOO_OLD TRUE)
elseif(CMAKE_CXX_COMPILER_ID MATCHES Intel AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS "12.0")
set(_INTEL_TOO_OLD TRUE)
diff --git a/Modules/MatlabTestsRedirect.cmake b/Modules/MatlabTestsRedirect.cmake
index 0ef4c3e..76f9a53 100644
--- a/Modules/MatlabTestsRedirect.cmake
+++ b/Modules/MatlabTestsRedirect.cmake
@@ -23,11 +23,12 @@
# -DMatlab_PROGRAM=matlab_exe_location
# -DMatlab_ADDITIONNAL_STARTUP_OPTIONS=""
# -Dtest_name=name_of_the_test
+# -Dcustom_Matlab_test_command=""
# -Dcmd_to_run_before_test=""
# -Dunittest_file_to_run
# -P FindMatlab_TestsRedirect.cmake
-set(Matlab_UNIT_TESTS_CMD -nosplash -nojvm -nodesktop -nodisplay ${Matlab_ADDITIONNAL_STARTUP_OPTIONS})
+set(Matlab_UNIT_TESTS_CMD -nosplash -nodesktop -nodisplay ${Matlab_ADDITIONNAL_STARTUP_OPTIONS})
if(WIN32)
set(Matlab_UNIT_TESTS_CMD ${Matlab_UNIT_TESTS_CMD} -wait)
endif()
@@ -36,6 +37,13 @@ if(NOT test_timeout)
set(test_timeout 180)
endif()
+# If timeout is -1, then do not put a timeout on the execute_process
+if(test_timeout EQUAL -1)
+ set(test_timeout "")
+else()
+ set(test_timeout TIMEOUT ${test_timeout})
+endif()
+
if(NOT cmd_to_run_before_test)
set(cmd_to_run_before_test)
endif()
@@ -50,16 +58,30 @@ foreach(s IN LISTS additional_paths)
endif()
endforeach()
-set(unittest_to_run "runtests('${unittest_file_to_run_name}'), exit(max([ans(1,:).Failed]))")
+if(custom_Matlab_test_command)
+ set(unittest_to_run "${custom_Matlab_test_command}")
+else()
+ set(unittest_to_run "runtests('${unittest_file_to_run_name}'), exit(max([ans(1,:).Failed]))")
+endif()
+
+
if(no_unittest_framework)
set(unittest_to_run "try, ${unittest_file_to_run_name}, catch err, disp('An exception has been thrown during the execution'), disp(err), disp(err.stack), exit(1), end, exit(0)")
endif()
set(Matlab_SCRIPT_TO_RUN
- "addpath(${concat_string}), path, ${cmd_to_run_before_test}, ${unittest_to_run}"
+ "addpath(${concat_string}); ${cmd_to_run_before_test}; ${unittest_to_run}"
)
+# if the working directory is not specified then default
+# to the output_directory because the log file will go there
+# if the working_directory is specified it will override the
+# output_directory
+if(NOT working_directory)
+ set(working_directory "${output_directory}")
+endif()
-set(Matlab_LOG_FILE "${output_directory}/${test_name}.log")
+string(REPLACE "/" "_" log_file_name "${test_name}.log")
+set(Matlab_LOG_FILE "${working_directory}/${log_file_name}")
set(devnull)
if(UNIX)
@@ -69,11 +91,14 @@ elseif(WIN32)
endif()
execute_process(
- COMMAND "${Matlab_PROGRAM}" ${Matlab_UNIT_TESTS_CMD} -logfile "${test_name}.log" -r "${Matlab_SCRIPT_TO_RUN}"
+ # Do not use a full path to log file. Depend on the fact that the log file
+ # is always going to go in the working_directory. This is because matlab
+ # on unix is a shell script that does not handle spaces in the logfile path.
+ COMMAND "${Matlab_PROGRAM}" ${Matlab_UNIT_TESTS_CMD} -logfile "${log_file_name}" -r "${Matlab_SCRIPT_TO_RUN}"
RESULT_VARIABLE res
- TIMEOUT ${test_timeout}
+ ${test_timeout}
OUTPUT_QUIET # we do not want the output twice
- WORKING_DIRECTORY "${output_directory}"
+ WORKING_DIRECTORY "${working_directory}"
${devnull}
)
@@ -87,5 +112,5 @@ message("Matlab test ${name_of_the_test} output:\n${matlab_log_content}") # if w
if(NOT (res EQUAL 0))
- message( FATAL_ERROR "[MATLAB] TEST FAILED" )
+ message( FATAL_ERROR "[MATLAB] TEST FAILED Matlab returned ${res}" )
endif()