diff options
author | Craig Scott <craig.scott@crascit.com> | 2020-09-24 11:28:52 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-09-24 11:29:03 (GMT) |
commit | ac5195c408a713c9c31388ef9b3c0e6f5173b2da (patch) | |
tree | 0bc6f2e902b775bbcfaacc83c3a82c77c69e983b | |
parent | d18c564210dd20692536b4988afc8356c5926694 (diff) | |
parent | 5b3356263cf8f00c79c25aa9e3ac71ffd8cc7e7e (diff) | |
download | CMake-ac5195c408a713c9c31388ef9b3c0e6f5173b2da.zip CMake-ac5195c408a713c9c31388ef9b3c0e6f5173b2da.tar.gz CMake-ac5195c408a713c9c31388ef9b3c0e6f5173b2da.tar.bz2 |
Merge topic 'find_package-version-range'
5b3356263c CMakePackageConfigHelpers: Add version range support
6bfc442fde FPHSA: add support of version range
d7df81067b find_package: Add support of version range
09095dbcd2 cmFindPackageCommand: Refactoring
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Michael Hirsch, Ph.D. <michael@scivision.dev>
Merge-request: !5226
52 files changed, 1099 insertions, 237 deletions
diff --git a/Help/command/find_package.rst b/Help/command/find_package.rst index 857de78..87265ce 100644 --- a/Help/command/find_package.rst +++ b/Help/command/find_package.rst @@ -34,14 +34,29 @@ Additional optional components may be listed after whether a package is considered to be found are defined by the target package. +.. _FIND_PACKAGE_VERSION_FORMAT: + The ``[version]`` argument requests a version with which the package found -should be compatible (format is ``major[.minor[.patch[.tweak]]]``). The -``EXACT`` option requests that the version be matched exactly. If no -``[version]`` and/or component list is given to a recursive invocation +should be compatible. There are two possible forms in which it may be +specified: + + * A single version with the format ``major[.minor[.patch[.tweak]]]``. + * A version range with the format ``versionMin...[<]versionMax`` where + ``versionMin`` and ``versionMax`` have the same format as the single + version. By default, both end points are included. By specifying ``<``, + the upper end point will be excluded. + +The ``EXACT`` option requests that the version be matched exactly. This option +is incompatible with the specification of a version range. + +If no ``[version]`` and/or component list is given to a recursive invocation inside a find-module, the corresponding arguments are forwarded automatically from the outer call (including the ``EXACT`` flag for ``[version]``). Version support is currently provided only on a package-by-package basis (see the `Version Selection`_ section below). +When a version range is specified but the package is only designed to expect +a single version, the package will ignore the upper end point of the range and +only take the single version at the lower end of the range into account. See the :command:`cmake_policy` command documentation for discussion of the ``NO_POLICY_SCOPE`` option. @@ -140,10 +155,10 @@ outlined below will find them without requiring use of additional options. Version Selection ^^^^^^^^^^^^^^^^^ -When the ``[version]`` argument is given Config mode will only find a +When the ``[version]`` argument is given, Config mode will only find a version of the package that claims compatibility with the requested -version (format is ``major[.minor[.patch[.tweak]]]``). If the ``EXACT`` -option is given only a version of the package claiming an exact match +version (see :ref:`format specification <FIND_PACKAGE_VERSION_FORMAT>`). If the +``EXACT`` option is given, only a version of the package claiming an exact match of the requested version may be found. CMake does not establish any convention for the meaning of version numbers. Package version numbers are checked by "version" files provided by the packages @@ -160,31 +175,78 @@ version file is loaded in a nested scope in which the following variables have been defined: ``PACKAGE_FIND_NAME`` - the ``<PackageName>`` + The ``<PackageName>`` ``PACKAGE_FIND_VERSION`` - full requested version string + Full requested version string ``PACKAGE_FIND_VERSION_MAJOR`` - major version if requested, else 0 + Major version if requested, else 0 ``PACKAGE_FIND_VERSION_MINOR`` - minor version if requested, else 0 + Minor version if requested, else 0 ``PACKAGE_FIND_VERSION_PATCH`` - patch version if requested, else 0 + Patch version if requested, else 0 ``PACKAGE_FIND_VERSION_TWEAK`` - tweak version if requested, else 0 + Tweak version if requested, else 0 ``PACKAGE_FIND_VERSION_COUNT`` - number of version components, 0 to 4 + Number of version components, 0 to 4 + +When a version range is specified, the above version variables will hold +values based on the lower end of the version range. This is to preserve +compatibility with packages that have not been implemented to expect version +ranges. In addition, the version range will be described by the following +variables: + +``PACKAGE_FIND_VERSION_RANGE`` + Full requested version range string +``PACKAGE_FIND_VERSION_RANGE_MIN`` + This specifies whether the lower end point of the version range should be + included or excluded. Currently, the only supported value for this variable + is ``INCLUDE``. +``PACKAGE_FIND_VERSION_RANGE_MAX`` + This specifies whether the upper end point of the version range should be + included or excluded. The supported values for this variable are + ``INCLUDE`` and ``EXCLUDE``. + +``PACKAGE_FIND_VERSION_MIN`` + Full requested version string of the lower end point of the range +``PACKAGE_FIND_VERSION_MIN_MAJOR`` + Major version of the lower end point if requested, else 0 +``PACKAGE_FIND_VERSION_MIN_MINOR`` + Minor version of the lower end point if requested, else 0 +``PACKAGE_FIND_VERSION_MIN_PATCH`` + Patch version of the lower end point if requested, else 0 +``PACKAGE_FIND_VERSION_MIN_TWEAK`` + Tweak version of the lower end point if requested, else 0 +``PACKAGE_FIND_VERSION_MIN_COUNT`` + Number of version components of the lower end point, 0 to 4 + +``PACKAGE_FIND_VERSION_MAX`` + Full requested version string of the upper end point of the range +``PACKAGE_FIND_VERSION_MAX_MAJOR`` + Major version of the upper end point if requested, else 0 +``PACKAGE_FIND_VERSION_MAX_MINOR`` + Minor version of the upper end point if requested, else 0 +``PACKAGE_FIND_VERSION_MAX_PATCH`` + Patch version of the upper end point if requested, else 0 +``PACKAGE_FIND_VERSION_MAX_TWEAK`` + Tweak version of the upper end point if requested, else 0 +``PACKAGE_FIND_VERSION_MAX_COUNT`` + Number of version components of the upper end point, 0 to 4 + +Regardless of whether a single version or a version range is specified, the +variable ``PACKAGE_FIND_VERSION_COMPLETE`` will be defined and will hold +the full requested version string as specified. The version file checks whether it satisfies the requested version and sets these variables: ``PACKAGE_VERSION`` - full provided version string + Full provided version string ``PACKAGE_VERSION_EXACT`` - true if version is exact match + True if version is exact match ``PACKAGE_VERSION_COMPATIBLE`` - true if version is compatible + True if version is compatible ``PACKAGE_VERSION_UNSUITABLE`` - true if unsuitable as any version + True if unsuitable as any version These variables are checked by the ``find_package`` command to determine whether the configuration file provides an acceptable version. They @@ -192,17 +254,17 @@ are not available after the ``find_package`` call returns. If the version is acceptable the following variables are set: ``<PackageName>_VERSION`` - full provided version string + Full provided version string ``<PackageName>_VERSION_MAJOR`` - major version if provided, else 0 + Major version if provided, else 0 ``<PackageName>_VERSION_MINOR`` - minor version if provided, else 0 + Minor version if provided, else 0 ``<PackageName>_VERSION_PATCH`` - patch version if provided, else 0 + Patch version if provided, else 0 ``<PackageName>_VERSION_TWEAK`` - tweak version if provided, else 0 + Tweak version if provided, else 0 ``<PackageName>_VERSION_COUNT`` - number of version components, 0 to 4 + Number of version components, 0 to 4 and the corresponding package configuration file is loaded. When multiple package configuration files are available whose version files @@ -391,31 +453,77 @@ defines variables to provide information about the call arguments (and restores their original state before returning): ``CMAKE_FIND_PACKAGE_NAME`` - the ``<PackageName>`` which is searched for + The ``<PackageName>`` which is searched for ``<PackageName>_FIND_REQUIRED`` - true if ``REQUIRED`` option was given + True if ``REQUIRED`` option was given ``<PackageName>_FIND_QUIETLY`` - true if ``QUIET`` option was given + True if ``QUIET`` option was given ``<PackageName>_FIND_VERSION`` - full requested version string + Full requested version string ``<PackageName>_FIND_VERSION_MAJOR`` - major version if requested, else 0 + Major version if requested, else 0 ``<PackageName>_FIND_VERSION_MINOR`` - minor version if requested, else 0 + Minor version if requested, else 0 ``<PackageName>_FIND_VERSION_PATCH`` - patch version if requested, else 0 + Patch version if requested, else 0 ``<PackageName>_FIND_VERSION_TWEAK`` - tweak version if requested, else 0 + Tweak version if requested, else 0 ``<PackageName>_FIND_VERSION_COUNT`` - number of version components, 0 to 4 + Number of version components, 0 to 4 ``<PackageName>_FIND_VERSION_EXACT`` - true if ``EXACT`` option was given + True if ``EXACT`` option was given ``<PackageName>_FIND_COMPONENTS`` - list of requested components + List of requested components ``<PackageName>_FIND_REQUIRED_<c>`` - true if component ``<c>`` is required, + True if component ``<c>`` is required, false if component ``<c>`` is optional +When a version range is specified, the above version variables will hold +values based on the lower end of the version range. This is to preserve +compatibility with packages that have not been implemented to expect version +ranges. In addition, the version range will be described by the following +variables: + +``<PackageName>_FIND_VERSION_RANGE`` + Full requested version range string +``<PackageName>_FIND_VERSION_RANGE_MIN`` + This specifies whether the lower end point of the version range is + included or excluded. Currently, ``INCLUDE`` is the only supported value. +``<PackageName>_FIND_VERSION_RANGE_MAX`` + This specifies whether the upper end point of the version range is + included or excluded. The possible values for this variable are + ``INCLUDE`` or ``EXCLUDE``. + +``<PackageName>_FIND_VERSION_MIN`` + Full requested version string of the lower end point of the range +``<PackageName>_FIND_VERSION_MIN_MAJOR`` + Major version of the lower end point if requested, else 0 +``<PackageName>_FIND_VERSION_MIN_MINOR`` + Minor version of the lower end point if requested, else 0 +``<PackageName>_FIND_VERSION_MIN_PATCH`` + Patch version of the lower end point if requested, else 0 +``<PackageName>_FIND_VERSION_MIN_TWEAK`` + Tweak version of the lower end point if requested, else 0 +``<PackageName>_FIND_VERSION_MIN_COUNT`` + Number of version components of the lower end point, 0 to 4 + +``<PackageName>_FIND_VERSION_MAX`` + Full requested version string of the upper end point of the range +``<PackageName>_FIND_VERSION_MAX_MAJOR`` + Major version of the upper end point if requested, else 0 +``<PackageName>_FIND_VERSION_MAX_MINOR`` + Minor version of the upper end point if requested, else 0 +``<PackageName>_FIND_VERSION_MAX_PATCH`` + Patch version of the upper end point if requested, else 0 +``<PackageName>_FIND_VERSION_MAX_TWEAK`` + Tweak version of the upper end point if requested, else 0 +``<PackageName>_FIND_VERSION_MAX_COUNT`` + Number of version components of the upper end point, 0 to 4 + +Regardless of whether a single version or a version range is specified, the +variable ``<PackageName>_FIND_VERSION_COMPLETE`` will be defined and will hold +the full requested version string as specified. + In Module mode the loaded find module is responsible to honor the request detailed by these variables; see the find module for details. In Config mode ``find_package`` handles ``REQUIRED``, ``QUIET``, and diff --git a/Help/release/dev/CMakePackageConfigHelpers-version_range.rst b/Help/release/dev/CMakePackageConfigHelpers-version_range.rst new file mode 100644 index 0000000..6900529 --- /dev/null +++ b/Help/release/dev/CMakePackageConfigHelpers-version_range.rst @@ -0,0 +1,4 @@ +CMakePackageConfigHelpers-version_range +--------------------------------------- + +* :module:`CMakePackageConfigHelpers` module learned to manage version range. diff --git a/Help/release/dev/FPHSA-version_range.rst b/Help/release/dev/FPHSA-version_range.rst new file mode 100644 index 0000000..18996c4 --- /dev/null +++ b/Help/release/dev/FPHSA-version_range.rst @@ -0,0 +1,7 @@ +FPHSA-version_range +------------------- + +* The :module:`FindPackageHandleStandardArgs` module learned to handle + version range. It also gained the ``find_package_check_version()`` command to + check the validity of a version against version-related arguments of + :command:`find_package` command. diff --git a/Help/release/dev/find_package-version_range.rst b/Help/release/dev/find_package-version_range.rst new file mode 100644 index 0000000..5305518 --- /dev/null +++ b/Help/release/dev/find_package-version_range.rst @@ -0,0 +1,4 @@ +find_package-version_range +-------------------------- + +* The :command:`find_package` command learned to handle a version range. diff --git a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in index a6e5fda..46b8b2a 100644 --- a/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in +++ b/Modules/BasicConfigVersion-AnyNewerVersion.cmake.in @@ -9,12 +9,23 @@ set(PACKAGE_VERSION "@CVF_VERSION@") -if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) - set(PACKAGE_VERSION_COMPATIBLE FALSE) +if (PACKAGE_FIND_VERSION_RANGE) + # Package version must be in the requested version range + if ((PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION_MIN) + OR ((PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" AND PACKAGE_VERSION VERSION_GREATER PACKAGE_FIND_VERSION_MAX) + OR (PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" AND PACKAGE_VERSION VERSION_GREATER_EQUAL PACKAGE_FIND_VERSION_MAX))) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + endif() else() - set(PACKAGE_VERSION_COMPATIBLE TRUE) - if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) - set(PACKAGE_VERSION_EXACT TRUE) + if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) + set(PACKAGE_VERSION_COMPATIBLE FALSE) + else() + set(PACKAGE_VERSION_COMPATIBLE TRUE) + if(PACKAGE_FIND_VERSION STREQUAL PACKAGE_VERSION) + set(PACKAGE_VERSION_EXACT TRUE) + endif() endif() endif() diff --git a/Modules/BasicConfigVersion-ExactVersion.cmake.in b/Modules/BasicConfigVersion-ExactVersion.cmake.in index 43fc4d0..3507a22 100644 --- a/Modules/BasicConfigVersion-ExactVersion.cmake.in +++ b/Modules/BasicConfigVersion-ExactVersion.cmake.in @@ -9,6 +9,13 @@ # The variable CVF_VERSION must be set before calling configure_file(). +if (PACKAGE_FIND_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the version strategy " + "(ExactVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " + "with this request. Only the lower endpoint of the range will be used.") +endif() + set(PACKAGE_VERSION "@CVF_VERSION@") if("@CVF_VERSION@" MATCHES "^([0-9]+\\.[0-9]+\\.[0-9]+)\\.") # strip the tweak version diff --git a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in index 8c3b6a2..662900d 100644 --- a/Modules/BasicConfigVersion-SameMajorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMajorVersion.cmake.in @@ -9,6 +9,13 @@ # The variable CVF_VERSION must be set before calling configure_file(). +if (PACKAGE_FIND_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the version strategy " + "(SameMajorVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " + "with this request. Only the lower endpoint of the range will be used.") +endif() + set(PACKAGE_VERSION "@CVF_VERSION@") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) diff --git a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in index e2030d2..bddf4ce 100644 --- a/Modules/BasicConfigVersion-SameMinorVersion.cmake.in +++ b/Modules/BasicConfigVersion-SameMinorVersion.cmake.in @@ -10,6 +10,13 @@ # The variable CVF_VERSION must be set before calling configure_file(). +if (PACKAGE_FIND_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the version strategy " + "(SameMinorVersion) of the module `${PACKAGE_FIND_NAME}` is incompatible " + "with this request. Only the lower endpoint of the range will be used.") +endif() + set(PACKAGE_VERSION "@CVF_VERSION@") if(PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION) diff --git a/Modules/CMakePackageConfigHelpers.cmake b/Modules/CMakePackageConfigHelpers.cmake index 22fc953..50d7605 100644 --- a/Modules/CMakePackageConfigHelpers.cmake +++ b/Modules/CMakePackageConfigHelpers.cmake @@ -159,6 +159,11 @@ If your project has more elaborated version matching rules, you will need to write your own custom ``ConfigVersion.cmake`` file instead of using this macro. +.. note:: ``COMPATIBILITY_MODE`` ``AnyNewerVersion`` handles the version range + if any is specified (see :command:`find_package` command for the details). + All other modes are incompatible with version range and will display an + author warning if a one is specified. + If ``ARCH_INDEPENDENT`` is given, the installed package version will be considered compatible even if it was built for a different architecture than the requested architecture. Otherwise, an architecture check will be performed, diff --git a/Modules/FindPackageHandleStandardArgs.cmake b/Modules/FindPackageHandleStandardArgs.cmake index 4fb0825..4d252bc 100644 --- a/Modules/FindPackageHandleStandardArgs.cmake +++ b/Modules/FindPackageHandleStandardArgs.cmake @@ -5,16 +5,19 @@ FindPackageHandleStandardArgs ----------------------------- -This module provides a function intended to be used in :ref:`Find Modules` -implementing :command:`find_package(<PackageName>)` calls. It handles the -``REQUIRED``, ``QUIET`` and version-related arguments of ``find_package``. -It also sets the ``<PackageName>_FOUND`` variable. The package is -considered found if all variables listed contain valid results, e.g. -valid filepaths. +This module provides functions intended to be used in :ref:`Find Modules` +implementing :command:`find_package(<PackageName>)` calls. .. command:: find_package_handle_standard_args - There are two signatures:: + This command handles the ``REQUIRED``, ``QUIET`` and version-related + arguments of :command:`find_package`. It also sets the + ``<PackageName>_FOUND`` variable. The package is considered found if all + variables listed contain valid results, e.g. valid filepaths. + + There are two signatures: + + .. code-block:: cmake find_package_handle_standard_args(<PackageName> (DEFAULT_MSG|<custom-failure-message>) @@ -25,6 +28,7 @@ valid filepaths. [FOUND_VAR <result-var>] [REQUIRED_VARS <required-var>...] [VERSION_VAR <version-var>] + [HANDLE_VERSION_RANGE] [HANDLE_COMPONENTS] [CONFIG_MODE] [NAME_MISMATCHED] @@ -69,6 +73,11 @@ valid filepaths. version and the version which has been actually found, both if the version is ok or not. + ``HANDLE_VERSION_RANGE`` + Enable handling of a version range, if one is specified. Without this + option, a developer warning will be displayed if a version range is + specified. + ``HANDLE_COMPONENTS`` Enable handling of package components. In this case, the command will report which components have been found and which are missing, @@ -151,10 +160,54 @@ In this case, a ``FindAutmoc4.cmake`` module wraps a call to directory for ``automoc4``. Then the call to ``find_package_handle_standard_args`` produces a proper success/failure message. + +.. command:: find_package_check_version + + Helper function which can be used to check if a ``<version>`` is valid + against version-related arguments of :command:`find_package`. + + .. code-block:: cmake + + find_package_check_version(<version> <result-var> + [HANDLE_VERSION_RANGE] + [RESULT_MESSAGE_VARIABLE <message-var>] + ) + + The ``<result-var>`` will hold a boolean value giving the result of the check. + + The options are: + + ``HANDLE_VERSION_RANGE`` + Enable handling of a version range, if one is specified. Without this + option, a developer warning will be displayed if a version range is + specified. + + ``RESULT_MESSAGE_VARIABLE <message-var>`` + Specify a variable to get back a message describing the result of the check. + +Example for the usage: + +.. code-block:: cmake + + find_package_check_version(1.2.3 result HANDLE_VERSION_RANGE + RESULT_MESSAGE_VARIABLE reason) + if (result) + message (STATUS "${reason}") + else() + message (FATAL_ERROR "${reason}") + endif() #]=======================================================================] include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) + +cmake_policy(PUSH) +# numbers and boolean constants +cmake_policy (SET CMP0012 NEW) +# IN_LIST operator +cmake_policy (SET CMP0057 NEW) + + # internal helper macro macro(_FPHSA_FAILURE_MESSAGE _msg) set (__msg "${_msg}") @@ -207,10 +260,112 @@ macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) endmacro() +function(FIND_PACKAGE_CHECK_VERSION version result) + cmake_parse_arguments (PARSE_ARGV 2 FPCV "HANDLE_VERSION_RANGE;NO_AUTHOR_WARNING_VERSION_RANGE" "RESULT_MESSAGE_VARIABLE" "") + + if (FPCV_UNPARSED_ARGUMENTS) + message (FATAL_ERROR "find_package_check_version(): ${FPCV_UNPARSED_ARGUMENTS}: unexpected arguments") + endif() + if ("RESULT_MESSAGE_VARIABLE" IN_LIST FPCV_KEYWORDS_MISSING_VALUES) + message (FATAL_ERROR "find_package_check_version(): RESULT_MESSAGE_VARIABLE expects an argument") + endif() + + set (${result} FALSE PARENT_SCOPE) + if (FPCV_RESULT_MESSAGE_VARIABLE) + unset (${FPCV_RESULT_MESSAGE_VARIABLE} PARENT_SCOPE) + endif() + + if (CMAKE_FIND_PACKAGE_NAME) + set (package ${CMAKE_FIND_PACKAGE_NAME}) + else() + message (FATAL_ERROR "find_package_check_version(): Cannot be used outside a 'Find Module'") + endif() + + if (NOT FPCV_NO_AUTHOR_WARNING_VERSION_RANGE + AND ${package}_FIND_VERSION_RANGE AND NOT FPCV_HANDLE_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the option " + "HANDLE_VERSION_RANGE` is not passed to `find_package_check_version()`. " + "Only the lower endpoint of the range will be used.") + endif() + + + set (version_ok FALSE) + unset (version_msg) + + if (FPCV_HANDLE_VERSION_RANGE AND ${package}_FIND_VERSION_RANGE) + if (${package}_FIND_VERSION_MIN VERSION_GREATER ${package}_FIND_VERSION_MAX + OR (${package}_FIND_VERSION_MIN VERSION_EQUAL ${package}_FIND_VERSION_MAX + AND ${package}_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE")) + set (version_msg "Found unsuitable version \"${version}\", required range is empty (\"${${package}_FIND_VERSION_RANGE}\")") + elseif ((${package}_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE" + AND version VERSION_GREATER_EQUAL ${package}_FIND_VERSION_MIN) + AND ((${package}_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" + AND version VERSION_LESS_EQUAL ${package}_FIND_VERSION_MAX) + OR (${package}_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" + AND version VERSION_LESS ${package}_FIND_VERSION_MAX))) + set (version_ok TRUE) + set(version_msg "(found suitable version \"${version}\", required range is \"${${package}_FIND_VERSION_RANGE}\")") + else() + set(version_msg "Found unsuitable version \"${version}\", required range is \"${${package}_FIND_VERSION_RANGE}\"") + endif() + elseif (DEFINED ${package}_FIND_VERSION) + if(${package}_FIND_VERSION_EXACT) # exact version required + # count the dots in the version string + string(REGEX REPLACE "[^.]" "" version_dots "${version}") + # add one dot because there is one dot more than there are components + string(LENGTH "${version_dots}." version_dots) + if (version_dots GREATER ${package}_FIND_VERSION_COUNT) + # Because of the C++ implementation of find_package() ${package}_FIND_VERSION_COUNT + # is at most 4 here. Therefore a simple lookup table is used. + if (${package}_FIND_VERSION_COUNT EQUAL 1) + set(version_regex "[^.]*") + elseif (${package}_FIND_VERSION_COUNT EQUAL 2) + set(version_regex "[^.]*\\.[^.]*") + elseif (${package}_FIND_VERSION_COUNT EQUAL 3) + set(version_regex "[^.]*\\.[^.]*\\.[^.]*") + else() + set(version_regex "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") + endif() + string(REGEX REPLACE "^(${version_regex})\\..*" "\\1" version_head "${version}") + if (NOT ${package}_FIND_VERSION VERSION_EQUAL version_head) + set(version_msg "Found unsuitable version \"${version}\", but required is exact version \"${${package}_FIND_VERSION}\"") + else () + set(version_ok TRUE) + set(version_msg "(found suitable exact version \"${_FOUND_VERSION}\")") + endif () + else () + if (NOT ${package}_FIND_VERSION VERSION_EQUAL version) + set(version_msg "Found unsuitable version \"${version}\", but required is exact version \"${${package}_FIND_VERSION}\"") + else () + set(version_ok TRUE) + set(version_msg "(found suitable exact version \"${version}\")") + endif () + endif () + else() # minimum version + if (${package}_FIND_VERSION VERSION_GREATER version) + set(version_msg "Found unsuitable version \"${version}\", but required is at least \"${${package}_FIND_VERSION}\"") + else() + set(version_ok TRUE) + set(version_msg "(found suitable version \"${version}\", minimum required is \"${${package}_FIND_VERSION}\")") + endif() + endif() + else () + set(version_ok TRUE) + set(version_msg "(found version \"${version}\")") + endif() + + set (${result} ${version_ok} PARENT_SCOPE) + if (FPCV_RESULT_MESSAGE_VARIABLE) + set (${FPCV_RESULT_MESSAGE_VARIABLE} "${version_msg}" PARENT_SCOPE) + endif() +endfunction() + + function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) # Set up the arguments for `cmake_parse_arguments`. - set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED) + set(options CONFIG_MODE HANDLE_COMPONENTS NAME_MISMATCHED HANDLE_VERSION_RANGE) set(oneValueArgs FAIL_MESSAGE REASON_FAILURE_MESSAGE VERSION_VAR FOUND_VAR) set(multiValueArgs REQUIRED_VARS) @@ -278,7 +433,14 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) "to follow a certain pattern.") endif () -# now that we collected all arguments, process them + if (${_NAME}_FIND_VERSION_RANGE AND NOT FPHSA_HANDLE_VERSION_RANGE) + message(AUTHOR_WARNING + "`find_package()` specify a version range but the module ${_NAME} does " + "not support this capability. Only the lower endpoint of the range " + "will be used.") + endif() + + # now that we collected all arguments, process them if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") @@ -364,61 +526,22 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) if (DEFINED ${_NAME}_FIND_VERSION) if(DEFINED ${FPHSA_VERSION_VAR}) set(_FOUND_VERSION ${${FPHSA_VERSION_VAR}}) - - if(${_NAME}_FIND_VERSION_EXACT) # exact version required - # count the dots in the version string - string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${_FOUND_VERSION}") - # add one dot because there is one dot more than there are components - string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) - if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) - # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT - # is at most 4 here. Therefore a simple lookup table is used. - if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) - set(_VERSION_REGEX "[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) - set(_VERSION_REGEX "[^.]*\\.[^.]*") - elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") - else () - set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") - endif () - string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${_FOUND_VERSION}") - unset(_VERSION_REGEX) - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - unset(_VERSION_HEAD) - else () - if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable exact version \"${_FOUND_VERSION}\")") - endif () - endif () - unset(_VERSION_DOTS) - - else() # minimum version specified: - if (${_NAME}_FIND_VERSION VERSION_GREATER _FOUND_VERSION) - set(VERSION_MSG "Found unsuitable version \"${_FOUND_VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") - set(VERSION_OK FALSE) - else () - set(VERSION_MSG "(found suitable version \"${_FOUND_VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") - endif () + if (FPHSA_HANDLE_VERSION_RANGE) + set (FPCV_HANDLE_VERSION_RANGE HANDLE_VERSION_RANGE) + else() + set(FPCV_HANDLE_VERSION_RANGE NO_AUTHOR_WARNING_VERSION_RANGE) endif() - + find_package_check_version (${_FOUND_VERSION} VERSION_OK RESULT_MESSAGE_VARIABLE VERSION_MSG + ${FPCV_HANDLE_VERSION_RANGE}) else() - # if the package was not found, but a version was given, add that to the output: if(${_NAME}_FIND_VERSION_EXACT) - set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") + elseif (FPHSA_HANDLE_VERSION_RANGE AND ${_NAME}_FIND_VERSION_RANGE) + set(VERSION_MSG "(Required is version range \"${${_NAME}_FIND_VERSION_RANGE}\")") else() - set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") + set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") endif() - endif() else () # Check with DEFINED as the found version may be 0. @@ -464,3 +587,6 @@ function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) set(${_NAME}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) set(${_NAME_UPPER}_FOUND ${${_NAME}_FOUND} PARENT_SCOPE) endfunction() + + +cmake_policy(POP) diff --git a/Source/cmFindPackageCommand.cxx b/Source/cmFindPackageCommand.cxx index c462651..1ff093f 100644 --- a/Source/cmFindPackageCommand.cxx +++ b/Source/cmFindPackageCommand.cxx @@ -13,6 +13,7 @@ #include <utility> #include <cm/memory> +#include <cmext/string_view> #include "cmsys/Directory.hxx" #include "cmsys/FStream.hxx" @@ -48,6 +49,11 @@ cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::Builds( cmFindPackageCommand::PathLabel cmFindPackageCommand::PathLabel::SystemRegistry("SYSTEM_PACKAGE_REGISTRY"); +const cm::string_view cmFindPackageCommand::VERSION_ENDPOINT_INCLUDED( + "INCLUDE"); +const cm::string_view cmFindPackageCommand::VERSION_ENDPOINT_EXCLUDED( + "EXCLUDE"); + struct StrverscmpGreater { bool operator()(const std::string& lhs, const std::string& rhs) const @@ -89,34 +95,11 @@ void cmFindPackageCommand::Sort(std::vector<std::string>::iterator begin, cmFindPackageCommand::cmFindPackageCommand(cmExecutionStatus& status) : cmFindCommon(status) + , VersionRangeMin(VERSION_ENDPOINT_INCLUDED) + , VersionRangeMax(VERSION_ENDPOINT_INCLUDED) { this->CMakePathName = "PACKAGE"; - this->Quiet = false; - this->Required = false; - this->NoUserRegistry = false; - this->NoSystemRegistry = false; - this->UseConfigFiles = true; - this->UseFindModules = true; this->DebugMode = false; - this->UseLib32Paths = false; - this->UseLib64Paths = false; - this->UseLibx32Paths = false; - this->UseRealPath = false; - this->PolicyScope = true; - this->VersionMajor = 0; - this->VersionMinor = 0; - this->VersionPatch = 0; - this->VersionTweak = 0; - this->VersionCount = 0; - this->VersionExact = false; - this->VersionFoundMajor = 0; - this->VersionFoundMinor = 0; - this->VersionFoundPatch = 0; - this->VersionFoundTweak = 0; - this->VersionFoundCount = 0; - this->RequiredCMakeVersion = 0; - this->SortOrder = None; - this->SortDirection = Asc; this->AppendSearchPathGroups(); this->DeprecatedFindModules["Qt"] = cmPolicies::CMP0084; @@ -266,7 +249,8 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) DoingHints }; Doing doing = DoingNone; - cmsys::RegularExpression version("^[0-9.]+$"); + cmsys::RegularExpression versionRegex( + R"V(^([0-9]+(\.[0-9]+)*)(\.\.\.(<?)([0-9]+(\.[0-9]+)*))?$)V"); bool haveVersion = false; std::set<unsigned int> configArgs; std::set<unsigned int> moduleArgs; @@ -369,9 +353,9 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) return false; } this->Configs.push_back(args[i]); - } else if (!haveVersion && version.find(args[i])) { + } else if (!haveVersion && versionRegex.find(args[i])) { haveVersion = true; - this->Version = args[i]; + this->VersionComplete = args[i]; } else { this->SetError( cmStrCat("called with invalid argument \"", args[i], "\"")); @@ -410,23 +394,23 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } // Ignore EXACT with no version. - if (this->Version.empty() && this->VersionExact) { + if (this->VersionComplete.empty() && this->VersionExact) { this->VersionExact = false; this->Makefile->IssueMessage( MessageType::AUTHOR_WARNING, "Ignoring EXACT since no version is requested."); } - if (this->Version.empty() || components.empty()) { + if (this->VersionComplete.empty() || components.empty()) { // Check whether we are recursing inside "Find<name>.cmake" within // another find_package(<name>) call. std::string mod = cmStrCat(this->Name, "_FIND_MODULE"); if (this->Makefile->IsOn(mod)) { - if (this->Version.empty()) { + if (this->VersionComplete.empty()) { // Get version information from the outer call if necessary. // Requested version string. - std::string ver = cmStrCat(this->Name, "_FIND_VERSION"); - this->Version = this->Makefile->GetSafeDefinition(ver); + std::string ver = cmStrCat(this->Name, "_FIND_VERSION_COMPLETE"); + this->VersionComplete = this->Makefile->GetSafeDefinition(ver); // Whether an exact version is required. std::string exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT"); @@ -439,32 +423,46 @@ bool cmFindPackageCommand::InitialPass(std::vector<std::string> const& args) } } + // fill various parts of version specification + if (!this->VersionComplete.empty()) { + if (!versionRegex.find(this->VersionComplete)) { + this->SetError("called with invalid version specification"); + return false; + } + + this->Version = versionRegex.match(1); + this->VersionMax = versionRegex.match(5); + if (versionRegex.match(4) == "<"_s) { + this->VersionRangeMax = VERSION_ENDPOINT_EXCLUDED; + } + if (!this->VersionMax.empty()) { + this->VersionRange = this->VersionComplete; + } + } + + if (this->VersionExact && !this->VersionRange.empty()) { + this->SetError("EXACT cannot be specified with a version range."); + return false; + } + + // Parse the version number and store the results that were + // successfully parsed. + auto parseVersion = [](const std::string& version, unsigned int& major, + unsigned int& minor, unsigned int& patch, + unsigned int& tweak) -> unsigned int { + return sscanf(version.c_str(), "%u.%u.%u.%u", &major, &minor, &patch, + &tweak); + }; + if (!this->Version.empty()) { - // Try to parse the version number and store the results that were - // successfully parsed. - unsigned int parsed_major; - unsigned int parsed_minor; - unsigned int parsed_patch; - unsigned int parsed_tweak; this->VersionCount = - sscanf(this->Version.c_str(), "%u.%u.%u.%u", &parsed_major, - &parsed_minor, &parsed_patch, &parsed_tweak); - switch (this->VersionCount) { - case 4: - this->VersionTweak = parsed_tweak; - CM_FALLTHROUGH; - case 3: - this->VersionPatch = parsed_patch; - CM_FALLTHROUGH; - case 2: - this->VersionMinor = parsed_minor; - CM_FALLTHROUGH; - case 1: - this->VersionMajor = parsed_major; - CM_FALLTHROUGH; - default: - break; - } + parseVersion(this->Version, this->VersionMajor, this->VersionMinor, + this->VersionPatch, this->VersionTweak); + } + if (!this->VersionMax.empty()) { + this->VersionMaxCount = parseVersion( + this->VersionMax, this->VersionMaxMajor, this->VersionMaxMinor, + this->VersionMaxPatch, this->VersionMaxTweak); } std::string disableFindPackageVar = @@ -627,53 +625,97 @@ bool cmFindPackageCommand::FindPackageUsingConfigMode() return this->HandlePackageMode(HandlePackageModeType::Config); } +void cmFindPackageCommand::SetVersionVariables( + const std::function<void(const std::string&, cm::string_view)>& + addDefinition, + const std::string& prefix, const std::string& version, unsigned int count, + unsigned int major, unsigned int minor, unsigned int patch, + unsigned int tweak) +{ + addDefinition(prefix, version); + + char buf[64]; + sprintf(buf, "%u", major); + addDefinition(prefix + "_MAJOR", buf); + sprintf(buf, "%u", minor); + addDefinition(prefix + "_MINOR", buf); + sprintf(buf, "%u", patch); + addDefinition(prefix + "_PATCH", buf); + sprintf(buf, "%u", tweak); + addDefinition(prefix + "_TWEAK", buf); + sprintf(buf, "%u", count); + addDefinition(prefix + "_COUNT", buf); +} + void cmFindPackageCommand::SetModuleVariables(const std::string& components) { - this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name.c_str()); + this->AddFindDefinition("CMAKE_FIND_PACKAGE_NAME", this->Name); // Store the list of components. std::string components_var = this->Name + "_FIND_COMPONENTS"; - this->AddFindDefinition(components_var, components.c_str()); + this->AddFindDefinition(components_var, components); if (this->Quiet) { // Tell the module that is about to be read that it should find // quietly. std::string quietly = cmStrCat(this->Name, "_FIND_QUIETLY"); - this->AddFindDefinition(quietly, "1"); + this->AddFindDefinition(quietly, "1"_s); } if (this->Required) { // Tell the module that is about to be read that it should report // a fatal error if the package is not found. std::string req = cmStrCat(this->Name, "_FIND_REQUIRED"); - this->AddFindDefinition(req, "1"); + this->AddFindDefinition(req, "1"_s); + } + + if (!this->VersionComplete.empty()) { + std::string req = cmStrCat(this->Name, "_FIND_VERSION_COMPLETE"); + this->AddFindDefinition(req, this->VersionComplete); } + // Tell the module that is about to be read what version of the + // package has been requested. + auto addDefinition = [this](const std::string& variable, + cm::string_view value) { + this->AddFindDefinition(variable, value); + }; + if (!this->Version.empty()) { - // Tell the module that is about to be read what version of the - // package has been requested. - std::string ver = cmStrCat(this->Name, "_FIND_VERSION"); - this->AddFindDefinition(ver, this->Version.c_str()); - char buf[64]; - sprintf(buf, "%u", this->VersionMajor); - this->AddFindDefinition(ver + "_MAJOR", buf); - sprintf(buf, "%u", this->VersionMinor); - this->AddFindDefinition(ver + "_MINOR", buf); - sprintf(buf, "%u", this->VersionPatch); - this->AddFindDefinition(ver + "_PATCH", buf); - sprintf(buf, "%u", this->VersionTweak); - this->AddFindDefinition(ver + "_TWEAK", buf); - sprintf(buf, "%u", this->VersionCount); - this->AddFindDefinition(ver + "_COUNT", buf); + auto prefix = cmStrCat(this->Name, "_FIND_VERSION"_s); + this->SetVersionVariables(addDefinition, prefix, this->Version, + this->VersionCount, this->VersionMajor, + this->VersionMinor, this->VersionPatch, + this->VersionTweak); // Tell the module whether an exact version has been requested. - std::string exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT"); - this->AddFindDefinition(exact, this->VersionExact ? "1" : "0"); + auto exact = cmStrCat(this->Name, "_FIND_VERSION_EXACT"); + this->AddFindDefinition(exact, this->VersionExact ? "1"_s : "0"_s); + } + if (!this->VersionRange.empty()) { + auto prefix = cmStrCat(this->Name, "_FIND_VERSION_MIN"_s); + this->SetVersionVariables(addDefinition, prefix, this->Version, + this->VersionCount, this->VersionMajor, + this->VersionMinor, this->VersionPatch, + this->VersionTweak); + + prefix = cmStrCat(this->Name, "_FIND_VERSION_MAX"_s); + this->SetVersionVariables(addDefinition, prefix, this->VersionMax, + this->VersionMaxCount, this->VersionMaxMajor, + this->VersionMaxMinor, this->VersionMaxPatch, + this->VersionMaxTweak); + + auto id = cmStrCat(this->Name, "_FIND_VERSION_RANGE"); + this->AddFindDefinition(id, this->VersionRange); + id = cmStrCat(this->Name, "_FIND_VERSION_RANGE_MIN"); + this->AddFindDefinition(id, this->VersionRangeMin); + id = cmStrCat(this->Name, "_FIND_VERSION_RANGE_MAX"); + this->AddFindDefinition(id, this->VersionRangeMax); } } void cmFindPackageCommand::AddFindDefinition(const std::string& var, - const char* val) + cm::string_view value) { if (cmProp old = this->Makefile->GetDefinition(var)) { this->OriginalDefs[var].exists = true; @@ -681,9 +723,7 @@ void cmFindPackageCommand::AddFindDefinition(const std::string& var, } else { this->OriginalDefs[var].exists = false; } - if (val) { - this->Makefile->AddDefinition(var, val); - } + this->Makefile->AddDefinition(var, value); } void cmFindPackageCommand::RestoreFindDefinitions() @@ -881,7 +921,9 @@ bool cmFindPackageCommand::HandlePackageMode( e << "Could not find a configuration file for package \"" << this->Name << "\" that " << (this->VersionExact ? "exactly matches" : "is compatible with") - << " requested version \"" << this->Version << "\".\n" + << " requested version " + << (this->VersionRange.empty() ? "" : "range ") << "\"" + << this->VersionComplete << "\".\n" << "The following configuration files were considered but not " "accepted:\n"; @@ -891,9 +933,9 @@ bool cmFindPackageCommand::HandlePackageMode( } } else { std::string requestedVersionString; - if (!this->Version.empty()) { + if (!this->VersionComplete.empty()) { requestedVersionString = - cmStrCat(" (requested version ", this->Version, ')'); + cmStrCat(" (requested version ", this->VersionComplete, ')'); } if (this->UseConfigFiles) { @@ -1182,7 +1224,9 @@ void cmFindPackageCommand::AppendSuccessInformation() std::string versionInfoPropName = cmStrCat("_CMAKE_", this->Name, "_REQUIRED_VERSION"); std::string versionInfo; - if (!this->Version.empty()) { + if (!this->VersionRange.empty()) { + versionInfo = this->VersionRange; + } else if (!this->Version.empty()) { versionInfo = cmStrCat(this->VersionExact ? "==" : ">=", ' ', this->Version); } @@ -1725,18 +1769,34 @@ bool cmFindPackageCommand::CheckVersionFile(std::string const& version_file, // Set the input variables. this->Makefile->AddDefinition("PACKAGE_FIND_NAME", this->Name); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION", this->Version); - char buf[64]; - sprintf(buf, "%u", this->VersionMajor); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MAJOR", buf); - sprintf(buf, "%u", this->VersionMinor); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_MINOR", buf); - sprintf(buf, "%u", this->VersionPatch); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_PATCH", buf); - sprintf(buf, "%u", this->VersionTweak); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_TWEAK", buf); - sprintf(buf, "%u", this->VersionCount); - this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COUNT", buf); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_COMPLETE", + this->VersionComplete); + + auto addDefinition = [this](const std::string& variable, + cm::string_view value) { + this->Makefile->AddDefinition(variable, value); + }; + this->SetVersionVariables(addDefinition, "PACKAGE_FIND_VERSION", + this->Version, this->VersionCount, + this->VersionMajor, this->VersionMinor, + this->VersionPatch, this->VersionTweak); + if (!this->VersionRange.empty()) { + this->SetVersionVariables(addDefinition, "PACKAGE_FIND_VERSION_MIN", + this->Version, this->VersionCount, + this->VersionMajor, this->VersionMinor, + this->VersionPatch, this->VersionTweak); + this->SetVersionVariables(addDefinition, "PACKAGE_FIND_VERSION_MAX", + this->VersionMax, this->VersionMaxCount, + this->VersionMaxMajor, this->VersionMaxMinor, + this->VersionMaxPatch, this->VersionMaxTweak); + + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_RANGE", + this->VersionComplete); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_RANGE_MIN", + this->VersionRangeMin); + this->Makefile->AddDefinition("PACKAGE_FIND_VERSION_RANGE_MAX", + this->VersionRangeMax); + } // Load the version check file. Pass NoPolicyScope because we do // our own policy push/pop independent of CMP0011. @@ -1798,24 +1858,19 @@ void cmFindPackageCommand::StoreVersionFound() { // Store the whole version string. std::string ver = cmStrCat(this->Name, "_VERSION"); + auto addDefinition = [this](const std::string& variable, + cm::string_view value) { + this->Makefile->AddDefinition(variable, value); + }; + + this->SetVersionVariables(addDefinition, ver, this->VersionFound, + this->VersionFoundCount, this->VersionFoundMajor, + this->VersionFoundMinor, this->VersionFoundPatch, + this->VersionFoundTweak); + if (this->VersionFound.empty()) { this->Makefile->RemoveDefinition(ver); - } else { - this->Makefile->AddDefinition(ver, this->VersionFound); } - - // Store the version components. - char buf[64]; - sprintf(buf, "%u", this->VersionFoundMajor); - this->Makefile->AddDefinition(ver + "_MAJOR", buf); - sprintf(buf, "%u", this->VersionFoundMinor); - this->Makefile->AddDefinition(ver + "_MINOR", buf); - sprintf(buf, "%u", this->VersionFoundPatch); - this->Makefile->AddDefinition(ver + "_PATCH", buf); - sprintf(buf, "%u", this->VersionFoundTweak); - this->Makefile->AddDefinition(ver + "_TWEAK", buf); - sprintf(buf, "%u", this->VersionFoundCount); - this->Makefile->AddDefinition(ver + "_COUNT", buf); } class cmFileListGeneratorBase diff --git a/Source/cmFindPackageCommand.h b/Source/cmFindPackageCommand.h index eacd1ce..edf32d4 100644 --- a/Source/cmFindPackageCommand.h +++ b/Source/cmFindPackageCommand.h @@ -11,6 +11,8 @@ #include <string> #include <vector> +#include <cm/string_view> + #include <cm3p/kwiml/int.h> #include "cmFindCommon.h" @@ -88,9 +90,15 @@ private: void AppendSuccessInformation(); void AppendToFoundProperty(bool found); + void SetVersionVariables( + const std::function<void(const std::string&, cm::string_view)>& + addDefinition, + const std::string& prefix, const std::string& version, unsigned int count, + unsigned int major, unsigned int minor, unsigned int patch, + unsigned int tweak); void SetModuleVariables(const std::string& components); bool FindModule(bool& found); - void AddFindDefinition(const std::string& var, const char* val); + void AddFindDefinition(const std::string& var, cm::string_view value); void RestoreFindDefinitions(); enum /*class*/ HandlePackageModeType @@ -150,34 +158,47 @@ private: std::map<std::string, cmPolicies::PolicyID> DeprecatedFindModules; + static const cm::string_view VERSION_ENDPOINT_INCLUDED; + static const cm::string_view VERSION_ENDPOINT_EXCLUDED; + std::string Name; std::string Variable; + std::string VersionComplete; + std::string VersionRange; + cm::string_view VersionRangeMin; + cm::string_view VersionRangeMax; std::string Version; - unsigned int VersionMajor; - unsigned int VersionMinor; - unsigned int VersionPatch; - unsigned int VersionTweak; - unsigned int VersionCount; - bool VersionExact; + unsigned int VersionMajor = 0; + unsigned int VersionMinor = 0; + unsigned int VersionPatch = 0; + unsigned int VersionTweak = 0; + unsigned int VersionCount = 0; + std::string VersionMax; + unsigned int VersionMaxMajor = 0; + unsigned int VersionMaxMinor = 0; + unsigned int VersionMaxPatch = 0; + unsigned int VersionMaxTweak = 0; + unsigned int VersionMaxCount = 0; + bool VersionExact = false; std::string FileFound; std::string VersionFound; - unsigned int VersionFoundMajor; - unsigned int VersionFoundMinor; - unsigned int VersionFoundPatch; - unsigned int VersionFoundTweak; - unsigned int VersionFoundCount; - KWIML_INT_uint64_t RequiredCMakeVersion; - bool Quiet; - bool Required; - bool UseConfigFiles; - bool UseFindModules; - bool NoUserRegistry; - bool NoSystemRegistry; - bool UseLib32Paths; - bool UseLib64Paths; - bool UseLibx32Paths; - bool UseRealPath; - bool PolicyScope; + unsigned int VersionFoundMajor = 0; + unsigned int VersionFoundMinor = 0; + unsigned int VersionFoundPatch = 0; + unsigned int VersionFoundTweak = 0; + unsigned int VersionFoundCount = 0; + KWIML_INT_uint64_t RequiredCMakeVersion = 0; + bool Quiet = false; + bool Required = false; + bool UseConfigFiles = true; + bool UseFindModules = true; + bool NoUserRegistry = false; + bool NoSystemRegistry = false; + bool UseLib32Paths = false; + bool UseLib64Paths = false; + bool UseLibx32Paths = false; + bool UseRealPath = false; + bool PolicyScope = true; std::string LibraryArchitecture; std::vector<std::string> Names; std::vector<std::string> Configs; @@ -185,9 +206,9 @@ private: std::string DebugBuffer; /*! the selected sortOrder (None by default)*/ - SortOrderType SortOrder; + SortOrderType SortOrder = None; /*! the selected sortDirection (Asc by default)*/ - SortDirectionType SortDirection; + SortDirectionType SortDirection = Asc; struct ConfigFileInfo { diff --git a/Tests/ExportImport/Import/CMakeLists.txt b/Tests/ExportImport/Import/CMakeLists.txt index 189f7a2..a8a98fc 100644 --- a/Tests/ExportImport/Import/CMakeLists.txt +++ b/Tests/ExportImport/Import/CMakeLists.txt @@ -23,3 +23,6 @@ add_subdirectory(try_compile) # Test package INTERFACE controls add_subdirectory(Interface) + +# Test package version range +add_subdirectory(version_range) diff --git a/Tests/ExportImport/Import/version_range/CMakeLists.txt b/Tests/ExportImport/Import/version_range/CMakeLists.txt new file mode 100644 index 0000000..73b1d1e --- /dev/null +++ b/Tests/ExportImport/Import/version_range/CMakeLists.txt @@ -0,0 +1,15 @@ + +cmake_minimum_required(VERSION 3.18) + +find_package(testLibRequired 2.0...3.0) + +if (NOT testLibRequired_FOUND) + message(SEND_ERROR "version_range: fail to find package testLibRequired(2.5) with range 2.0...3.0") +endif() + + +find_package(testLibRequired 2.0...<2.5) + +if (testLibRequired_FOUND) + message(SEND_ERROR "version_range: package testLibRequired(2.5) unexpectedly found with range 2.0...<2.5") +endif() diff --git a/Tests/RunCMake/FPHSA/FindPseudoRange.cmake b/Tests/RunCMake/FPHSA/FindPseudoRange.cmake new file mode 100644 index 0000000..ad0342c --- /dev/null +++ b/Tests/RunCMake/FPHSA/FindPseudoRange.cmake @@ -0,0 +1,7 @@ +# pseudo find_module + +set(FOOBAR TRUE) + +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(PseudoRange REQUIRED_VARS FOOBAR VERSION_VAR PseudoRange_VERSION + HANDLE_VERSION_RANGE) diff --git a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake index 8e39090..e4b8700 100644 --- a/Tests/RunCMake/FPHSA/RunCMakeTest.cmake +++ b/Tests/RunCMake/FPHSA/RunCMakeTest.cmake @@ -55,3 +55,15 @@ run_cmake(required_and_optional_components) run_cmake(all_optional_components) list(APPEND RunCMake_TEST_OPTIONS "-DUseComponents_REQUIRE_VARS=TRUE") run_cmake(required_components_with_vars) + +# check handling of version range +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudo_VERSION=2.3.4.5") +run_cmake(range_ignored) +set(RunCMake_TEST_OPTIONS "-DCMAKE_MODULE_PATH=${CMAKE_CURRENT_LIST_DIR}" "-DPseudoRange_VERSION=2.0") +run_cmake(range_no-range) +run_cmake(range_empty-1) +run_cmake(range_empty-2) +run_cmake(range_1-3) +run_cmake(range_1-2-include) +run_cmake(range_1-2-exclude) +run_cmake(range_3-4) diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt b/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt b/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt new file mode 100644 index 0000000..8e34630 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude-stderr.txt @@ -0,0 +1,2 @@ + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is "1.0...<2.0" \(found TRUE\) diff --git a/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake b/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake new file mode 100644 index 0000000..0cba368 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-exclude.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...<2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_1-2-include.cmake b/Tests/RunCMake/FPHSA/range_1-2-include.cmake new file mode 100644 index 0000000..467267f --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-2-include.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_1-3.cmake b/Tests/RunCMake/FPHSA/range_1-3.cmake new file mode 100644 index 0000000..f1506c5 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_1-3.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0...3.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_3-4-result.txt b/Tests/RunCMake/FPHSA/range_3-4-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_3-4-stderr.txt b/Tests/RunCMake/FPHSA/range_3-4-stderr.txt new file mode 100644 index 0000000..8ea19ce --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4-stderr.txt @@ -0,0 +1,2 @@ + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is "3.0...4.0" \(found TRUE\) diff --git a/Tests/RunCMake/FPHSA/range_3-4.cmake b/Tests/RunCMake/FPHSA/range_3-4.cmake new file mode 100644 index 0000000..dd19314 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_3-4.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 3.0...4.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_empty-1-result.txt b/Tests/RunCMake/FPHSA/range_empty-1-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-1-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt b/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt new file mode 100644 index 0000000..e1c741a --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-1-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is empty \("3\.0\.\.\.2\.0"\) \(found TRUE\) +Call Stack \(most recent call first\): + .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) + FindPseudoRange.cmake:[0-9]+ \(find_package_handle_standard_args\) diff --git a/Tests/RunCMake/FPHSA/range_empty-1.cmake b/Tests/RunCMake/FPHSA/range_empty-1.cmake new file mode 100644 index 0000000..c510d7d --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-1.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 3.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_empty-2-result.txt b/Tests/RunCMake/FPHSA/range_empty-2-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-2-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt b/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt new file mode 100644 index 0000000..ee0e79a --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-2-stderr.txt @@ -0,0 +1,6 @@ +CMake Error at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + Could NOT find PseudoRange: Found unsuitable version "2\.0", required range + is empty \("2\.0\.\.\.<2.0"\) \(found TRUE\) +Call Stack \(most recent call first\): + .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(_FPHSA_FAILURE_MESSAGE\) + FindPseudoRange.cmake:[0-9]+ \(find_package_handle_standard_args\) diff --git a/Tests/RunCMake/FPHSA/range_empty-2.cmake b/Tests/RunCMake/FPHSA/range_empty-2.cmake new file mode 100644 index 0000000..3ce90e8 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_empty-2.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 2.0...<2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_ignored-stderr.txt b/Tests/RunCMake/FPHSA/range_ignored-stderr.txt new file mode 100644 index 0000000..43f2336 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_ignored-stderr.txt @@ -0,0 +1,4 @@ +CMake Warning \(dev\) at .+FindPackageHandleStandardArgs.cmake:[0-9]+ \(message\): + `find_package\(\)` specify a version range but the module Pseudo does not + support this capability. Only the lower endpoint of the range will be + used. diff --git a/Tests/RunCMake/FPHSA/range_ignored.cmake b/Tests/RunCMake/FPHSA/range_ignored.cmake new file mode 100644 index 0000000..ff1ad15 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_ignored.cmake @@ -0,0 +1 @@ +find_package(Pseudo 1.0...2.0 REQUIRED) diff --git a/Tests/RunCMake/FPHSA/range_no-range.cmake b/Tests/RunCMake/FPHSA/range_no-range.cmake new file mode 100644 index 0000000..24896b1 --- /dev/null +++ b/Tests/RunCMake/FPHSA/range_no-range.cmake @@ -0,0 +1 @@ +find_package(PseudoRange 1.0 REQUIRED) diff --git a/Tests/RunCMake/find_package/FindVersionRange.cmake b/Tests/RunCMake/find_package/FindVersionRange.cmake new file mode 100644 index 0000000..ff84e93 --- /dev/null +++ b/Tests/RunCMake/find_package/FindVersionRange.cmake @@ -0,0 +1,82 @@ + +if (NOT VersionRange_FIND_VERSION_COMPLETE STREQUAL VersionRange_SPECIFIED_VERSION_COMPLETE) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_COMPLETE: ${VersionRange_FIND_VERSION_COMPLETE}") +endif() + +if (NOT VersionRange_FIND_VERSION VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION: ${VersionRange_FIND_VERSION}") +endif() +if (NOT VersionRange_FIND_VERSION_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAJOR: ${VersionRange_FIND_VERSION_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MINOR: ${VersionRange_FIND_VERSION_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_PATCH: ${VersionRange_FIND_VERSION_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_TWEAK: ${VersionRange_FIND_VERSION_TWEAK}") +endif() + +if (NOT VersionRange_FIND_VERSION_RANGE STREQUAL VersionRange_SPECIFIED_VERSION_RANGE) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE: ${VersionRange_FIND_VERSION_RANGE}") +endif() +if (NOT VersionRange_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MIN: ${VersionRange_FIND_VERSION_RANGE_MIN}") +endif() +if (VersionRange_FIND_VERSION_RANGE MATCHES "<[0-9.]+$") + if (NOT VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MAX: ${VersionRange_FIND_VERSION_RANGE_MAX}") + endif() +else() + if (NOT VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_RANGE_MAX: ${VersionRange_FIND_VERSION_RANGE_MAX}") + endif() +endif() + +if (NOT VersionRange_FIND_VERSION_MIN VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN: ${VersionRange_FIND_VERSION}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MAJOR: ${VersionRange_FIND_VERSION_MIN_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_MINOR: ${VersionRange_FIND_VERSION_MIN_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_PATCH: ${VersionRange_FIND_VERSION_MIN_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_MIN_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MIN_TWEAK: ${VersionRange_FIND_VERSION_MIN_TWEAK}") +endif() + +if (NOT VersionRange_FIND_VERSION_MAX VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX: ${VersionRange_FIND_VERSION_MAX}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_MAJOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_MAJOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX_MAJOR: ${VersionRange_FIND_VERSION_MAX_MAJOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_MINOR VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_MINOR) + message (SEND_ERROR "Wrong value for VersionRange_FIND_VERSION_MAX_MINOR: ${VersionRange_FIND_VERSION_MAX_MINOR}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_PATCH VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_PATCH) + message (SEND_ERROR "Wrong value for VersionRange_VERSION_FIND_MAX_PATCH: ${VersionRange_FIND_VERSION_MAX_PATCH}") +endif() +if (NOT VersionRange_FIND_VERSION_MAX_TWEAK VERSION_EQUAL VersionRange_SPECIFIED_VERSION_MAX_TWEAK) + message (SEND_ERROR "Wrong value for VersionRange_VERSION_FIND_MAX_TWEAK: ${VersionRange_FIND_VERSION_MAX_TWEAK}") +endif() + +if ((VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE" + AND "2.3.4.5" VERSION_LESS_EQUAL VersionRange_FIND_VERSION_MAX) + OR (VersionRange_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE" + AND "2.3.4.5" VERSION_LESS VersionRange_FIND_VERSION_MAX)) +set (VersionRange_FOUND TRUE) +set (VersionRange_VERSION 2.3.4.5) +set (VersionRange_VERSION_MAJOR 2) +set (VersionRange_VERSION_MINOR 3) +set (VersionRange_VERSION_PATCH 4) +set (VersionRange_VERSION_TWEAK 5) +else() + set (VersionRange_FOUND FALSE) +endif() diff --git a/Tests/RunCMake/find_package/RunCMakeTest.cmake b/Tests/RunCMake/find_package/RunCMakeTest.cmake index 5186297..7755a70 100644 --- a/Tests/RunCMake/find_package/RunCMakeTest.cmake +++ b/Tests/RunCMake/find_package/RunCMakeTest.cmake @@ -29,6 +29,15 @@ run_cmake(WrongVersionConfig) run_cmake(CMP0084-OLD) run_cmake(CMP0084-WARN) run_cmake(CMP0084-NEW) +run_cmake(WrongVersionRange) +run_cmake(VersionRangeWithEXACT) +run_cmake(VersionRange) +run_cmake(VersionRange2) +run_cmake(VersionRange3) +run_cmake(VersionRangeConfig) +run_cmake(VersionRangeConfig2) +run_cmake(VersionRangeConfigStd) +run_cmake(VersionRangeConfigStd2) if(UNIX) run_cmake(SetFoundResolved) endif() diff --git a/Tests/RunCMake/find_package/VersionRange.cmake b/Tests/RunCMake/find_package/VersionRange.cmake new file mode 100644 index 0000000..b3d8950 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange.cmake @@ -0,0 +1,32 @@ + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 7) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 8) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRange2.cmake b/Tests/RunCMake/find_package/VersionRange2.cmake new file mode 100644 index 0000000..d0e685b --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange2.cmake @@ -0,0 +1,32 @@ + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX 5.6.7.8) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 5) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 6) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 7) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 8) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRange3.cmake b/Tests/RunCMake/find_package/VersionRange3.cmake new file mode 100644 index 0000000..76eef1d --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRange3.cmake @@ -0,0 +1,44 @@ + +# show the effect of the exclusion or inclusion of the upper endpoint + +set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}") + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...<2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...<2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MAX 2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_MAX_MAJOR 2) +set (VersionRange_SPECIFIED_VERSION_MAX_MINOR 3) +set (VersionRange_SPECIFIED_VERSION_MAX_PATCH 4) +set (VersionRange_SPECIFIED_VERSION_MAX_TWEAK 5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange found unexpectedly.") +endif() + + +set (VersionRange_SPECIFIED_VERSION_COMPLETE 1.2.3.4...2.3.4.5) +set (VersionRange_SPECIFIED_VERSION_RANGE 1.2.3.4...2.3.4.5) + +find_package (VersionRange ${VersionRange_SPECIFIED_VERSION_RANGE}) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfig.cmake diff --git a/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake new file mode 100644 index 0000000..e9f6076 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeCfg/VersionRangeCfgConfigVersion.cmake @@ -0,0 +1,74 @@ + +if (NOT PACKAGE_FIND_VERSION_COMPLETE STREQUAL "1.2.3.4...5.6.7.8" + AND NOT PACKAGE_FIND_VERSION_COMPLETE STREQUAL "1.2.3.4...<5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_COMPLETE: ${PACKAGE_FIND_VERSION_COMPLETE}") +endif() + +if (NOT PACKAGE_FIND_VERSION VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION: ${PACKAGE_FIND_VERSION}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAJOR: ${PACKAGE_FIND_VERSION_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MINOR: ${PACKAGE_FIND_VERSION_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_PATCH: ${PACKAGE_FIND_VERSION_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_TWEAK: ${PACKAGE_FIND_VERSION_TWEAK}") +endif() + +if (NOT PACKAGE_FIND_VERSION_RANGE STREQUAL "1.2.3.4...5.6.7.8" + AND NOT PACKAGE_FIND_VERSION_RANGE STREQUAL "1.2.3.4...<5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE: ${PACKAGE_FIND_VERSION_RANGE}") +endif() + +if (NOT PACKAGE_FIND_VERSION_RANGE_MIN STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MIN: ${PACKAGE_FIND_VERSION_RANGE_MIN}") +endif() +if (PACKAGE_FIND_VERSION_RANGE MATCHES "<[0-9.]+$") + if (NOT PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "EXCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MAX: ${PACKAGE_FIND_VERSION_RANGE_MAX}") + endif() +else() + if (NOT PACKAGE_FIND_VERSION_RANGE_MAX STREQUAL "INCLUDE") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_RANGE_MAX: ${PACKAGE_FIND_VERSION_RANGE_MAX}") + endif() +endif() + +if (NOT PACKAGE_FIND_VERSION_MIN VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN: ${PACKAGE_FIND_VERSION_MIN}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_MAJOR: ${PACKAGE_FIND_VERSION_MIN_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_MINOR: ${PACKAGE_FIND_VERSION_MIN_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_PATCH: ${PACKAGE_FIND_VERSION_MIN_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_MIN_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MIN_TWEAK: ${PACKAGE_FIND_VERSION_MIN_TWEAK}") +endif() + +if (NOT PACKAGE_FIND_VERSION_MAX VERSION_EQUAL "5.6.7.8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX: ${PACKAGE_FIND_VERSION_MAX}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_MAJOR VERSION_EQUAL "5") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_MAJOR: ${PACKAGE_FIND_VERSION_MAX_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_MINOR VERSION_EQUAL "6") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_MINOR: ${PACKAGE_FIND_VERSION_MAX_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_PATCH VERSION_EQUAL "7") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAXPATCH: ${PACKAGE_FIND_VERSION_MAX_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAX_TWEAK VERSION_EQUAL "8") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAX_TWEAK: ${PACKAGE_FIND_VERSION_MAX_TWEAK}") +endif() + +set (PACKAGE_VERSION 2.3.4.5) +set (PACKAGE_VERSION_COMPATIBLE TRUE) diff --git a/Tests/RunCMake/find_package/VersionRangeConfig.cmake b/Tests/RunCMake/find_package/VersionRangeConfig.cmake new file mode 100644 index 0000000..b39a966 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfig.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...5.6.7.8 CONFIG NAMES VersionRangeCfg) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfig2.cmake b/Tests/RunCMake/find_package/VersionRangeConfig2.cmake new file mode 100644 index 0000000..04c570a --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfig2.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...<5.6.7.8 CONFIG NAMES VersionRangeCfg) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake b/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake new file mode 100644 index 0000000..3ffc72f --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfigStd.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4 CONFIG NAMES VersionRangeStd) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake b/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake new file mode 100644 index 0000000..8b48828 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeConfigStd2.cmake @@ -0,0 +1,23 @@ +set(CMAKE_PREFIX_PATH ${CMAKE_CURRENT_SOURCE_DIR}) + +find_package(VersionRange 1.2.3.4...5.6.7.8 CONFIG NAMES VersionRangeStd) + +if (NOT VersionRange_FOUND) + message (FATAL_ERROR "Package VersionRange not found in CONFIG mode.") +endif() + +if (NOT VersionRange_VERSION VERSION_EQUAL "2.3.4.5") + message (SEND_ERROR "Wrong version : ${VersionRange_VERSION}") +endif() +if (NOT VersionRange_VERSION_MAJOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong major version : ${VersionRange_VERSION_MAJOR}") +endif() +if (NOT VersionRange_VERSION_MINOR VERSION_EQUAL "3") + message (SEND_ERROR "Wrong minor version : ${VersionRange_VERSION_MINOR}") +endif() +if (NOT VersionRange_VERSION_PATCH VERSION_EQUAL "4") + message (SEND_ERROR "Wrong patch version : ${VersionRange_VERSION_PATCH}") +endif() +if (NOT VersionRange_VERSION_TWEAK VERSION_EQUAL "5") + message (SEND_ERROR "Wrong tweak version : ${VersionRange_VERSION_TWEAK}") +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfig.cmake diff --git a/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake new file mode 100644 index 0000000..6e9151c --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeStd/VersionRangeStdConfigVersion.cmake @@ -0,0 +1,24 @@ + +if (NOT PACKAGE_FIND_VERSION VERSION_EQUAL "1.2.3.4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION: ${PACKAGE_FIND_VERSION}") +endif() +if (NOT PACKAGE_FIND_VERSION_MAJOR VERSION_EQUAL "1") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MAJOR: ${PACKAGE_FIND_VERSION_MAJOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_MINOR VERSION_EQUAL "2") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_MINOR: ${PACKAGE_FIND_VERSION_MINOR}") +endif() +if (NOT PACKAGE_FIND_VERSION_PATCH VERSION_EQUAL "3") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_PATCH: ${PACKAGE_FIND_VERSION_PATCH}") +endif() +if (NOT PACKAGE_FIND_VERSION_TWEAK VERSION_EQUAL "4") + message (SEND_ERROR "Wrong value for PACKAGE_FIND_VERSION_TWEAK: ${PACKAGE_FIND_VERSION_TWEAK}") +endif() + +set (PACKAGE_VERSION 2.3.4.5) + +if (PACKAGE_FIND_VERSION VERSION_LESS_EQUAL PACKAGE_VERSION) + set (PACKAGE_VERSION_COMPATIBLE TRUE) +else() + set (PACKAGE_VERSION_UNSUITABLE TRUE) +endif() diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt b/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt b/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt new file mode 100644 index 0000000..6319aee --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT-stderr.txt @@ -0,0 +1,2 @@ +CMake Error at VersionRangeWithEXACT.cmake:[0-9]+ \(find_package\): + find_package EXACT cannot be specified with a version range. diff --git a/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake b/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake new file mode 100644 index 0000000..419c7c5 --- /dev/null +++ b/Tests/RunCMake/find_package/VersionRangeWithEXACT.cmake @@ -0,0 +1 @@ +find_package(VersionRange 1.2...3.4 EXACT) diff --git a/Tests/RunCMake/find_package/WrongVersionRange-result.txt b/Tests/RunCMake/find_package/WrongVersionRange-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt b/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt new file mode 100644 index 0000000..fe0b088 --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange-stderr.txt @@ -0,0 +1,28 @@ +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\." +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "\.\.\.1\.2" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\.\.2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2\.\.\.>2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) + + +CMake Error at WrongVersionRange.cmake:[0-9]+ \(find_package\): + find_package called with invalid argument "1\.2>\.\.\.2\.3" +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\) diff --git a/Tests/RunCMake/find_package/WrongVersionRange.cmake b/Tests/RunCMake/find_package/WrongVersionRange.cmake new file mode 100644 index 0000000..9851ade --- /dev/null +++ b/Tests/RunCMake/find_package/WrongVersionRange.cmake @@ -0,0 +1,9 @@ +find_package(VersionRange 1.2...) + +find_package(VersionRange ...1.2) + +find_package(VersionRange 1.2....2.3) + +find_package(VersionRange 1.2...>2.3) + +find_package(VersionRange 1.2>...2.3) |