Compare commits
12 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3bef96bafa | |||
| 4ab58b18ac | |||
| 6f4488a833 | |||
| 16bfa9568c | |||
| e442dea08d | |||
| 2494a2b6c8 | |||
| e240967c27 | |||
| db601c04d3 | |||
| e5b1376772 | |||
| 2f60608e3c | |||
| 6d978a044e | |||
| 2b80fbc79c |
+3
-3
@@ -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.2"
|
version = "1.4.1"
|
||||||
release = "1.2"
|
release = "1.4.1"
|
||||||
|
|
||||||
|
|
||||||
# -- General configuration ---------------------------------------------------
|
# -- General configuration ---------------------------------------------------
|
||||||
@@ -53,4 +53,4 @@ html_theme = 'sphinx_rtd_theme'
|
|||||||
# Add any paths that contain custom static files (such as style sheets) here,
|
# Add any paths that contain custom static files (such as style sheets) here,
|
||||||
# relative to this directory. They are copied after the builtin static files,
|
# relative to this directory. They are copied after the builtin static files,
|
||||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
html_static_path = []
|
html_static_path = []
|
||||||
|
|||||||
+17
-11
@@ -8,9 +8,9 @@ Synopsis
|
|||||||
|
|
||||||
.. parsed-literal::
|
.. parsed-literal::
|
||||||
|
|
||||||
version(`PARSE`_ <out-var> <string>)
|
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>])
|
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>)
|
version(`COMPARE`_ <out-var> <a> <b>)
|
||||||
|
|
||||||
|
|
||||||
@@ -27,9 +27,11 @@ Parsing
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
version(PARSE <out-var> <string>)
|
version(PARSE <out-var> [REQUIRE [PATCH|TWEAK][;...]] <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 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.
|
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
|
||||||
^^^^^^^^^^
|
^^^^^^^^^^
|
||||||
@@ -38,9 +40,11 @@ Generating
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. 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
|
Modifying
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
@@ -49,9 +53,11 @@ Modifying
|
|||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
version(MODIFY <out-var> <string> [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>] [REQUIRE [PATCH|TWEAK][;...]])
|
||||||
|
|
||||||
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.
|
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
|
||||||
^^^^^^^^^
|
^^^^^^^^^
|
||||||
@@ -59,7 +65,7 @@ Comparing
|
|||||||
.. _COMPARE:
|
.. _COMPARE:
|
||||||
|
|
||||||
.. code-block:: cmake
|
.. code-block:: cmake
|
||||||
|
|
||||||
version(COMPARE <out-var> <a> <b>)
|
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:
|
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:
|
||||||
@@ -69,7 +75,7 @@ Compares the version ``<a>`` against ``<b>`` and stores the result in ``<out-var
|
|||||||
- 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 ``<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 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.
|
- If a component is alphanumerical and the value is different in either, ``<out-var>`` will contain the component name with no prefix.
|
||||||
- If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant, and ``<out-var>`` will be a false constant.
|
- If an error occurred, ``<out-var>_ERROR`` will contain the error message otherwise it will be a false constant, and ``<out-var>`` will be a false constant.
|
||||||
- In all other cases, ``<out-var>`` will be a false constant.
|
- In all other cases, ``<out-var>`` will be a false constant.
|
||||||
|
|
||||||
There is no special handling for dot-separated ``PRERELEASE`` and ``BUILD`` component. They will be treated as if they were a string, as special handling for these is up to the application.
|
There is no special handling for dot-separated ``PRERELEASE`` and ``BUILD`` component. They will be treated as if they were a string, as special handling for these is up to the application.
|
||||||
|
|||||||
+94
-41
@@ -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.0" "0.0" MAJOR 1)
|
version(MODIFY _TEST "0.2" MAJOR 1)
|
||||||
test_modify("1.0" "0.0" MAJOR "+1")
|
compare_test("1.2")
|
||||||
test_modify("1.0" "2.0" MAJOR "-1")
|
version(MODIFY _TEST "0.2" MAJOR "+1")
|
||||||
test_modify("0.2" "0.0" MINOR 2)
|
compare_test("1.2")
|
||||||
test_modify("0.2" "0.0" MINOR "+2")
|
version(MODIFY _TEST "2.2" MAJOR "-1")
|
||||||
test_modify("0.2" "0.3" MINOR "-1")
|
compare_test("1.2")
|
||||||
test_modify("0.0.3" "0.0" PATCH 3)
|
version(MODIFY _TEST "1.0" MINOR 2)
|
||||||
test_modify("0.0.3" "0.0.2" PATCH "+1")
|
compare_test("1.2")
|
||||||
test_modify("0.0.3" "0.0.4" PATCH "-1")
|
version(MODIFY _TEST "1.0" MINOR "+2")
|
||||||
test_modify("0.0.0.4" "0.0" TWEAK 4)
|
compare_test("1.2")
|
||||||
test_modify("0.0.0.4" "0.0.0.3" TWEAK "+1")
|
version(MODIFY _TEST "1.3" MINOR "-1")
|
||||||
test_modify("0.0.0.4" "0.0.0.5" TWEAK "-1")
|
compare_test("1.2")
|
||||||
test_modify("0.0-5" "0.0" COMPRESS PRERELEASE 5)
|
version(MODIFY _TEST "1.2" PATCH 3)
|
||||||
test_modify("0.0a5" "0.0" COMPRESS PRERELEASE a5)
|
compare_test("1.2.3")
|
||||||
test_modify("0.0+6" "0.0" COMPRESS BUILD 6)
|
version(MODIFY _TEST "1.2.2" PATCH "+1")
|
||||||
test_modify("0.0-5+6" "0.0" COMPRESS PRERELEASE 5 BUILD 6)
|
compare_test("1.2.3")
|
||||||
test_modify("0.0a5+6" "0.0" 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 =====")
|
||||||
|
|||||||
+3
-86
@@ -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
|
||||||
|
|||||||
+93
-159
@@ -10,101 +10,29 @@
|
|||||||
#
|
#
|
||||||
# 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.
|
||||||
|
|
||||||
#[=======================================================================[.rst:
|
function(version MODE OUT_VAR)
|
||||||
version
|
# CMake functions do not have their own proper scope, they act more
|
||||||
-------
|
|
||||||
|
|
||||||
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)
|
|
||||||
# CMake functions do not have their own proper scope, they act more
|
|
||||||
|
|
||||||
set(OUT_VAR "${ARGV1}")
|
set(OUT_VAR "${ARGV1}")
|
||||||
|
|
||||||
# Force clean parent elements.
|
# Force clean parent elements.
|
||||||
set(${OUT_VAR} "" PARENT_SCOPE)
|
|
||||||
set(${OUT_VAR}_ERROR "" PARENT_SCOPE)
|
set(${OUT_VAR}_ERROR "" PARENT_SCOPE)
|
||||||
|
|
||||||
string(TOUPPER "${ARGV0}" ARGV0)
|
string(TOUPPER "${ARGV0}" ARGV0)
|
||||||
if(ARGV0 STREQUAL "PARSE")
|
if(ARGV0 STREQUAL "PARSE")
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 2
|
||||||
|
_992ae727
|
||||||
|
""
|
||||||
|
"REQUIRE"
|
||||||
|
""
|
||||||
|
)
|
||||||
# <major> "." <minor> ["." <patch> ["." <tweak>]]
|
# <major> "." <minor> ["." <patch> ["." <tweak>]]
|
||||||
# <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
|
# <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
|
||||||
|
|
||||||
# One regex to rule them all...
|
# One regex to rule them all...
|
||||||
if(NOT (ARGV2 MATCHES [[^([0-9]+)\.([0-9]+)(\.[0-9]+|)(\.[0-9]+|)(-?[a-zA-Z0-9]+[a-zA-Z0-9\.\-]*|)(\+[a-zA-Z0-9]+[a-zA-Z0-9\.\-]*|)$]]))
|
if(NOT (_992ae727_UNPARSED_ARGUMENTS MATCHES [[^([0-9]+)\.([0-9]+)(\.[0-9]+|)(\.[0-9]+|)(-?[a-zA-Z0-9]+[a-zA-Z0-9\.\-]*|)(\+[a-zA-Z0-9]+[a-zA-Z0-9\.\-]*|)$]]))
|
||||||
set(${OUT_VAR}_ERROR "Version format not supported: '${ARGV2}'" PARENT_SCOPE)
|
set(${OUT_VAR}_ERROR "Version format not supported: '${_992ae727_UNPARSED_ARGUMENTS}'" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
@@ -113,21 +41,29 @@ function(version)
|
|||||||
# {2} = Minor
|
# {2} = Minor
|
||||||
set(${OUT_VAR}_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
|
set(${OUT_VAR}_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
|
||||||
# {3} = Patch
|
# {3} = Patch
|
||||||
if(CMAKE_MATCH_3)
|
if((DEFINED CMAKE_MATCH_3) AND (NOT "${CMAKE_MATCH_3}" STREQUAL ""))
|
||||||
string(SUBSTRING "${CMAKE_MATCH_3}" 1 -1 _TMP)
|
string(SUBSTRING "${CMAKE_MATCH_3}" 1 -1 _TMP)
|
||||||
set(${OUT_VAR}_PATCH "${_TMP}" PARENT_SCOPE)
|
set(${OUT_VAR}_PATCH "${_TMP}" PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
set(${OUT_VAR}_PATCH "" PARENT_SCOPE)
|
if("PATCH" IN_LIST _992ae727_REQUIRE)
|
||||||
|
set(${OUT_VAR}_PATCH "0" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_PATCH "" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# {4} = Tweak
|
# {4} = Tweak
|
||||||
if(CMAKE_MATCH_4)
|
if((DEFINED CMAKE_MATCH_4) AND (NOT "${CMAKE_MATCH_4}" STREQUAL ""))
|
||||||
string(SUBSTRING "${CMAKE_MATCH_4}" 1 -1 _TMP)
|
string(SUBSTRING "${CMAKE_MATCH_4}" 1 -1 _TMP)
|
||||||
set(${OUT_VAR}_TWEAK "${_TMP}" PARENT_SCOPE)
|
set(${OUT_VAR}_TWEAK "${_TMP}" PARENT_SCOPE)
|
||||||
else()
|
else()
|
||||||
set(${OUT_VAR}_TWEAK "" PARENT_SCOPE)
|
if("TWEAK" IN_LIST _992ae727_REQUIRE)
|
||||||
|
set(${OUT_VAR}_TWEAK "0" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_TWEAK "" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
endif()
|
endif()
|
||||||
# {5} = PreRelease
|
# {5} = PreRelease
|
||||||
if(CMAKE_MATCH_5)
|
if((DEFINED CMAKE_MATCH_5) AND (NOT "${CMAKE_MATCH_5}" STREQUAL ""))
|
||||||
string(REPLACE "." ";" CMAKE_MATCH_5 "${CMAKE_MATCH_5}") # Handle dot separation as list.
|
string(REPLACE "." ";" CMAKE_MATCH_5 "${CMAKE_MATCH_5}") # Handle dot separation as list.
|
||||||
string(SUBSTRING "${CMAKE_MATCH_5}" 0 1 _TMP)
|
string(SUBSTRING "${CMAKE_MATCH_5}" 0 1 _TMP)
|
||||||
if(_TMP STREQUAL "-")
|
if(_TMP STREQUAL "-")
|
||||||
@@ -140,7 +76,7 @@ function(version)
|
|||||||
set(${OUT_VAR}_PRERELEASE "" PARENT_SCOPE)
|
set(${OUT_VAR}_PRERELEASE "" PARENT_SCOPE)
|
||||||
endif()
|
endif()
|
||||||
# {6} = Build
|
# {6} = Build
|
||||||
if(CMAKE_MATCH_6)
|
if((DEFINED CMAKE_MATCH_6) AND (NOT "${CMAKE_MATCH_6}" STREQUAL ""))
|
||||||
string(REPLACE "." ";" CMAKE_MATCH_6 "${CMAKE_MATCH_6}") # Handle dot separation as list.
|
string(REPLACE "." ";" CMAKE_MATCH_6 "${CMAKE_MATCH_6}") # Handle dot separation as list.
|
||||||
string(SUBSTRING "${CMAKE_MATCH_6}" 1 -1 CMAKE_MATCH_6)
|
string(SUBSTRING "${CMAKE_MATCH_6}" 1 -1 CMAKE_MATCH_6)
|
||||||
set(${OUT_VAR}_BUILD "${CMAKE_MATCH_6}" PARENT_SCOPE)
|
set(${OUT_VAR}_BUILD "${CMAKE_MATCH_6}" PARENT_SCOPE)
|
||||||
@@ -157,48 +93,48 @@ function(version)
|
|||||||
set(_32070faa_PRERELEASE "")
|
set(_32070faa_PRERELEASE "")
|
||||||
set(_32070faa_BUILD "")
|
set(_32070faa_BUILD "")
|
||||||
set(_32070faa_ERROR "")
|
set(_32070faa_ERROR "")
|
||||||
|
set(_32070faa_REQUIRE "")
|
||||||
cmake_parse_arguments(
|
cmake_parse_arguments(
|
||||||
PARSE_ARGV 2
|
PARSE_ARGV 2
|
||||||
_32070faa
|
_32070faa
|
||||||
"COMPRESS"
|
"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?
|
# Do we have the major component, and is it valid?
|
||||||
if(_32070faa_MAJOR)
|
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(_32070faa_MINOR)
|
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(_32070faa_PATCH)
|
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 "")
|
endif()
|
||||||
unset(_32070faa_PATCH)
|
if(NOT _32070faa_PATCH STREQUAL "")
|
||||||
elseif(_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)
|
||||||
@@ -207,14 +143,11 @@ function(version)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Do we have the tweak component, and is it valid?
|
# Do we have the tweak component, and is it valid?
|
||||||
if(_32070faa_TWEAK)
|
if(("TWEAK" IN_LIST _32070faa_REQUIRE) AND (_32070faa_TWEAK STREQUAL ""))
|
||||||
string(STRIP "${_32070faa_TWEAK}" _32070faa_TWEAK)
|
set(_32070faa_TWEAK "0")
|
||||||
if(_32070faa_TWEAK STREQUAL "")
|
endif()
|
||||||
unset(_32070faa_TWEAK)
|
if(NOT _32070faa_TWEAK STREQUAL "")
|
||||||
elseif(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
|
if(_32070faa_TWEAK MATCHES [[^[0-9]+$]])
|
||||||
if(NOT _32070faa_PATCH)
|
|
||||||
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)
|
||||||
@@ -223,13 +156,12 @@ function(version)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Do we have the pre-release component, and is it valid?
|
# Do we have the pre-release component, and is it valid?
|
||||||
if(_32070faa_PRERELEASE)
|
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 "")
|
||||||
unset(_32070faa_PRERELEASE)
|
set(_32070faa_PRERELEASE "")
|
||||||
elseif(_32070faa_PRERELEASE MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
elseif(_32070faa_PRERELEASE MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||||
if(_32070faa_COMPRESS AND (_32070faa_PRERELEASE MATCHES [[[a-zA-Z]+[a-zA-Z0-9\-\.]*$]]))
|
if(_32070faa_COMPRESS AND (_32070faa_PRERELEASE MATCHES [[^[a-zA-Z]+[a-zA-Z0-9\-\.]*$]]))
|
||||||
set(_feeb1eff "${_feeb1eff}${_32070faa_PRERELEASE}")
|
set(_feeb1eff "${_feeb1eff}${_32070faa_PRERELEASE}")
|
||||||
else()
|
else()
|
||||||
set(_feeb1eff "${_feeb1eff}-${_32070faa_PRERELEASE}")
|
set(_feeb1eff "${_feeb1eff}-${_32070faa_PRERELEASE}")
|
||||||
@@ -241,10 +173,9 @@ function(version)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Do we have the build component, and is it valid?
|
# Do we have the build component, and is it valid?
|
||||||
if(_32070faa_BUILD)
|
if(NOT "${_32070faa_BUILD}" STREQUAL "")
|
||||||
string(STRIP "${_32070faa_BUILD}" _32070faa_PRERELEASE)
|
|
||||||
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)
|
||||||
elseif(_32070faa_BUILD MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
elseif(_32070faa_BUILD MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||||
set(_feeb1eff "${_feeb1eff}+${_32070faa_BUILD}")
|
set(_feeb1eff "${_feeb1eff}+${_32070faa_BUILD}")
|
||||||
@@ -269,18 +200,18 @@ 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"
|
||||||
""
|
""
|
||||||
)
|
)
|
||||||
|
|
||||||
# Helpers
|
# Helpers
|
||||||
macro(modify_version_number)
|
macro(modify_version_number)
|
||||||
if(${ARGV1})
|
if(NOT ("${${ARGV1}}" STREQUAL ""))
|
||||||
if(${ARGV1} MATCHES "^(\\+|\\-)([0-9]+)$")
|
if("${${ARGV1}}" MATCHES "^(\\+|\\-)([0-9]+)$")
|
||||||
if(${ARGV0})
|
if("${${ARGV0}}" STREQUAL "")
|
||||||
math(EXPR ${ARGV0} "${${ARGV0}} ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
|
||||||
else()
|
|
||||||
math(EXPR ${ARGV0} "0 ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
math(EXPR ${ARGV0} "0 ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||||
|
else()
|
||||||
|
math(EXPR ${ARGV0} "${${ARGV0}} ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||||
endif()
|
endif()
|
||||||
else()
|
else()
|
||||||
set(${ARGV0} "${${ARGV1}}")
|
set(${ARGV0} "${${ARGV1}}")
|
||||||
@@ -297,7 +228,7 @@ function(version)
|
|||||||
set(_df8abcce_PRERELEASE "")
|
set(_df8abcce_PRERELEASE "")
|
||||||
set(_df8abcce_BUILD "")
|
set(_df8abcce_BUILD "")
|
||||||
set(_df8abcce_ERROR "")
|
set(_df8abcce_ERROR "")
|
||||||
version(PARSE _df8abcce "${ARGV2}")
|
version(PARSE _df8abcce "${ARGV2}" REQUIRE "${_df8abcce_REQUIRE}")
|
||||||
if(_df8abcce_ERROR)
|
if(_df8abcce_ERROR)
|
||||||
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
@@ -310,36 +241,39 @@ function(version)
|
|||||||
modify_version_number(_df8abcce_TWEAK _fe7bcddd_TWEAK)
|
modify_version_number(_df8abcce_TWEAK _fe7bcddd_TWEAK)
|
||||||
|
|
||||||
# Replace other components if defined.
|
# Replace other components if defined.
|
||||||
if(_fe7bcddd_PRERELEASE)
|
if(NOT "${_fe7bcddd_PRERELEASE}" STREQUAL "")
|
||||||
set(_df8abcce_PRERELEASE "${_fe7bcddd_PRERELEASE}")
|
set(_df8abcce_PRERELEASE "${_fe7bcddd_PRERELEASE}")
|
||||||
endif()
|
endif()
|
||||||
if(_fe7bcddd_BUILD)
|
if(NOT "${_fe7bcddd_BUILD}" STREQUAL "")
|
||||||
set(_df8abcce_BUILD "${_fe7bcddd_BUILD}")
|
set(_df8abcce_BUILD "${_fe7bcddd_BUILD}")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Generate a new version.
|
# Generate a new version.
|
||||||
set(_fe7bcddd_GEN "")
|
set(_fe7bcddd_GEN "")
|
||||||
if(_df8abcce_MAJOR AND (NOT _df8abcce_MAJOR STREQUAL ""))
|
if(NOT "${_df8abcce_MAJOR}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MAJOR \"${_df8abcce_MAJOR}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MAJOR \"${_df8abcce_MAJOR}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_df8abcce_MINOR AND (NOT _df8abcce_MINOR STREQUAL ""))
|
if(NOT "${_df8abcce_MINOR}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MINOR \"${_df8abcce_MINOR}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} MINOR \"${_df8abcce_MINOR}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_df8abcce_PATCH AND (NOT _df8abcce_PATCH STREQUAL ""))
|
if(NOT "${_df8abcce_PATCH}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PATCH \"${_df8abcce_PATCH}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PATCH \"${_df8abcce_PATCH}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_df8abcce_TWEAK AND (NOT _df8abcce_TWEAK STREQUAL ""))
|
if(NOT "${_df8abcce_TWEAK}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} TWEAK \"${_df8abcce_TWEAK}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} TWEAK \"${_df8abcce_TWEAK}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_df8abcce_PRERELEASE AND (NOT _df8abcce_PRERELEASE STREQUAL ""))
|
if(NOT "${_df8abcce_PRERELEASE}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PRERELEASE \"${_df8abcce_PRERELEASE}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} PRERELEASE \"${_df8abcce_PRERELEASE}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_df8abcce_BUILD AND (NOT _df8abcce_BUILD STREQUAL ""))
|
if(NOT "${_df8abcce_BUILD}" STREQUAL "")
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} BUILD \"${_df8abcce_BUILD}\"")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} BUILD \"${_df8abcce_BUILD}\"")
|
||||||
endif()
|
endif()
|
||||||
if(_fe7bcddd_COMPRESS)
|
if(_fe7bcddd_COMPRESS)
|
||||||
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS")
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} COMPRESS")
|
||||||
endif()
|
endif()
|
||||||
|
if(NOT _fe7bcddd_REQUIRE STREQUAL "")
|
||||||
|
set(_fe7bcddd_GEN "${_fe7bcddd_GEN} REQUIRE \"${_fe7bcddd_REQUIRE}\"")
|
||||||
|
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)
|
||||||
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
set(${OUT_VAR}_ERROR ${_df8abcce_ERROR} PARENT_SCOPE)
|
||||||
@@ -404,11 +338,11 @@ function(version)
|
|||||||
elseif(_00fdeadb_PATCH LESS _ca75feel_PATCH)
|
elseif(_00fdeadb_PATCH LESS _ca75feel_PATCH)
|
||||||
set(${OUT_VAR} "<PATCH" PARENT_SCOPE)
|
set(${OUT_VAR} "<PATCH" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif((_00fdeadb_PATCH STREQUAL "") OR (_ca75feel_PATCH STREQUAL ""))
|
elseif(("${_00fdeadb_PATCH}" STREQUAL "") OR ("${_ca75feel_PATCH}" STREQUAL ""))
|
||||||
if(_00fdeadb_PATCH)
|
if(NOT "${_00fdeadb_PATCH}" STREQUAL "")
|
||||||
set(${OUT_VAR} "+PATCH" PARENT_SCOPE)
|
set(${OUT_VAR} "+PATCH" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif(_ca75feel_PATCH)
|
elseif(NOT "${_ca75feel_PATCH}" STREQUAL "")
|
||||||
set(${OUT_VAR} "-PATCH" PARENT_SCOPE)
|
set(${OUT_VAR} "-PATCH" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
@@ -421,42 +355,42 @@ function(version)
|
|||||||
elseif(_00fdeadb_TWEAK LESS _ca75feel_TWEAK)
|
elseif(_00fdeadb_TWEAK LESS _ca75feel_TWEAK)
|
||||||
set(${OUT_VAR} "<TWEAK" PARENT_SCOPE)
|
set(${OUT_VAR} "<TWEAK" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif((_00fdeadb_TWEAK STREQUAL "") OR (_ca75feel_TWEAK STREQUAL ""))
|
elseif(("${_00fdeadb_TWEAK}" STREQUAL "") OR ("${_ca75feel_TWEAK}" STREQUAL ""))
|
||||||
if(_00fdeadb_TWEAK)
|
if(NOT "${_00fdeadb_TWEAK}" STREQUAL "")
|
||||||
set(${OUT_VAR} "+TWEAK" PARENT_SCOPE)
|
set(${OUT_VAR} "+TWEAK" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif(_ca75feel_TWEAK)
|
elseif(NOT "${_ca75feel_TWEAK}" STREQUAL "")
|
||||||
set(${OUT_VAR} "-TWEAK" PARENT_SCOPE)
|
set(${OUT_VAR} "-TWEAK" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Pre-Release
|
# Pre-Release
|
||||||
if((_00fdeadb_PRERELEASE STREQUAL "") OR (_ca75feel_PRERELEASE STREQUAL ""))
|
if(("${_00fdeadb_PRERELEASE}" STREQUAL "") OR ("${_ca75feel_PRERELEASE}" STREQUAL ""))
|
||||||
if(_00fdeadb_PRERELEASE)
|
if(NOT "${_00fdeadb_PRERELEASE}" STREQUAL "")
|
||||||
set(${OUT_VAR} "+PRERELEASE" PARENT_SCOPE)
|
set(${OUT_VAR} "+PRERELEASE" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif(_ca75feel_PRERELEASE)
|
elseif(NOT "${_ca75feel_PRERELEASE}" STREQUAL "")
|
||||||
set(${OUT_VAR} "-PRERELEASE" PARENT_SCOPE)
|
set(${OUT_VAR} "-PRERELEASE" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
elseif(NOT (_00fdeadb_PRERELEASE STREQUAL _ca75feel_PRERELEASE))
|
elseif(NOT (_00fdeadb_PRERELEASE STREQUAL _ca75feel_PRERELEASE))
|
||||||
set(${OUT_VAR} "PRERELEASE" PARENT_SCOPE)
|
set(${OUT_VAR} "PRERELEASE" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Build
|
# Build
|
||||||
if((_00fdeadb_BUILD STREQUAL "") OR (_ca75feel_BUILD STREQUAL ""))
|
if(("${_00fdeadb_BUILD}" STREQUAL "") OR ("${_ca75feel_BUILD}" STREQUAL ""))
|
||||||
if(_00fdeadb_BUILD)
|
if(NOT "${_00fdeadb_BUILD}" STREQUAL "")
|
||||||
set(${OUT_VAR} "+BUILD" PARENT_SCOPE)
|
set(${OUT_VAR} "+BUILD" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
elseif(_ca75feel_BUILD)
|
elseif(NOT "${_ca75feel_BUILD}" STREQUAL "")
|
||||||
set(${OUT_VAR} "-BUILD" PARENT_SCOPE)
|
set(${OUT_VAR} "-BUILD" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
elseif(NOT (_00fdeadb_BUILD STREQUAL _ca75feel_BUILD))
|
elseif(NOT (_00fdeadb_BUILD STREQUAL _ca75feel_BUILD))
|
||||||
set(${OUT_VAR} "BUILD" PARENT_SCOPE)
|
set(${OUT_VAR} "BUILD" PARENT_SCOPE)
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
# Both are exactly the same.
|
# Both are exactly the same.
|
||||||
@@ -465,4 +399,4 @@ function(version)
|
|||||||
message(FATAL_ERROR "Unknown command '${ARGV0}'")
|
message(FATAL_ERROR "Unknown command '${ARGV0}'")
|
||||||
return()
|
return()
|
||||||
endif()
|
endif()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|||||||
Reference in New Issue
Block a user