Version 0.1
This commit is contained in:
@@ -0,0 +1,2 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
@@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: "Suggest an Enhancment to a Feature or a new Feature"
|
||||||
|
title: "Replace Me Or Have Your Request Closed"
|
||||||
|
description: "Is there something lacking that you would like to have supported?"
|
||||||
|
labels: ["enhancement", "help wanted"]
|
||||||
|
body:
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Explain the Feature/Enhancement"
|
||||||
|
description: "Describe the feature or enhancement in as much detail as possible, leave nothing out. If you think images or example videos help describe the Feature/Enhancement, include them."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Examples"
|
||||||
|
description: "Provide some examples of how this feature would/should be used."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Any additional information we need to know?"
|
||||||
@@ -0,0 +1,137 @@
|
|||||||
|
name: "Report a Bug/Crash/Freeze"
|
||||||
|
title: "Replace Me Or Have Your Report Closed"
|
||||||
|
description: "Encountered a problem, a bug or a crash?"
|
||||||
|
labels: ["bug", "help wanted"]
|
||||||
|
body:
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: "Operating System"
|
||||||
|
description: "What Operating System do you use for OBS Studio and StreamFX? Select 'Other' if your Operating System is not listed"
|
||||||
|
options:
|
||||||
|
- "Windows 10 1903 and higher"
|
||||||
|
- "MacOS 10.15 and higher"
|
||||||
|
- "Linux (like Debian/Ubuntu)"
|
||||||
|
- "Linux (like Arch Linux)"
|
||||||
|
- "Linux (like FreeBSD)"
|
||||||
|
- "(Other)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: "OBS Studio Version?"
|
||||||
|
description: "Which OBS Studio version are you using to run StreamFX? Versions include all patches (the third element in 'A.B.C'), and release candidates for that version. Select 'Other' if you are using a custom build."
|
||||||
|
options:
|
||||||
|
- "27.1"
|
||||||
|
- "27.0"
|
||||||
|
- "26.1"
|
||||||
|
- "26.0"
|
||||||
|
- "25.0"
|
||||||
|
- "(Other)"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: dropdown
|
||||||
|
attributes:
|
||||||
|
label: "StreamFX Version"
|
||||||
|
description: "On which StreamFX version did you first encounter this issue?"
|
||||||
|
options:
|
||||||
|
- "0.12.0a1"
|
||||||
|
- "0.11.1"
|
||||||
|
- "0.11.1b1"
|
||||||
|
- "0.11.1a1"
|
||||||
|
- "0.11.0"
|
||||||
|
- "0.11.0c1"
|
||||||
|
- "0.11.0b3"
|
||||||
|
- "0.11.0b2"
|
||||||
|
- "0.11.0b1"
|
||||||
|
- "0.11.0a8"
|
||||||
|
- "0.11.0a7"
|
||||||
|
- "0.11.0a6"
|
||||||
|
- "0.11.0a5"
|
||||||
|
- "0.11.0a4"
|
||||||
|
- "0.11.0a3"
|
||||||
|
- "0.11.0a2"
|
||||||
|
- "0.11.0a1"
|
||||||
|
- "0.10.1"
|
||||||
|
- "0.10.0"
|
||||||
|
- "0.10.0b3"
|
||||||
|
- "0.10.0b2"
|
||||||
|
- "0.10.0b1"
|
||||||
|
- "0.10.0a2"
|
||||||
|
- "0.10.0a1"
|
||||||
|
- "0.10.0a0"
|
||||||
|
- "0.9.3"
|
||||||
|
- "0.9.2"
|
||||||
|
- "0.9.1"
|
||||||
|
- "0.9.0"
|
||||||
|
- "0.9.0a3"
|
||||||
|
- "0.9.0a2"
|
||||||
|
- "0.9.0a1"
|
||||||
|
- "0.8.3"
|
||||||
|
- "0.8.2"
|
||||||
|
- "0.8.1"
|
||||||
|
- "0.8.0"
|
||||||
|
- "0.8.0b3"
|
||||||
|
- "0.8.0b2"
|
||||||
|
- "0.8.0b2hf2"
|
||||||
|
- "0.8.0b2hf1"
|
||||||
|
- "0.8.0b1"
|
||||||
|
- "0.8.0a4"
|
||||||
|
- "0.8.0a3"
|
||||||
|
- "0.8.0a2"
|
||||||
|
- "0.8.0a1"
|
||||||
|
- "0.7.2"
|
||||||
|
- "0.7.1"
|
||||||
|
- "0.7.0"
|
||||||
|
- "0.6.3"
|
||||||
|
- "0.6.2"
|
||||||
|
- "0.6.1"
|
||||||
|
- "0.6.0"
|
||||||
|
- "0.5.2"
|
||||||
|
- "0.5.1"
|
||||||
|
- "0.5.0"
|
||||||
|
- "0.5.0preview3"
|
||||||
|
- "0.5.0preview2"
|
||||||
|
- "0.5.0preview1"
|
||||||
|
- "0.4.3"
|
||||||
|
- "0.4.3preview1"
|
||||||
|
- "0.4.2"
|
||||||
|
- "0.4.1"
|
||||||
|
- "0.4.0"
|
||||||
|
- "0.3.0"
|
||||||
|
- "0.2.0"
|
||||||
|
- "0.1.1"
|
||||||
|
- "0.1.0"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: input
|
||||||
|
attributes:
|
||||||
|
label: "OBS Studio Log"
|
||||||
|
description: "Upload a normal log file that showcases the issue happening. If you encountered a crash, also fill out the next field."
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "OBS Studio Crash Log"
|
||||||
|
description: "If OBS Studio crashed (not froze) paste the crash log here, or upload it somewhere and paste the link here."
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Current Behavior"
|
||||||
|
description: "What actually happened when you used StreamFX?"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Expected Behavior"
|
||||||
|
description: "What did you expect to happen when using StreamFX?"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Steps to Reproduce the Bug"
|
||||||
|
description: "What steps are required to consistently reproduce the bug/crash/freeze?"
|
||||||
|
validations:
|
||||||
|
required: true
|
||||||
|
- type: textarea
|
||||||
|
attributes:
|
||||||
|
label: "Any additional Information we need to know?"
|
||||||
|
description: "If you answered '(Other)' to any system relevant information, explain what you mean by that here."
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
### Explain the Pull Request
|
||||||
|
<!-- Describe the PR in as much detail as possible, leave nothing out. -->
|
||||||
|
<!-- If you think images or example videos help describe the PR, include them. -->
|
||||||
|
<!-- Additionally, link any PRs, Issues, etc. that may be relevant. -->
|
||||||
|
|
||||||
|
### Checklist
|
||||||
|
- [ ] I will become the maintainer for this part of code.
|
||||||
|
- [ ] I have tested this code. <!-- If you lie here, it will show in the CI builds. -->
|
||||||
Vendored
+21
@@ -0,0 +1,21 @@
|
|||||||
|
{
|
||||||
|
// See https://go.microsoft.com/fwlink/?LinkId=733558
|
||||||
|
// for the documentation about the tasks.json format
|
||||||
|
"version": "2.0.0",
|
||||||
|
"tasks": [
|
||||||
|
{
|
||||||
|
"label": "Test",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "cmake",
|
||||||
|
"args": [
|
||||||
|
"-Htests",
|
||||||
|
"-Bbuild/tests"
|
||||||
|
],
|
||||||
|
"group": {
|
||||||
|
"kind": "test",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
{
|
||||||
|
"folders": [
|
||||||
|
{
|
||||||
|
"path": "."
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"settings": {
|
||||||
|
"editor.tabSize": 4
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,56 @@
|
|||||||
|
# Configuration file for the Sphinx documentation builder.
|
||||||
|
#
|
||||||
|
# This file only contains a selection of the most common options. For a full
|
||||||
|
# list see the documentation:
|
||||||
|
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||||
|
|
||||||
|
# -- Path setup --------------------------------------------------------------
|
||||||
|
|
||||||
|
# If extensions (or modules to document with autodoc) are in another directory,
|
||||||
|
# add these directories to sys.path here. If the directory is relative to the
|
||||||
|
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||||
|
#
|
||||||
|
# import os
|
||||||
|
# import sys
|
||||||
|
# sys.path.insert(0, os.path.abspath('.'))
|
||||||
|
|
||||||
|
|
||||||
|
# -- Project information -----------------------------------------------------
|
||||||
|
|
||||||
|
project = 'version'
|
||||||
|
copyright = "2022, Michael Fabian Dirks"
|
||||||
|
author = "Michael Fabian 'Xaymar' Dirks"
|
||||||
|
version = "0.1"
|
||||||
|
release = "0.1"
|
||||||
|
|
||||||
|
|
||||||
|
# -- General configuration ---------------------------------------------------
|
||||||
|
|
||||||
|
# Add any Sphinx extension module names here, as strings. They can be
|
||||||
|
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||||
|
# ones.
|
||||||
|
extensions = [
|
||||||
|
]
|
||||||
|
|
||||||
|
# Add any paths that contain templates here, relative to this directory.
|
||||||
|
templates_path = ['_templates']
|
||||||
|
|
||||||
|
# List of patterns, relative to source directory, that match files and
|
||||||
|
# directories to ignore when looking for source files.
|
||||||
|
# This pattern also affects html_static_path and html_extra_path.
|
||||||
|
exclude_patterns = [
|
||||||
|
"Thumbs.db"
|
||||||
|
".DS_Store"
|
||||||
|
]
|
||||||
|
|
||||||
|
# -- Options for HTML output -------------------------------------------------
|
||||||
|
|
||||||
|
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||||
|
# a list of builtin themes.
|
||||||
|
#
|
||||||
|
html_theme = 'sphinx_rtd_theme'
|
||||||
|
|
||||||
|
# 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,
|
||||||
|
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||||
|
html_static_path = ['_static']
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
Version handling for CMake
|
||||||
|
=========================================
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 1
|
||||||
|
|
||||||
|
version
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
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.
|
||||||
|
|
||||||
@@ -0,0 +1,108 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
project(cmake-version)
|
||||||
|
|
||||||
|
include("helpers.cmake")
|
||||||
|
|
||||||
|
# ToDo: Add even more test cases, as we don't want a burning bar because someone asked where the toilet is.
|
||||||
|
|
||||||
|
# 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.0+6" BUILD 6)
|
||||||
|
# - 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")
|
||||||
|
|
||||||
|
# Parsing
|
||||||
|
message(STATUS "\n\n===== Parsing =====")
|
||||||
|
# - Valid Cases
|
||||||
|
test_parse("1.2" MAJOR 1 MINOR 2)
|
||||||
|
test_parse("1.2.3" MAJOR 1 MINOR 2 PATCH 3)
|
||||||
|
test_parse("1.2.3.4" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4)
|
||||||
|
test_parse("1.2-5" MAJOR 1 MINOR 2 PRERELEASE 5)
|
||||||
|
test_parse("1.2.3-5" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE 5)
|
||||||
|
test_parse("1.2.3.4-5" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE 5)
|
||||||
|
test_parse("1.2a5" MAJOR 1 MINOR 2 PRERELEASE a5)
|
||||||
|
test_parse("1.2.3a5" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE a5)
|
||||||
|
test_parse("1.2.3.4a5" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE a5)
|
||||||
|
test_parse("1.2+6" MAJOR 1 MINOR 2 BUILD 6)
|
||||||
|
test_parse("1.2.3+6" MAJOR 1 MINOR 2 PATCH 3 BUILD 6)
|
||||||
|
test_parse("1.2.3.4+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 BUILD 6)
|
||||||
|
test_parse("1.2-5+6" MAJOR 1 MINOR 2 PRERELEASE 5 BUILD 6)
|
||||||
|
test_parse("1.2.3-5+6" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE 5 BUILD 6)
|
||||||
|
test_parse("1.2.3.4-5+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE 5 BUILD 6)
|
||||||
|
test_parse("1.2a5+6" MAJOR 1 MINOR 2 PRERELEASE a5 BUILD 6)
|
||||||
|
test_parse("1.2.3a5+6" MAJOR 1 MINOR 2 PATCH 3 PRERELEASE a5 BUILD 6)
|
||||||
|
test_parse("1.2.3.4a5+6" MAJOR 1 MINOR 2 PATCH 3 TWEAK 4 PRERELEASE a5 BUILD 6)
|
||||||
|
# - Invalid Cases
|
||||||
|
test_parse("" FAIL)
|
||||||
|
test_parse("cmake" FAIL)
|
||||||
|
test_parse("0" FAIL)
|
||||||
|
test_parse("-1.0.0" FAIL)
|
||||||
|
test_parse("11.bad.0" FAIL)
|
||||||
|
test_parse("0.0.0+.0" FAIL)
|
||||||
|
|
||||||
|
# Modifying
|
||||||
|
message(STATUS "\n\n===== Modifying =====")
|
||||||
|
# - Valid Cases
|
||||||
|
test_modify("1.0" "0.0" MAJOR 1)
|
||||||
|
test_modify("1.0" "0.0" MAJOR "+1")
|
||||||
|
test_modify("1.0" "2.0" MAJOR "-1")
|
||||||
|
test_modify("0.2" "0.0" MINOR 2)
|
||||||
|
test_modify("0.2" "0.0" MINOR "+2")
|
||||||
|
test_modify("0.2" "0.3" MINOR "-1")
|
||||||
|
test_modify("0.0.3" "0.0" PATCH 3)
|
||||||
|
test_modify("0.0.3" "0.0.2" PATCH "+1")
|
||||||
|
test_modify("0.0.3" "0.0.4" PATCH "-1")
|
||||||
|
test_modify("0.0.0.4" "0.0" TWEAK 4)
|
||||||
|
test_modify("0.0.0.4" "0.0.0.3" TWEAK "+1")
|
||||||
|
test_modify("0.0.0.4" "0.0.0.5" TWEAK "-1")
|
||||||
|
test_modify("0.0-5" "0.0" COMPRESS PRERELEASE 5)
|
||||||
|
test_modify("0.0a5" "0.0" COMPRESS PRERELEASE a5)
|
||||||
|
test_modify("0.0+6" "0.0" COMPRESS BUILD 6)
|
||||||
|
test_modify("0.0-5+6" "0.0" COMPRESS PRERELEASE 5 BUILD 6)
|
||||||
|
test_modify("0.0a5+6" "0.0" COMPRESS PRERELEASE a5 BUILD 6)
|
||||||
|
# - 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 "#")
|
||||||
|
|
||||||
|
# Comparing
|
||||||
|
message(STATUS "\n\n===== Comparing =====")
|
||||||
|
# - Base Components Comparison
|
||||||
|
test_compare("0.0" "" "0.0")
|
||||||
|
test_compare("1.0" ">MAJOR" "0.0")
|
||||||
|
test_compare("0.0" "<MAJOR" "1.0")
|
||||||
|
test_compare("0.2" ">MINOR" "0.0")
|
||||||
|
test_compare("0.0" "<MINOR" "0.2")
|
||||||
|
test_compare("0.0.3" ">PATCH" "0.0.0")
|
||||||
|
test_compare("0.0.0" "<PATCH" "0.0.3")
|
||||||
|
test_compare("0.0.0.4" ">TWEAK" "0.0.0.0")
|
||||||
|
test_compare("0.0.0.0" "<TWEAK" "0.0.0.4")
|
||||||
|
test_compare("0.0-5" "PRERELEASE" "0.0-6")
|
||||||
|
test_compare("0.0+6" "BUILD" "0.0+7")
|
||||||
|
# - Missing Components Tests
|
||||||
|
test_compare("0.0.3" "+PATCH" "0.0")
|
||||||
|
test_compare("0.0" "-PATCH" "0.0.3")
|
||||||
|
test_compare("0.0.0.4" "+TWEAK" "0.0.0")
|
||||||
|
test_compare("0.0.0" "-TWEAK" "0.0.0.4")
|
||||||
|
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")
|
||||||
@@ -0,0 +1,234 @@
|
|||||||
|
include("../version.cmake")
|
||||||
|
|
||||||
|
function(test_generate)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 1
|
||||||
|
_ARGS
|
||||||
|
"COMPRESS;FAIL"
|
||||||
|
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
set(ARGS "")
|
||||||
|
if(_ARGS_MAJOR)
|
||||||
|
set(ARGS "${ARGS} MAJOR \"${_ARGS_MAJOR}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_MINOR)
|
||||||
|
set(ARGS "${ARGS} MINOR \"${_ARGS_MINOR}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_PATCH)
|
||||||
|
set(ARGS "${ARGS} PATCH \"${_ARGS_PATCH}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_TWEAK)
|
||||||
|
set(ARGS "${ARGS} TWEAK \"${_ARGS_TWEAK}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_PRERELEASE)
|
||||||
|
set(ARGS "${ARGS} PRERELEASE \"${_ARGS_PRERELEASE}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_BUILD)
|
||||||
|
set(ARGS "${ARGS} BUILD \"${_ARGS_BUILD}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_COMPRESS)
|
||||||
|
set(ARGS "${ARGS} COMPRESS")
|
||||||
|
endif()
|
||||||
|
cmake_language(EVAL CODE "version(GENERATE _TEST ${ARGS})")
|
||||||
|
|
||||||
|
if(DEFINED _TEST_ERROR)
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.\n\t${_TEST_ERROR}")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}'.\n\t${_TEST_ERROR}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if((ARGV0 STREQUAL _TEST) AND (NOT _ARGS_FAIL))
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}' != '${_TEST}'.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(test_parse)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 1
|
||||||
|
_ARGS
|
||||||
|
"FAIL"
|
||||||
|
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
version(PARSE _TEST "${ARGV0}")
|
||||||
|
|
||||||
|
set(FAILED OFF)
|
||||||
|
set(MESSAGE "${_TEST_ERROR}")
|
||||||
|
if(NOT DEFINED _TEST_ERROR)
|
||||||
|
if(DEFINED _ARGS_MAJOR)
|
||||||
|
if(NOT DEFINED _TEST_MAJOR)
|
||||||
|
set(MESSAGE "MAJOR component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_MAJOR STREQUAL _ARGS_MAJOR))
|
||||||
|
set(MESSAGE "MAJOR component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _ARGS_MINOR)
|
||||||
|
if(NOT DEFINED _TEST_MINOR)
|
||||||
|
set(MESSAGE "MINOR component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_MINOR STREQUAL _ARGS_MINOR))
|
||||||
|
set(MESSAGE "MINOR component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _ARGS_PATCH)
|
||||||
|
if(NOT DEFINED _TEST_PATCH)
|
||||||
|
set(MESSAGE "PATCH component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_PATCH STREQUAL _ARGS_PATCH))
|
||||||
|
set(MESSAGE "PATCH component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _ARGS_TWEAK)
|
||||||
|
if(NOT DEFINED _TEST_TWEAK)
|
||||||
|
set(MESSAGE "TWEAK component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_TWEAK STREQUAL _ARGS_TWEAK))
|
||||||
|
set(MESSAGE "TWEAK component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _ARGS_PRERELEASE)
|
||||||
|
if(NOT DEFINED _TEST_PRERELEASE)
|
||||||
|
set(MESSAGE "PRERELEASE component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_PRERELEASE STREQUAL _ARGS_PRERELEASE))
|
||||||
|
set(MESSAGE "PRERELEASE component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(DEFINED _ARGS_BUILD)
|
||||||
|
if(NOT DEFINED _TEST_BUILD)
|
||||||
|
set(MESSAGE "BUILD component missing during parse.")
|
||||||
|
set(FAILED ON)
|
||||||
|
elseif(NOT (_TEST_BUILD STREQUAL _ARGS_BUILD))
|
||||||
|
set(MESSAGE "BUILD component mismatch.")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FAILED)
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.\n\t${MESSAGE}")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}'.\n\t${MESSAGE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}'.")
|
||||||
|
else()
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(test_modify)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 2
|
||||||
|
_ARGS
|
||||||
|
"FAIL;COMPRESS"
|
||||||
|
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
set(ARGS "")
|
||||||
|
if(_ARGS_MAJOR)
|
||||||
|
set(ARGS "${ARGS} MAJOR \"${_ARGS_MAJOR}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_MINOR)
|
||||||
|
set(ARGS "${ARGS} MINOR \"${_ARGS_MINOR}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_PATCH)
|
||||||
|
set(ARGS "${ARGS} PATCH \"${_ARGS_PATCH}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_TWEAK)
|
||||||
|
set(ARGS "${ARGS} TWEAK \"${_ARGS_TWEAK}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_PRERELEASE)
|
||||||
|
set(ARGS "${ARGS} PRERELEASE \"${_ARGS_PRERELEASE}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_BUILD)
|
||||||
|
set(ARGS "${ARGS} BUILD \"${_ARGS_BUILD}\"")
|
||||||
|
endif()
|
||||||
|
if(_ARGS_COMPRESS)
|
||||||
|
set(ARGS "${ARGS} COMPRESS")
|
||||||
|
endif()
|
||||||
|
cmake_language(EVAL CODE "version(MODIFY _TEST \"${ARGV1}\" ${ARGS})")
|
||||||
|
|
||||||
|
set(FAILED OFF)
|
||||||
|
if(DEFINED _TEST_ERROR)
|
||||||
|
set(MESSAGE "${_TEST_ERROR}")
|
||||||
|
set(FAILED ON)
|
||||||
|
else()
|
||||||
|
if(NOT (_TEST STREQUAL ARGV0))
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FAILED)
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.\n\t${MESSAGE}")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}' != '${_TEST}'.\n\t${MESSAGE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}' != '${_TEST}'.\n\t${MESSAGE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "PASSED: '${ARGV0}'.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(test_compare)
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 3
|
||||||
|
_ARGS
|
||||||
|
"FAIL"
|
||||||
|
"RESULT"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
version(COMPARE _TEST "${ARGV0}" "${ARGV2}")
|
||||||
|
set(FAILED OFF)
|
||||||
|
if(DEFINED _TEST_ERROR)
|
||||||
|
set(MESSAGE "${_TEST_ERROR}")
|
||||||
|
set(FAILED ON)
|
||||||
|
else()
|
||||||
|
if(NOT (_TEST STREQUAL ARGV1))
|
||||||
|
set(MESSAGE "'${_TEST}' != '${ARGV1}'")
|
||||||
|
set(FAILED ON)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(FAILED)
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(STATUS "PASSED: '${ARGV0}' '${ARGV1}' '${ARGV2}'.\n\t${MESSAGE}")
|
||||||
|
else()
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}' '${ARGV1}' '${ARGV2}'.\n\t${MESSAGE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(_ARGS_FAIL)
|
||||||
|
message(SEND_ERROR "FAILED: '${ARGV0}' '${ARGV1}' '${ARGV2}'.\n\t${MESSAGE}")
|
||||||
|
else()
|
||||||
|
message(STATUS "PASSED: '${ARGV0}' '${ARGV1}' '${ARGV2}'.")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
# Minimal makefile for Sphinx documentation
|
||||||
|
#
|
||||||
|
|
||||||
|
# You can set these variables from the command line, and also
|
||||||
|
# from the environment for the first two.
|
||||||
|
SPHINXOPTS ?=
|
||||||
|
SPHINXBUILD ?= sphinx-build
|
||||||
|
SOURCEDIR = ../docs
|
||||||
|
BUILDDIR = ../build/docs
|
||||||
|
|
||||||
|
# Put it first so that "make" without argument is like "make help".
|
||||||
|
help:
|
||||||
|
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
|
|
||||||
|
.PHONY: help Makefile
|
||||||
|
|
||||||
|
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||||
|
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||||
|
%: Makefile
|
||||||
|
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||||
@@ -0,0 +1,35 @@
|
|||||||
|
@ECHO OFF
|
||||||
|
|
||||||
|
pushd %~dp0
|
||||||
|
|
||||||
|
REM Command file for Sphinx documentation
|
||||||
|
|
||||||
|
if "%SPHINXBUILD%" == "" (
|
||||||
|
set SPHINXBUILD=sphinx-build
|
||||||
|
)
|
||||||
|
set SOURCEDIR=../docs
|
||||||
|
set BUILDDIR=../build/docs
|
||||||
|
|
||||||
|
%SPHINXBUILD% >NUL 2>NUL
|
||||||
|
if errorlevel 9009 (
|
||||||
|
echo.
|
||||||
|
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||||
|
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||||
|
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||||
|
echo.may add the Sphinx directory to PATH.
|
||||||
|
echo.
|
||||||
|
echo.If you don't have Sphinx installed, grab it from
|
||||||
|
echo.https://www.sphinx-doc.org/
|
||||||
|
exit /b 1
|
||||||
|
)
|
||||||
|
|
||||||
|
if "%1" == "" goto help
|
||||||
|
|
||||||
|
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
goto end
|
||||||
|
|
||||||
|
:help
|
||||||
|
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||||
|
|
||||||
|
:end
|
||||||
|
popd
|
||||||
+340
@@ -0,0 +1,340 @@
|
|||||||
|
# Copyright (C) 2022, Michael Fabian 'Xaymar' Dirks <info@xaymar.com>. All Rights Reserved
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
|
||||||
|
#
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
|
||||||
|
#
|
||||||
|
# 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
|
||||||
|
#
|
||||||
|
# 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.
|
||||||
|
|
||||||
|
# For SemVer 2.0.0
|
||||||
|
|
||||||
|
function(version)
|
||||||
|
unset(${OUT_VAR} PARENT_SCOPE)
|
||||||
|
unset(${OUT_VAR}_ERROR PARENT_SCOPE)
|
||||||
|
set(OUT_VAR "${ARGV1}")
|
||||||
|
set(_ "")
|
||||||
|
|
||||||
|
string(TOUPPER "${ARGV0}" ARGV0)
|
||||||
|
if(ARGV0 STREQUAL "PARSE")
|
||||||
|
# <major> "." <minor> ["." <patch> ["." <tweak>]]
|
||||||
|
# <major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
|
||||||
|
|
||||||
|
# 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\.\-]*|)$]]))
|
||||||
|
set(${OUT_VAR}_ERROR "Version format not supported: '${ARGV2}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# {1} = Major
|
||||||
|
set(${OUT_VAR}_MAJOR "${CMAKE_MATCH_1}" PARENT_SCOPE)
|
||||||
|
# {2} = Minor
|
||||||
|
set(${OUT_VAR}_MINOR "${CMAKE_MATCH_2}" PARENT_SCOPE)
|
||||||
|
# {3} = Patch
|
||||||
|
if(CMAKE_MATCH_3)
|
||||||
|
string(SUBSTRING "${CMAKE_MATCH_3}" 1 -1 _TMP)
|
||||||
|
set(${OUT_VAR}_PATCH "${_TMP}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
unset(${OUT_VAR}_PATCH PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
# {4} = Tweak
|
||||||
|
if(CMAKE_MATCH_4)
|
||||||
|
string(SUBSTRING "${CMAKE_MATCH_4}" 1 -1 _TMP)
|
||||||
|
set(${OUT_VAR}_TWEAK "${_TMP}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
unset(${OUT_VAR}_TWEAK PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
# {5} = PreRelease
|
||||||
|
if(CMAKE_MATCH_5)
|
||||||
|
string(SUBSTRING "${CMAKE_MATCH_5}" 0 1 _TMP)
|
||||||
|
if(_TMP STREQUAL "-")
|
||||||
|
string(SUBSTRING "${CMAKE_MATCH_5}" 1 -1 _TMP)
|
||||||
|
set(${OUT_VAR}_PRERELEASE "${_TMP}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_PRERELEASE "${CMAKE_MATCH_5}" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
unset(${OUT_VAR}_PRERELEASE PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
# {6} = Build
|
||||||
|
if(CMAKE_MATCH_6)
|
||||||
|
string(SUBSTRING "${CMAKE_MATCH_6}" 1 -1 _TMP)
|
||||||
|
set(${OUT_VAR}_BUILD "${_TMP}" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
unset(${OUT_VAR}_BUILD PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
elseif(ARGV0 STREQUAL "GENERATE")
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 2
|
||||||
|
_ARGS
|
||||||
|
"COMPRESS"
|
||||||
|
"MAJOR;MINOR;PATCH;TWEAK;PRERELEASE;BUILD"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
# Do we have the major component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_MAJOR)
|
||||||
|
string(STRIP "${_ARGS_MAJOR}" _ARGS_MAJOR)
|
||||||
|
if(_ARGS_MAJOR STREQUAL "")
|
||||||
|
set(_ARGS_MAJOR 0)
|
||||||
|
elseif(NOT (_ARGS_MAJOR MATCHES [[^[0-9]+$]]))
|
||||||
|
set(${OUT_VAR}_ERROR "MAJOR component must be a numeric identifier, but is: '${_ARGS_MAJOR}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(_ARGS_MAJOR 0)
|
||||||
|
endif()
|
||||||
|
set(_ "${_}${_ARGS_MAJOR}")
|
||||||
|
|
||||||
|
# Do we have the minor component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_MINOR)
|
||||||
|
string(STRIP "${_ARGS_MINOR}" _ARGS_MINOR)
|
||||||
|
if(_ARGS_MINOR STREQUAL "")
|
||||||
|
set(_ARGS_MINOR 0)
|
||||||
|
elseif(NOT (_ARGS_MINOR MATCHES [[^[0-9]+$]]))
|
||||||
|
set(${OUT_VAR}_ERROR "MINOR component must be a numeric identifier, but is: '${_ARGS_MINOR}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(_ARGS_MINOR 0)
|
||||||
|
endif()
|
||||||
|
set(_ "${_}.${_ARGS_MINOR}")
|
||||||
|
|
||||||
|
# Do we have the patch component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_PATCH)
|
||||||
|
string(STRIP "${_ARGS_PATCH}" _ARGS_PATCH)
|
||||||
|
if(_ARGS_PATCH STREQUAL "")
|
||||||
|
unset(_ARGS_PATCH)
|
||||||
|
elseif(_ARGS_PATCH MATCHES [[^[0-9]+$]])
|
||||||
|
set(_ "${_}.${_ARGS_PATCH}")
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_ERROR "PATCH component must be a numeric identifier, but is: '${_ARGS_PATCH}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Do we have the tweak component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_TWEAK)
|
||||||
|
string(STRIP "${_ARGS_TWEAK}" _ARGS_TWEAK)
|
||||||
|
if(_ARGS_TWEAK STREQUAL "")
|
||||||
|
unset(_ARGS_TWEAK)
|
||||||
|
elseif(_ARGS_TWEAK MATCHES [[^[0-9]+$]])
|
||||||
|
if(NOT DEFINED _ARGS_PATCH)
|
||||||
|
set(_ "${_}.0")
|
||||||
|
endif()
|
||||||
|
set(_ "${_}.${_ARGS_TWEAK}")
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_ERROR "TWEAK component must be a numeric identifier, but is: '${_ARGS_TWEAK}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Do we have the pre-release component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_PRERELEASE)
|
||||||
|
string(STRIP "${_ARGS_PRERELEASE}" _ARGS_PRERELEASE)
|
||||||
|
if(_ARGS_PRERELEASE STREQUAL "")
|
||||||
|
unset(_ARGS_PRERELEASE)
|
||||||
|
elseif(_ARGS_PRERELEASE MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||||
|
if(_ARGS_COMPRESS AND (_ARGS_PRERELEASE MATCHES [[[a-zA-Z]+[a-zA-Z0-9\\-\\.]*$]]))
|
||||||
|
set(_ "${_}${_ARGS_PRERELEASE}")
|
||||||
|
else()
|
||||||
|
set(_ "${_}-${_ARGS_PRERELEASE}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_ERROR "PRERELEASE component must be an alphanumeric identifier, but is: '${_ARGS_PRERELEASE}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Do we have the build component, and is it valid?
|
||||||
|
if(DEFINED _ARGS_BUILD)
|
||||||
|
string(STRIP "${_ARGS_BUILD}" _ARGS_PRERELEASE)
|
||||||
|
if(_ARGS_BUILD STREQUAL "")
|
||||||
|
unset(_ARGS_BUILD)
|
||||||
|
elseif(_ARGS_BUILD MATCHES [[^[a-zA-Z0-9]+[a-zA-Z0-9\-\.]*$]])
|
||||||
|
set(_ "${_}+${_ARGS_BUILD}")
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR}_ERROR "BUILD component must be an alphanumeric identifier, but is: '${_ARGS_BUILD}'" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(${OUT_VAR} "${_}" PARENT_SCOPE)
|
||||||
|
elseif(ARGV0 STREQUAL "MODIFY")
|
||||||
|
# Requires PARSE and GENERATE.
|
||||||
|
cmake_parse_arguments(
|
||||||
|
PARSE_ARGV 3
|
||||||
|
_ARGS
|
||||||
|
"COMPRESS"
|
||||||
|
"MAJOR;MINOR;PATCH;BUILD;PRERELEASE;COMMIT"
|
||||||
|
""
|
||||||
|
)
|
||||||
|
|
||||||
|
# Helpers
|
||||||
|
macro(modify_version_number)
|
||||||
|
if(DEFINED ${ARGV1})
|
||||||
|
if(${ARGV1} MATCHES "^(\\+|\\-)([0-9]+)$")
|
||||||
|
if(DEFINED ${ARGV0})
|
||||||
|
math(EXPR ${ARGV0} "${${ARGV0}} ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||||
|
else()
|
||||||
|
math(EXPR ${ARGV0} "0 ${CMAKE_MATCH_1} ${CMAKE_MATCH_2}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
set(${ARGV0} "${${ARGV1}}")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
endmacro()
|
||||||
|
|
||||||
|
# Parse the given version.
|
||||||
|
version(PARSE _TEMP "${ARGV2}")
|
||||||
|
if(DEFINED _TEMP_ERROR)
|
||||||
|
set(${OUT_VAR}_ERROR ${_TEMP_ERROR} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Modify core version components
|
||||||
|
modify_version_number(_TEMP_MAJOR _ARGS_MAJOR)
|
||||||
|
modify_version_number(_TEMP_MINOR _ARGS_MINOR)
|
||||||
|
modify_version_number(_TEMP_PATCH _ARGS_PATCH)
|
||||||
|
modify_version_number(_TEMP_TWEAK _ARGS_TWEAK)
|
||||||
|
|
||||||
|
# Replace other components if defined.
|
||||||
|
if(DEFINED _ARGS_PRERELEASE)
|
||||||
|
set(_TEMP_PRERELEASE "${_ARGS_PRERELEASE}")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _ARGS_BUILD)
|
||||||
|
set(_TEMP_BUILD "${_ARGS_BUILD}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Generate a new version.
|
||||||
|
set(_ARGS "")
|
||||||
|
if(DEFINED _TEMP_MAJOR AND (NOT _TEMP_MAJOR STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} MAJOR \"${_TEMP_MAJOR}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _TEMP_MINOR AND (NOT _TEMP_MINOR STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} MINOR \"${_TEMP_MINOR}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _TEMP_PATCH AND (NOT _TEMP_PATCH STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} PATCH \"${_TEMP_PATCH}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _TEMP_TWEAK AND (NOT _TEMP_TWEAK STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} TWEAK \"${_TEMP_TWEAK}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _TEMP_PRERELEASE AND (NOT _TEMP_PRERELEASE STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} PRERELEASE \"${_TEMP_PRERELEASE}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _TEMP_BUILD AND (NOT _TEMP_BUILD STREQUAL ""))
|
||||||
|
set(_ARGS "${_ARGS} BUILD \"${_TEMP_BUILD}\"")
|
||||||
|
endif()
|
||||||
|
if(DEFINED _ARGS_COMPRESS)
|
||||||
|
set(_ARGS "${_ARGS} COMPRESS")
|
||||||
|
endif()
|
||||||
|
cmake_language(EVAL CODE "version(GENERATE _TEMP ${_ARGS})")
|
||||||
|
if(DEFINED _TEMP_ERROR)
|
||||||
|
set(${OUT_VAR}_ERROR ${_TEMP_ERROR} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
set(${OUT_VAR} "${_TEMP}" PARENT_SCOPE)
|
||||||
|
elseif(ARGV0 STREQUAL "COMPARE")
|
||||||
|
# Requires PARSE.
|
||||||
|
|
||||||
|
# Parse first version
|
||||||
|
version(PARSE _A "${ARGV2}")
|
||||||
|
if(DEFINED _A_ERROR)
|
||||||
|
set(${OUT_VAR}_ERROR ${_A_ERROR} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Parse second version
|
||||||
|
version(PARSE _B "${ARGV3}")
|
||||||
|
if(DEFINED _B_ERROR)
|
||||||
|
set(${OUT_VAR}_ERROR ${_B_ERROR} PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Major
|
||||||
|
if(_A_MAJOR GREATER _B_MAJOR)
|
||||||
|
set(${OUT_VAR} ">MAJOR" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif(_A_MAJOR LESS _B_MAJOR)
|
||||||
|
set(${OUT_VAR} "<MAJOR" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Minor
|
||||||
|
if(_A_MINOR GREATER _B_MINOR)
|
||||||
|
set(${OUT_VAR} ">MINOR" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif(_A_MINOR LESS _B_MINOR)
|
||||||
|
set(${OUT_VAR} "<MINOR" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Patch
|
||||||
|
if((DEFINED _A_PATCH OR DEFINED _B_PATCH) AND ((NOT DEFINED _A_PATCH) OR (NOT DEFINED _B_PATCH)))
|
||||||
|
if(DEFINED _A_PATCH)
|
||||||
|
set(${OUT_VAR} "+PATCH" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR} "-PATCH" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
return()
|
||||||
|
elseif(_A_PATCH GREATER _B_PATCH)
|
||||||
|
set(${OUT_VAR} ">PATCH" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif(_A_PATCH LESS _B_PATCH)
|
||||||
|
set(${OUT_VAR} "<PATCH" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Tweak
|
||||||
|
if((DEFINED _A_TWEAK OR DEFINED _B_TWEAK) AND ((NOT DEFINED _A_TWEAK) OR (NOT DEFINED _B_TWEAK)))
|
||||||
|
if(DEFINED _A_TWEAK)
|
||||||
|
set(${OUT_VAR} "+TWEAK" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR} "-TWEAK" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
return()
|
||||||
|
elseif(_A_TWEAK GREATER _B_TWEAK)
|
||||||
|
set(${OUT_VAR} ">TWEAK" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif(_A_TWEAK LESS _B_TWEAK)
|
||||||
|
set(${OUT_VAR} "<TWEAK" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Pre-Release
|
||||||
|
if((DEFINED _A_PRERELEASE) AND (DEFINED _B_PRERELEASE) AND (NOT (_A_PRERELEASE STREQUAL _B_PRERELEASE)))
|
||||||
|
set(${OUT_VAR} "PRERELEASE" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif((DEFINED _A_PRERELEASE OR DEFINED _B_PRERELEASE) AND ((NOT DEFINED _A_PRERELEASE) OR (NOT DEFINED _B_PRERELEASE)))
|
||||||
|
if(DEFINED _A_PRERELEASE)
|
||||||
|
set(${OUT_VAR} "+PRERELEASE" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR} "-PRERELEASE" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Build
|
||||||
|
if((DEFINED _A_BUILD) AND (DEFINED _B_BUILD) AND (NOT (_A_BUILD STREQUAL _B_BUILD)))
|
||||||
|
set(${OUT_VAR} "BUILD" PARENT_SCOPE)
|
||||||
|
return()
|
||||||
|
elseif((DEFINED _A_BUILD OR DEFINED _B_BUILD) AND ((NOT DEFINED _A_BUILD) OR (NOT DEFINED _B_BUILD)))
|
||||||
|
if(DEFINED _A_BUILD)
|
||||||
|
set(${OUT_VAR} "+BUILD" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
set(${OUT_VAR} "-BUILD" PARENT_SCOPE)
|
||||||
|
endif()
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Both are exactly the same.
|
||||||
|
set(${OUT_VAR} "" PARENT_SCOPE)
|
||||||
|
else()
|
||||||
|
message(FATAL_ERROR "Unknown command '${ARGV0}'")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
Reference in New Issue
Block a user