4 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
6 changed files with 159 additions and 178 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' project = 'version'
copyright = "2022, Michael Fabian Dirks" copyright = "2022, Michael Fabian Dirks"
author = "Michael Fabian 'Xaymar' Dirks" author = "Michael Fabian 'Xaymar' Dirks"
version = "1.4.0" version = "1.4.1"
release = "1.4.0" release = "1.4.1"
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
+6
View File
@@ -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. 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 Generating
^^^^^^^^^^ ^^^^^^^^^^
@@ -42,6 +44,8 @@ Generating
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. 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 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. 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 Comparing
^^^^^^^^^ ^^^^^^^^^
+94 -46
View File
@@ -8,25 +8,49 @@ include("helpers.cmake")
# Generation # Generation
message(STATUS "\n\n===== Generation =====") message(STATUS "\n\n===== Generation =====")
# - Valid Cases # - Valid Cases
test_generate("0.0") version(GENERATE _TEST)
test_generate("1.0" MAJOR 1) compare_test("0.0")
test_generate("0.2" MINOR 2) version(GENERATE _TEST MAJOR 1)
test_generate("0.0.3" PATCH 3) compare_test("1.0")
test_generate("0.0.0.4" TWEAK 4) version(GENERATE _TEST MINOR 2)
test_generate("0.0-5" COMPRESS PRERELEASE 5) compare_test("0.2")
test_generate("0.0a5" COMPRESS PRERELEASE a5) version(GENERATE _TEST PATCH 3)
test_generate("0.0a5.5" COMPRESS PRERELEASE "a5;5") compare_test("0.0.3")
test_generate("0.0+6" BUILD 6) version(GENERATE _TEST TWEAK 4)
test_generate("0.0+6.8" BUILD "6;8") 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 # - Invalid Cases
test_generate("-1.0.0" FAIL MAJOR "-1") version(GENERATE _TEST MAJOR "-1")
test_generate("0.-1.0" FAIL MINOR "-1") compare_test("-1.0.0" FAIL)
test_generate("0.0.-1" FAIL PATCH "-1") version(GENERATE _TEST MINOR "-1")
test_generate("0.0.0.-1" FAIL TWEAK "-1") compare_test("0.-1.0" FAIL)
test_generate("0.0.0-#" FAIL PRERELEASE "#") version(GENERATE _TEST PATCH "-1")
test_generate("0.0.0-0 0" FAIL PRERELEASE "0 0") compare_test("0.0.-1" FAIL)
test_generate("0.0.0+#" FAIL BUILD "#") version(GENERATE _TEST TWEAK "-1")
test_generate("0.0.0+0 0" FAIL BUILD "0 0") 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 # Parsing
message(STATUS "\n\n===== Parsing =====") message(STATUS "\n\n===== Parsing =====")
@@ -63,30 +87,59 @@ test_parse("0.0.0+.0" FAIL)
# Modifying # Modifying
message(STATUS "\n\n===== Modifying =====") message(STATUS "\n\n===== Modifying =====")
# - Valid Cases # - Valid Cases
test_modify("1.2" "0.2" MAJOR 1) version(MODIFY _TEST "0.2" MAJOR 1)
test_modify("1.2" "0.2" MAJOR "+1") compare_test("1.2")
test_modify("1.2" "2.2" MAJOR "-1") version(MODIFY _TEST "0.2" MAJOR "+1")
test_modify("1.2" "1.0" MINOR 2) compare_test("1.2")
test_modify("1.2" "1.0" MINOR "+2") version(MODIFY _TEST "2.2" MAJOR "-1")
test_modify("1.2" "1.3" MINOR "-1") compare_test("1.2")
test_modify("1.2.3" "1.2" PATCH 3) version(MODIFY _TEST "1.0" MINOR 2)
test_modify("1.2.3" "1.2.2" PATCH "+1") compare_test("1.2")
test_modify("1.2.3" "1.2.4" PATCH "-1") version(MODIFY _TEST "1.0" MINOR "+2")
test_modify("1.2.0.4" "1.2" TWEAK 4) compare_test("1.2")
test_modify("1.2.3.4" "1.2.3.3" TWEAK "+1") version(MODIFY _TEST "1.3" MINOR "-1")
test_modify("1.2.3.4" "1.2.3.5" TWEAK "-1") compare_test("1.2")
test_modify("1.2-5" "1.2" COMPRESS PRERELEASE 5) version(MODIFY _TEST "1.2" PATCH 3)
test_modify("1.2a5" "1.2" COMPRESS PRERELEASE a5) compare_test("1.2.3")
test_modify("1.2+6" "1.2" COMPRESS BUILD 6) version(MODIFY _TEST "1.2.2" PATCH "+1")
test_modify("1.2-5+6" "1.2" COMPRESS PRERELEASE 5 BUILD 6) compare_test("1.2.3")
test_modify("1.2a5+6" "1.2" COMPRESS PRERELEASE a5 BUILD 6) 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 # - Invalid Cases
test_modify("0.0" "0.0" FAIL MAJOR -1) version(MODIFY _TEST "0.0" MAJOR -1)
test_modify("0.0" "0.0" FAIL MINOR -1) compare_test("0.0" FAIL)
test_modify("0.0" "0.0" FAIL PATCH -1) version(MODIFY _TEST "0.0" MINOR -1)
test_modify("0.0" "0.0" FAIL TWEAK -1) compare_test("0.0" FAIL)
test_modify("0.0" "0.0" FAIL COMPRESS PRERELEASE "#") version(MODIFY _TEST "0.0" PATCH -1)
test_modify("0.0" "0.0" FAIL COMPRESS BUILD "#") 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 # Comparing
message(STATUS "\n\n===== 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" "-PRERELEASE" "0.0-5")
test_compare("0.0+6" "+BUILD" "0.0") test_compare("0.0+6" "+BUILD" "0.0")
test_compare("0.0" "-BUILD" "0.0+6") 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") include("../version.cmake")
function(test_generate) function(compare_test)
cmake_parse_arguments( cmake_parse_arguments(
PARSE_ARGV 1 PARSE_ARGV 1
_6edc8bbd _6edc8bbd
"COMPRESS;FAIL" "FAIL"
"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(GENERATE _TEST ${ARGS})")
if(_TEST_ERROR) if(_TEST_ERROR)
if(_6edc8bbd_FAIL) if(_6edc8bbd_FAIL)
message(STATUS "PASSED: '${ARGV0}'.\n\t${_TEST_ERROR}") message(STATUS "PASSED: '${ARGV0}'.\n\t${_TEST_ERROR}")
@@ -139,64 +114,6 @@ function(test_parse)
endif() endif()
endfunction() 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) function(test_compare)
cmake_parse_arguments( cmake_parse_arguments(
PARSE_ARGV 3 PARSE_ARGV 3
+33 -44
View File
@@ -10,7 +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. # 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.
function(version) function(version MODE OUT_VAR)
# CMake functions do not have their own proper scope, they act more # CMake functions do not have their own proper scope, they act more
set(OUT_VAR "${ARGV1}") set(OUT_VAR "${ARGV1}")
@@ -24,8 +24,8 @@ function(version)
PARSE_ARGV 2 PARSE_ARGV 2
_992ae727 _992ae727
"" ""
""
"REQUIRE" "REQUIRE"
""
) )
# <major> "." <minor> ["." <patch> ["." <tweak>]] # <major> "." <minor> ["." <patch> ["." <tweak>]]
# <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>] # <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
@@ -98,65 +98,56 @@ function(version)
PARSE_ARGV 2 PARSE_ARGV 2
_32070faa _32070faa
"COMPRESS" "COMPRESS"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD" "MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD;REQUIRE"
"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? # Do we have the major component, and is it valid?
if(NOT "${_32070faa_MAJOR}" STREQUAL "") if(_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()
set(_32070faa_MAJOR 0) set(_32070faa_MAJOR 0)
endif() 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}") set(_feeb1eff "${_feeb1eff}${_32070faa_MAJOR}")
# Do we have the minor component, and is it valid? # Do we have the minor component, and is it valid?
if(NOT "${_32070faa_MINOR}" STREQUAL "") if(_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()
set(_32070faa_MINOR 0) set(_32070faa_MINOR 0)
endif() 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}") set(_feeb1eff "${_feeb1eff}.${_32070faa_MINOR}")
# Do we have the patch component, and is it valid? # Do we have the patch component, and is it valid?
if(NOT "${_32070faa_PATCH}" STREQUAL "") if((("PATCH" IN_LIST _32070faa_REQUIRE) OR ("TWEAK" IN_LIST _32070faa_REQUIRE) OR (NOT _32070faa_TWEAK STREQUAL "")) AND ("${_32070faa_PATCH}" STREQUAL ""))
string(STRIP "${_32070faa_PATCH}" _32070faa_PATCH) set(_32070faa_PATCH "0")
if(("${_32070faa_PATCH}" STREQUAL "") AND ("PATCH" IN_LIST _32070faa_REQUIRE)) endif()
set(_32070faa_PATCH "0") if(NOT _32070faa_PATCH STREQUAL "")
endif()
if(_32070faa_PATCH MATCHES [[^[0-9]+$]]) if(_32070faa_PATCH MATCHES [[^[0-9]+$]])
set(_feeb1eff "${_feeb1eff}.${_32070faa_PATCH}") set(_feeb1eff "${_feeb1eff}.${_32070faa_PATCH}")
else() else()
set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_32070faa_PATCH}'" PARENT_SCOPE) set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_32070faa_PATCH}'" PARENT_SCOPE)
return() return()
endif() endif()
elseif("PATCH" IN_LIST _32070faa_REQUIRE)
set(_feeb1eff "${_feeb1eff}.0")
endif() endif()
# Do we have the tweak component, and is it valid? # Do we have the tweak component, and is it valid?
if(NOT "${_32070faa_TWEAK}" STREQUAL "") if(("TWEAK" IN_LIST _32070faa_REQUIRE) AND (_32070faa_TWEAK STREQUAL ""))
string(STRIP "${_32070faa_TWEAK}" _32070faa_TWEAK) set(_32070faa_TWEAK "0")
if(("${_32070faa_TWEAK}" STREQUAL "") AND ("TWEAK" IN_LIST _32070faa_REQUIRE)) endif()
set(_32070faa_TWEAK "0") if(NOT _32070faa_TWEAK STREQUAL "")
endif()
if(_32070faa_TWEAK MATCHES [[^[0-9]+$]]) if(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
if("${_32070faa_PATCH}" STREQUAL "")
# Patch did not exist, so it is zero.
set(_feeb1eff "${_feeb1eff}.0")
endif()
set(_feeb1eff "${_feeb1eff}.${_32070faa_TWEAK}") set(_feeb1eff "${_feeb1eff}.${_32070faa_TWEAK}")
else() else()
set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_32070faa_TWEAK}'" PARENT_SCOPE) set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_32070faa_TWEAK}'" PARENT_SCOPE)
@@ -166,7 +157,6 @@ function(version)
# Do we have the pre-release component, and is it valid? # Do we have the pre-release component, and is it valid?
if(NOT "${_32070faa_PRERELEASE}" STREQUAL "") if(NOT "${_32070faa_PRERELEASE}" STREQUAL "")
string(STRIP "${_32070faa_PRERELEASE}" _32070faa_PRERELEASE)
list(JOIN _32070faa_PRERELEASE "." _32070faa_PRERELEASE) list(JOIN _32070faa_PRERELEASE "." _32070faa_PRERELEASE)
if("${_32070faa_PRERELEASE}" STREQUAL "") if("${_32070faa_PRERELEASE}" STREQUAL "")
set(_32070faa_PRERELEASE "") set(_32070faa_PRERELEASE "")
@@ -184,7 +174,6 @@ function(version)
# Do we have the build component, and is it valid? # Do we have the build component, and is it valid?
if(NOT "${_32070faa_BUILD}" STREQUAL "") if(NOT "${_32070faa_BUILD}" STREQUAL "")
string(STRIP "${_32070faa_BUILD}" _32070faa_BUILD)
list(JOIN _32070faa_BUILD "." _32070faa_BUILD) list(JOIN _32070faa_BUILD "." _32070faa_BUILD)
if("${_32070faa_BUILD}" STREQUAL "") if("${_32070faa_BUILD}" STREQUAL "")
unset(_32070faa_BUILD) unset(_32070faa_BUILD)
@@ -211,8 +200,8 @@ function(version)
PARSE_ARGV 3 PARSE_ARGV 3
_fe7bcddd _fe7bcddd
"COMPRESS" "COMPRESS"
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD" "MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD;REQUIRE"
"REQUIRE" ""
) )
# Helpers # Helpers
@@ -282,8 +271,8 @@ function(version)
if(_fe7bcddd_COMPRESS) if(_fe7bcddd_COMPRESS)
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS") set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS")
endif() endif()
if(_fe7bcddd_REQUIRE) if(NOT _fe7bcddd_REQUIRE STREQUAL "")
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} REQUIRE \"${_df8abcce_REQUIRE}\"") set(_fe7bcddd_GEN "${_fe7bcddd_GEN} REQUIRE \"${_fe7bcddd_REQUIRE}\"")
endif() endif()
cmake_language(EVAL CODE "version(GENERATE _df8abcce ${_fe7bcddd_GEN})") cmake_language(EVAL CODE "version(GENERATE _df8abcce ${_fe7bcddd_GEN})")
if(_df8abcce_ERROR) if(_df8abcce_ERROR)