6 Commits

Author SHA1 Message Date
Xaymar 0abbdf73e9 Add missing editorconfig file 2026-01-16 09:59:52 +01:00
Michael Fabian 'Xaymar' Dirks 3bef96bafa Version 1.4.1 2023-04-23 01:46:09 +02:00
Michael Fabian 'Xaymar' Dirks 4ab58b18ac tests: Fix some command generation problems
Can't figure out how to generate this correctly. 🤷
2023-04-23 01:45:55 +02:00
Michael Fabian 'Xaymar' Dirks 6f4488a833 code: Attempt to fix REQUIRE behavior 2023-04-23 01:45:15 +02:00
Michael Fabian 'Xaymar' Dirks 16bfa9568c Version 1.4.0 2022-08-21 07:25:19 +02:00
Michael Fabian 'Xaymar' Dirks e442dea08d code: Add REQUIRE to GENERATE command
Allows generating versions which contain all necessary components
2022-08-21 07:24:42 +02:00
6 changed files with 173 additions and 262 deletions
+21
View File
@@ -0,0 +1,21 @@
# AUTOGENERATED COPYRIGHT HEADER START
# Copyright (C) 2017-2024 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
# AUTOGENERATED COPYRIGHT HEADER END
# top-most EditorConfig file
root = true
# Unix-style newlines with a newline ending every file.
[*]
insert_final_newline = true
trim_trailing_whitespace = true
charset = utf-8
indent_style = tab
indent_size = 4
[*.yml]
indent_style = space
indent_size = 2
[*.md]
trim_trailing_whitespace = false
+2 -2
View File
@@ -20,8 +20,8 @@
project = 'version'
copyright = "2022, Michael Fabian Dirks"
author = "Michael Fabian 'Xaymar' Dirks"
version = "1.3.0"
release = "1.3.0"
version = "1.4.1"
release = "1.4.1"
# -- General configuration ---------------------------------------------------
+9 -3
View File
@@ -9,7 +9,7 @@ Synopsis
.. parsed-literal::
version(`PARSE`_ <out-var> [REQUIRE [PATCH|TWEAK][;...]] <string>)
version(`GENERATE`_ <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
version(`GENERATE`_ <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>] [REQUIRE [PATCH|TWEAK][;...]])
version(`MODIFY`_ <out-var> <string> [COMPRESS] [MAJOR <major>] [MINOR <minor] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>] [REQUIRE [PATCH|TWEAK][;...]])
version(`COMPARE`_ <out-var> <a> <b>)
@@ -31,6 +31,8 @@ Parsing
Attempts to parse the version in ``<string>`` and stores the individual compoents into ``<out-var>_<component>``. If a component is not present in the given version, it will be set to a false constant. If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant. The ``PRERELEASE`` and ``BUILD`` components support the dot-separation specifier and will be turned into a list if they are encountered. The optional ``REQUIRE`` allows forcing the components ``PATCH`` and ``TWEAK`` to always be defined.
It is necessary to include a ``;`` for the ``REQUIRE`` parameter, even if there is only one required part.
Generating
^^^^^^^^^^
@@ -38,9 +40,11 @@ Generating
.. code-block:: cmake
version(GENERATE <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
version(GENERATE <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>] [REQUIRE [PATCH|TWEAK][;...]])
Generates a version from the components provided and stores the result in ``<out-var>``. The components ``<major>`` and ``<minor>`` will default to ``0`` if not provided. If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant. The ``PRERELEASE`` and ``BUILD`` components support the dot-separation specifier and will be converted from a list if encountered.
Generates a version from the components provided and stores the result in ``<out-var>``. The components ``<major>`` and ``<minor>`` will default to ``0`` if not provided. If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant. The ``PRERELEASE`` and ``BUILD`` components support the dot-separation specifier and will be converted from a list if encountered. The optional ``REQUIRE`` allows forcing the components ``PATCH`` and ``TWEAK`` to always be defined.
It is necessary to include a ``;`` for the ``REQUIRE`` parameter, even if there is only one required part.
Modifying
^^^^^^^^^
@@ -53,6 +57,8 @@ Modifying
Modifies the version provided in ``<string>`` with the components provided. The components ``<major>``, ``<minor>``, ``<patch>`` and ``<tweak>`` may have a prefix of ``+`` or ``-`` to add and subtract the value, or no prefix to replace. The result of this operation will be stored as a string in ``<out-var>``. If a component did not exist in the original, it will be added to the version as a replace operation. If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant. The optional ``REQUIRE`` allows forcing the components ``PATCH`` and ``TWEAK`` to always be defined.
It is necessary to include a ``;`` for the ``REQUIRE`` parameter, even if there is only one required part.
Comparing
^^^^^^^^^
+94 -46
View File
@@ -8,25 +8,49 @@ include("helpers.cmake")
# Generation
message(STATUS "\n\n===== Generation =====")
# - Valid Cases
test_generate("0.0")
test_generate("1.0" MAJOR 1)
test_generate("0.2" MINOR 2)
test_generate("0.0.3" PATCH 3)
test_generate("0.0.0.4" TWEAK 4)
test_generate("0.0-5" COMPRESS PRERELEASE 5)
test_generate("0.0a5" COMPRESS PRERELEASE a5)
test_generate("0.0a5.5" COMPRESS PRERELEASE "a5;5")
test_generate("0.0+6" BUILD 6)
test_generate("0.0+6.8" BUILD "6;8")
version(GENERATE _TEST)
compare_test("0.0")
version(GENERATE _TEST MAJOR 1)
compare_test("1.0")
version(GENERATE _TEST MINOR 2)
compare_test("0.2")
version(GENERATE _TEST PATCH 3)
compare_test("0.0.3")
version(GENERATE _TEST TWEAK 4)
compare_test("0.0.0.4")
version(GENERATE _TEST COMPRESS PRERELEASE 5)
compare_test("0.0-5")
version(GENERATE _TEST COMPRESS PRERELEASE a5)
compare_test("0.0a5")
version(GENERATE _TEST COMPRESS PRERELEASE "a5;5")
compare_test("0.0a5.5")
version(GENERATE _TEST BUILD 6)
compare_test("0.0+6")
version(GENERATE _TEST BUILD "6;8")
compare_test("0.0+6.8")
version(GENERATE _TEST MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 BUILD "gABCDEF01")
compare_test("1.2.3.4+gABCDEF01") # Discovered in StreamFX
version(GENERATE _TEST REQUIRE "PATCH;")
compare_test("0.0.0") # Discovered in TonPlugIns, StreamFX
version(GENERATE _TEST REQUIRE "TWEAK;PATCH")
compare_test("0.0.0.0") # Discovered in TonPlugIns, StreamFX
# - Invalid Cases
test_generate("-1.0.0" FAIL MAJOR "-1")
test_generate("0.-1.0" FAIL MINOR "-1")
test_generate("0.0.-1" FAIL PATCH "-1")
test_generate("0.0.0.-1" FAIL TWEAK "-1")
test_generate("0.0.0-#" FAIL PRERELEASE "#")
test_generate("0.0.0-0 0" FAIL PRERELEASE "0 0")
test_generate("0.0.0+#" FAIL BUILD "#")
test_generate("0.0.0+0 0" FAIL BUILD "0 0")
version(GENERATE _TEST MAJOR "-1")
compare_test("-1.0.0" FAIL)
version(GENERATE _TEST MINOR "-1")
compare_test("0.-1.0" FAIL)
version(GENERATE _TEST PATCH "-1")
compare_test("0.0.-1" FAIL)
version(GENERATE _TEST TWEAK "-1")
compare_test("0.0.0.-1" FAIL)
version(GENERATE _TEST PRERELEASE "#")
compare_test("0.0.0-#" FAIL)
version(GENERATE _TEST PRERELEASE "0 0")
compare_test("0.0.0-0 0" FAIL)
version(GENERATE _TEST BUILD "#")
compare_test("0.0.0+#" FAIL)
version(GENERATE _TEST BUILD "0 0")
compare_test("0.0.0+0 0" FAIL)
# Parsing
message(STATUS "\n\n===== Parsing =====")
@@ -63,30 +87,59 @@ test_parse("0.0.0+.0" FAIL)
# Modifying
message(STATUS "\n\n===== Modifying =====")
# - Valid Cases
test_modify("1.2" "0.2" MAJOR 1)
test_modify("1.2" "0.2" MAJOR "+1")
test_modify("1.2" "2.2" MAJOR "-1")
test_modify("1.2" "1.0" MINOR 2)
test_modify("1.2" "1.0" MINOR "+2")
test_modify("1.2" "1.3" MINOR "-1")
test_modify("1.2.3" "1.2" PATCH 3)
test_modify("1.2.3" "1.2.2" PATCH "+1")
test_modify("1.2.3" "1.2.4" PATCH "-1")
test_modify("1.2.0.4" "1.2" TWEAK 4)
test_modify("1.2.3.4" "1.2.3.3" TWEAK "+1")
test_modify("1.2.3.4" "1.2.3.5" TWEAK "-1")
test_modify("1.2-5" "1.2" COMPRESS PRERELEASE 5)
test_modify("1.2a5" "1.2" COMPRESS PRERELEASE a5)
test_modify("1.2+6" "1.2" COMPRESS BUILD 6)
test_modify("1.2-5+6" "1.2" COMPRESS PRERELEASE 5 BUILD 6)
test_modify("1.2a5+6" "1.2" COMPRESS PRERELEASE a5 BUILD 6)
version(MODIFY _TEST "0.2" MAJOR 1)
compare_test("1.2")
version(MODIFY _TEST "0.2" MAJOR "+1")
compare_test("1.2")
version(MODIFY _TEST "2.2" MAJOR "-1")
compare_test("1.2")
version(MODIFY _TEST "1.0" MINOR 2)
compare_test("1.2")
version(MODIFY _TEST "1.0" MINOR "+2")
compare_test("1.2")
version(MODIFY _TEST "1.3" MINOR "-1")
compare_test("1.2")
version(MODIFY _TEST "1.2" PATCH 3)
compare_test("1.2.3")
version(MODIFY _TEST "1.2.2" PATCH "+1")
compare_test("1.2.3")
version(MODIFY _TEST "1.2.4" PATCH "-1")
compare_test("1.2.3")
version(MODIFY _TEST "1.2" TWEAK 4)
compare_test("1.2.0.4")
version(MODIFY _TEST "1.2.3.3" TWEAK "+1")
compare_test("1.2.3.4")
version(MODIFY _TEST "1.2.3.5" TWEAK "-1")
compare_test("1.2.3.4")
version(MODIFY _TEST "1.2" COMPRESS PRERELEASE 5)
compare_test("1.2-5")
version(MODIFY _TEST "1.2" COMPRESS PRERELEASE a5)
compare_test("1.2a5")
version(MODIFY _TEST "1.2" COMPRESS BUILD 6)
compare_test("1.2+6")
version(MODIFY _TEST "1.2" COMPRESS PRERELEASE 5 BUILD 6)
compare_test("1.2-5+6")
version(MODIFY _TEST "1.2" COMPRESS PRERELEASE a5 BUILD 6)
compare_test("1.2a5+6")
version(MODIFY _TEST "0.2.0" TWEAK "4" BUILD "gABCDEF01")
compare_test("0.2.0.4+gABCDEF01") # Discovered in StreamFX
version(MODIFY _TEST "1.2" COMPRESS REQUIRE "PATCH;")
compare_test("1.2.0") # Discovered in TonPlugIns, StreamFX
version(MODIFY _TEST "1.2" COMPRESS REQUIRE "TWEAK;")
compare_test("1.2.0.0") # Discovered in TonPlugIns, StreamFX
# - Invalid Cases
test_modify("0.0" "0.0" FAIL MAJOR -1)
test_modify("0.0" "0.0" FAIL MINOR -1)
test_modify("0.0" "0.0" FAIL PATCH -1)
test_modify("0.0" "0.0" FAIL TWEAK -1)
test_modify("0.0" "0.0" FAIL COMPRESS PRERELEASE "#")
test_modify("0.0" "0.0" FAIL COMPRESS BUILD "#")
version(MODIFY _TEST "0.0" MAJOR -1)
compare_test("0.0" FAIL)
version(MODIFY _TEST "0.0" MINOR -1)
compare_test("0.0" FAIL)
version(MODIFY _TEST "0.0" PATCH -1)
compare_test("0.0" FAIL)
version(MODIFY _TEST "0.0" TWEAK -1)
compare_test("0.0" FAIL)
version(MODIFY _TEST "0.0" COMPRESS PRERELEASE "#")
compare_test("0.0" FAIL)
version(MODIFY _TEST "0.0" COMPRESS BUILD "#")
compare_test("0.0" FAIL)
# Comparing
message(STATUS "\n\n===== Comparing =====")
@@ -111,8 +164,3 @@ test_compare("0.0-5" "+PRERELEASE" "0.0")
test_compare("0.0" "-PRERELEASE" "0.0-5")
test_compare("0.0+6" "+BUILD" "0.0")
test_compare("0.0" "-BUILD" "0.0+6")
# Discovered failure cases
message(STATUS "\n\n===== User-generated Cases =====")
test_generate("1.2.3.4+gABCDEF01" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 BUILD "gABCDEF01")
test_modify("0.2.0.4+gABCDEF01" "0.2.0" TWEAK "4" BUILD "gABCDEF01")
+3 -86
View File
@@ -1,38 +1,13 @@
include("../version.cmake")
function(test_generate)
function(compare_test)
cmake_parse_arguments(
PARSE_ARGV 1
_6edc8bbd
"COMPRESS;FAIL"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
"FAIL"
""
""
)
set(ARGS "")
if(_6edc8bbd_MAJOR)
set(ARGS "${ARGS} MAJOR \"${_6edc8bbd_MAJOR}\"")
endif()
if(_6edc8bbd_MINOR)
set(ARGS "${ARGS} MINOR \"${_6edc8bbd_MINOR}\"")
endif()
if(_6edc8bbd_PATCH)
set(ARGS "${ARGS} PATCH \"${_6edc8bbd_PATCH}\"")
endif()
if(_6edc8bbd_TWEAK)
set(ARGS "${ARGS} TWEAK \"${_6edc8bbd_TWEAK}\"")
endif()
if(_6edc8bbd_PRERELEASE)
set(ARGS "${ARGS} PRERELEASE \"${_6edc8bbd_PRERELEASE}\"")
endif()
if(_6edc8bbd_BUILD)
set(ARGS "${ARGS} BUILD \"${_6edc8bbd_BUILD}\"")
endif()
if(_6edc8bbd_COMPRESS)
set(ARGS "${ARGS} COMPRESS")
endif()
cmake_language(EVAL CODE "version(GENERATE _TEST ${ARGS})")
if(_TEST_ERROR)
if(_6edc8bbd_FAIL)
message(STATUS "PASSED: '${ARGV0}'.\n\t${_TEST_ERROR}")
@@ -139,64 +114,6 @@ function(test_parse)
endif()
endfunction()
function(test_modify)
cmake_parse_arguments(
PARSE_ARGV 2
_6edc8bbd
"FAIL;COMPRESS"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
""
)
set(ARGS "")
if(_6edc8bbd_MAJOR)
set(ARGS "${ARGS} MAJOR \"${_6edc8bbd_MAJOR}\"")
endif()
if(_6edc8bbd_MINOR)
set(ARGS "${ARGS} MINOR \"${_6edc8bbd_MINOR}\"")
endif()
if(_6edc8bbd_PATCH)
set(ARGS "${ARGS} PATCH \"${_6edc8bbd_PATCH}\"")
endif()
if(_6edc8bbd_TWEAK)
set(ARGS "${ARGS} TWEAK \"${_6edc8bbd_TWEAK}\"")
endif()
if(_6edc8bbd_PRERELEASE)
set(ARGS "${ARGS} PRERELEASE \"${_6edc8bbd_PRERELEASE}\"")
endif()
if(_6edc8bbd_BUILD)
set(ARGS "${ARGS} BUILD \"${_6edc8bbd_BUILD}\"")
endif()
if(_6edc8bbd_COMPRESS)
set(ARGS "${ARGS} COMPRESS")
endif()
cmake_language(EVAL CODE "version(MODIFY _TEST \"${ARGV1}\" ${ARGS})")
set(FAILED OFF)
if(_TEST_ERROR)
set(MESSAGE "${_TEST_ERROR}")
set(FAILED ON)
else()
if(NOT (_TEST STREQUAL ARGV0))
set(FAILED ON)
endif()
endif()
if(FAILED)
if(_6edc8bbd_FAIL)
message(STATUS "PASSED: '${ARGV0}' != '${_TEST}'.\n\t${MESSAGE}")
else()
message(SEND_ERROR "FAILED: '${ARGV0}' != '${_TEST}'.\n\t${MESSAGE}")
endif()
else()
if(_6edc8bbd_FAIL)
message(SEND_ERROR "FAILED: '${ARGV0}' == '${_TEST}'.\n\t${MESSAGE}")
else()
message(STATUS "PASSED: '${ARGV0}' == '${_TEST}'.")
endif()
endif()
endfunction()
function(test_compare)
cmake_parse_arguments(
PARSE_ARGV 3
+36 -117
View File
@@ -10,85 +10,7 @@
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
#[=======================================================================[.rst:
version
-------
Generate, parse and modify versions purely with CMake. Supports Semantic Versioning 2.0.0, 1.0.0 and other version formats.
Synopsis
^^^^^^^^
.. parsed-literal::
version(`PARSE`_ <out-var> <string>)
version(`GENERATE`_ <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
version(`MODIFY`_ <out-var> <string> [COMPRESS] [MAJOR <major>] [MINOR <minor] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
version(`COMPARE`_ <out-var> <a> <b>)
The following version constructs are currently supported:
.. code-block::
<major> "." <minor> ["." <patch> ["." <tweak>]]
<major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
Parsing
^^^^^^^
.. _PARSE:
.. code-block:: cmake
version(PARSE <out-var> <string>)
Attempts to parse the version in ``<string>`` and stores the individual compoents into ``<out-var>_<component>``. If a component is not present in the given version, it will be undefined. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
Generating
^^^^^^^^^^
.. _GENERATE:
.. code-block:: cmake
version(GENERATE <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
Generates a version from the components provided and stores the result in ``<out-var>``. The components ``<major>`` and ``<minor>`` will default to ``0`` if not provided. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
Modifying
^^^^^^^^^
.. _MODIFY:
.. code-block:: cmake
version(MODIFY <out-var> <string> [COMPRESS] [MAJOR <major>] [MINOR <minor] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
Modifies the version provided in ``<string>`` with the components provided. The components ``<major>``, ``<minor>``, ``<patch>`` and ``<tweak>`` may have a prefix of ``+`` or ``-`` to add and subtract the value, or no prefix to replace. The result of this operation will be stored as a string in ``<out-var>``. If a component did not exist in the original, it will be added to the version as a replace operation. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
Comparing
^^^^^^^^^
.. _COMPARE:
.. code-block:: cmake
version(COMPARE <out-var> <a> <b>)
Compares the version ``<a>`` against ``<b>`` and stores the result in ``<out-var>``. The provided version will be evaluated in the order MAJOR, MINOR, PATCH, TWEAK, PRERELEASE, and then BUILD. The following results should be expected:
- If a component is only in ``<a>``, ``<out-var>`` will contain the componenent name prefixed by ``+``.
- If a component is only in ``<b>``, ``<out-var>`` will contain the componenent name prefixed by ``-``.
- If a component is numerical and the value is larger in ``<a>``, ``<out-var>`` will contain the componenent name prefixed by ``>``.
- If a component is numerical and the value is larger in ``<b>``, ``<out-var>`` will contain the componenent name prefixed by ``<``.
- If a component is alphanumerical and the value is different in either, ``<out-var>`` will contain the component name with no prefix.
- In all other cases, ``<out-var>`` will be empty.
- If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message, and ``<out-var>`` will be undefined.
#]=======================================================================]
function(version)
function(version MODE OUT_VAR)
# CMake functions do not have their own proper scope, they act more
set(OUT_VAR "${ARGV1}")
@@ -102,8 +24,8 @@ function(version)
PARSE_ARGV 2
_992ae727
""
""
"REQUIRE"
""
)
# <major> "." <minor> ["." <patch> ["." <tweak>]]
# <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
@@ -171,48 +93,48 @@ function(version)
set(_32070faa_PRERELEASE "")
set(_32070faa_BUILD "")
set(_32070faa_ERROR "")
set(_32070faa_REQUIRE "")
cmake_parse_arguments(
PARSE_ARGV 2
_32070faa
"COMPRESS"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD;REQUIRE"
""
)
string(STRIP "${_32070faa_MAJOR}" _32070faa_MAJOR)
string(STRIP "${_32070faa_MINOR}" _32070faa_MINOR)
string(STRIP "${_32070faa_PATCH}" _32070faa_PATCH)
string(STRIP "${_32070faa_TWEAK}" _32070faa_TWEAK)
string(STRIP "${_32070faa_PRERELEASE}" _32070faa_PRERELEASE)
string(STRIP "${_32070faa_BUILD}" _32070faa_BUILD)
# Do we have the major component, and is it valid?
if(NOT "${_32070faa_MAJOR}" STREQUAL "")
string(STRIP "${_32070faa_MAJOR}" _32070faa_MAJOR)
if("${_32070faa_MAJOR}" STREQUAL "")
set(_32070faa_MAJOR 0)
elseif(NOT (_32070faa_MAJOR MATCHES [[^[0-9]+$]]))
set(${OUT_VAR}_ERROR "MAJOR component must be a numeric identifier, but is: '${_32070faa_MAJOR}'" PARENT_SCOPE)
return()
endif()
else()
if(_32070faa_MAJOR STREQUAL "")
set(_32070faa_MAJOR 0)
endif()
if(NOT (_32070faa_MAJOR MATCHES [[^[0-9]+$]]))
set(${OUT_VAR}_ERROR "MAJOR component must be a numeric identifier, but is: '${_32070faa_MAJOR}'" PARENT_SCOPE)
return()
endif()
set(_feeb1eff "${_feeb1eff}${_32070faa_MAJOR}")
# Do we have the minor component, and is it valid?
if(NOT "${_32070faa_MINOR}" STREQUAL "")
string(STRIP "${_32070faa_MINOR}" _32070faa_MINOR)
if("${_32070faa_MINOR}" STREQUAL "")
set(_32070faa_MINOR 0)
elseif(NOT (_32070faa_MINOR MATCHES [[^[0-9]+$]]))
set(${OUT_VAR}_ERROR "MINOR component must be a numeric identifier, but is: '${_32070faa_MINOR}'" PARENT_SCOPE)
return()
endif()
else()
if(_32070faa_MINOR STREQUAL "")
set(_32070faa_MINOR 0)
endif()
if(NOT (_32070faa_MINOR MATCHES [[^[0-9]+$]]))
set(${OUT_VAR}_ERROR "MINOR component must be a numeric identifier, but is: '${_32070faa_MINOR}'" PARENT_SCOPE)
return()
endif()
set(_feeb1eff "${_feeb1eff}.${_32070faa_MINOR}")
# Do we have the patch component, and is it valid?
if(NOT "${_32070faa_PATCH}" STREQUAL "")
string(STRIP "${_32070faa_PATCH}" _32070faa_PATCH)
if("${_32070faa_PATCH}" STREQUAL "")
set(_32070faa_PATCH "")
elseif(_32070faa_PATCH MATCHES [[^[0-9]+$]])
if((("PATCH" IN_LIST _32070faa_REQUIRE) OR ("TWEAK" IN_LIST _32070faa_REQUIRE) OR (NOT _32070faa_TWEAK STREQUAL "")) AND ("${_32070faa_PATCH}" STREQUAL ""))
set(_32070faa_PATCH "0")
endif()
if(NOT _32070faa_PATCH STREQUAL "")
if(_32070faa_PATCH MATCHES [[^[0-9]+$]])
set(_feeb1eff "${_feeb1eff}.${_32070faa_PATCH}")
else()
set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_32070faa_PATCH}'" PARENT_SCOPE)
@@ -221,15 +143,11 @@ function(version)
endif()
# Do we have the tweak component, and is it valid?
if(NOT "${_32070faa_TWEAK}" STREQUAL "")
string(STRIP "${_32070faa_TWEAK}" _32070faa_TWEAK)
if("${_32070faa_TWEAK}" STREQUAL "")
set(_32070faa_TWEAK "")
elseif(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
if("${_32070faa_PATCH}" STREQUAL "")
# Patch did not exist, so it is zero.
set(_feeb1eff "${_feeb1eff}.0")
endif()
if(("TWEAK" IN_LIST _32070faa_REQUIRE) AND (_32070faa_TWEAK STREQUAL ""))
set(_32070faa_TWEAK "0")
endif()
if(NOT _32070faa_TWEAK STREQUAL "")
if(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
set(_feeb1eff "${_feeb1eff}.${_32070faa_TWEAK}")
else()
set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_32070faa_TWEAK}'" PARENT_SCOPE)
@@ -239,7 +157,6 @@ function(version)
# Do we have the pre-release component, and is it valid?
if(NOT "${_32070faa_PRERELEASE}" STREQUAL "")
string(STRIP "${_32070faa_PRERELEASE}" _32070faa_PRERELEASE)
list(JOIN _32070faa_PRERELEASE "." _32070faa_PRERELEASE)
if("${_32070faa_PRERELEASE}" STREQUAL "")
set(_32070faa_PRERELEASE "")
@@ -257,7 +174,6 @@ function(version)
# Do we have the build component, and is it valid?
if(NOT "${_32070faa_BUILD}" STREQUAL "")
string(STRIP "${_32070faa_BUILD}" _32070faa_BUILD)
list(JOIN _32070faa_BUILD "." _32070faa_BUILD)
if("${_32070faa_BUILD}" STREQUAL "")
unset(_32070faa_BUILD)
@@ -284,8 +200,8 @@ function(version)
PARSE_ARGV 3
_fe7bcddd
"COMPRESS"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
"REQUIRE"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD;REQUIRE"
""
)
# Helpers
@@ -355,6 +271,9 @@ function(version)
if(_fe7bcddd_COMPRESS)
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS")
endif()
if(NOT _fe7bcddd_REQUIRE STREQUAL "")
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} REQUIRE \"${_fe7bcddd_REQUIRE}\"")
endif()
cmake_language(EVAL CODE "version(GENERATE _df8abcce ${_fe7bcddd_GEN})")
if(_df8abcce_ERROR)
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)