Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 2b0699284a | |||
| 9fe3d44d54 | |||
| 208fb31040 | |||
| c61e2cb2ce | |||
| e4313a31ad | |||
| f3d5d3956c | |||
| 519fe4cc75 | |||
| 50e6f494af |
@@ -0,0 +1,88 @@
|
||||
name: Generate Documentation
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!documentation'
|
||||
paths:
|
||||
- '.github/workflows/documentation.yml'
|
||||
- 'docs/**'
|
||||
- 'tools/**'
|
||||
- 'LICENSE'
|
||||
|
||||
jobs:
|
||||
docs:
|
||||
name: "Generate Documentation"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Set up Git"
|
||||
shell: bash
|
||||
run: |
|
||||
git config --global user.name 'GitHub Actions'
|
||||
git config --global user.email 'xaymar@users.noreply.github.com'
|
||||
git config --global pull.ff only
|
||||
git config --global pull.rebase true
|
||||
|
||||
- name: "Clone"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Clone Documentation"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
ref: 'documentation'
|
||||
path: 'build/docs/html'
|
||||
submodules: 'recursive'
|
||||
fetch-depth: 0
|
||||
# git clone --progress --recursive -b documentation --single-branch https://x-access-token:${{ github.token }}@github.com/${{ github.repository }} "${{ github.workspace }}/build/docs/html"
|
||||
|
||||
- name: "Install Prerequisites"
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install make python3 python3-pip python3-virtualenv
|
||||
|
||||
- name: "Install Sphinx and Themes into a VirtualEnv"
|
||||
shell: bash
|
||||
run: |
|
||||
source ~/.profile
|
||||
virtualenv build/venv
|
||||
source build/venv/bin/activate
|
||||
pip install sphinx
|
||||
pip install sphinx-rtd-theme
|
||||
|
||||
- name: "Generate Documentation"
|
||||
shell: bash
|
||||
run: |
|
||||
source ~/.profile
|
||||
source build/venv/bin/activate
|
||||
pushd tools
|
||||
make html
|
||||
ls -lha
|
||||
popd
|
||||
ls -lha
|
||||
|
||||
- name: "Update Documentation"
|
||||
shell: bash
|
||||
run: |
|
||||
pushd build/docs/html
|
||||
git add .
|
||||
git --no-pager diff --patch --minimal HEAD --
|
||||
git update-index --refresh
|
||||
if ! git diff-index --quiet HEAD --; then
|
||||
git commit -a -m "${{ github.sha }}"
|
||||
|
||||
# Only push from master branch.
|
||||
if [[ "${{ github.ref }}" == "refs/heads/master" ]]; then
|
||||
git push
|
||||
echo "Documentation has been updated!"
|
||||
else
|
||||
git log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr) %C(bold blue)<%an>%Creset' --abbrev-commit
|
||||
fi
|
||||
else
|
||||
echo "Documentation is still up to date."
|
||||
fi
|
||||
popd
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
name: Automated Testing
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- '*'
|
||||
- '!documentation'
|
||||
paths:
|
||||
- '.github/workflows/test.yml'
|
||||
- 'tests/**'
|
||||
- 'version.cmake'
|
||||
pull_request:
|
||||
paths:
|
||||
- '.github/workflows/test.yml'
|
||||
- 'tests/**'
|
||||
- 'version.cmake'
|
||||
|
||||
jobs:
|
||||
test:
|
||||
name: "Run Tests"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: "Clone"
|
||||
uses: actions/checkout@v3
|
||||
with:
|
||||
submodules: recursive
|
||||
fetch-depth: 0
|
||||
|
||||
- name: "Install Prerequisites"
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt-get install build-essential cmake
|
||||
|
||||
- name: "Run Tests"
|
||||
shell: bash
|
||||
run: |
|
||||
cmake -Htests -Bbuild/tests
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
Copyright 2021 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
||||
Copyright 2022 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
# cmake-version
|
||||
Tired of manually parsing, modifying and comparing versions? Then this may help you! cmake-version is a pure CMake module that supports parsing, modifying, generating and comparing versions in the format specified by Semantic Versioning 1.0.0, Semantic Versioning 2.0.0 and CMake. It also supports a mixture of all formats, for much more functionality.
|
||||
|
||||
## [Documentation](https://xaymar.github.io/cmake-version/)
|
||||
The documentation is generated by Sphinx with the `Read the Docs` theme and is available at [xaymar.github.io/cmake-version/](https://xaymar.github.io/cmake-version/).
|
||||
|
||||
## License
|
||||
> Copyright 2022 Michael Fabian 'Xaymar' Dirks <info@xaymar.com>
|
||||
>
|
||||
> 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.
|
||||
+3
-3
@@ -20,8 +20,8 @@
|
||||
project = 'version'
|
||||
copyright = "2022, Michael Fabian Dirks"
|
||||
author = "Michael Fabian 'Xaymar' Dirks"
|
||||
version = "0.1"
|
||||
release = "0.1"
|
||||
version = "1.0"
|
||||
release = "1.0"
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
@@ -53,4 +53,4 @@ 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']
|
||||
html_static_path = []
|
||||
+75
-6
@@ -1,7 +1,76 @@
|
||||
Version handling for CMake
|
||||
=========================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
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.
|
||||
|
||||
|
||||
@@ -1,76 +0,0 @@
|
||||
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.
|
||||
|
||||
+77
-1
@@ -10,7 +10,83 @@
|
||||
#
|
||||
# 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
|
||||
#[=======================================================================[.rst:
|
||||
version
|
||||
-------
|
||||
|
||||
Generate, parse and modify versions purely with CMake. Supports Semantic Versioning 2.0.0, 1.0.0 and other version formats.
|
||||
|
||||
Synopsis
|
||||
^^^^^^^^
|
||||
|
||||
.. parsed-literal::
|
||||
|
||||
version(`PARSE`_ <out-var> <string>)
|
||||
version(`GENERATE`_ <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
|
||||
version(`MODIFY`_ <out-var> <string> [COMPRESS] [MAJOR <major>] [MINOR <minor] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
|
||||
version(`COMPARE`_ <out-var> <a> <b>)
|
||||
|
||||
|
||||
The following version constructs are currently supported:
|
||||
|
||||
.. code-block::
|
||||
|
||||
<major> "." <minor> ["." <patch> ["." <tweak>]]
|
||||
<major> "." <minor> ["." <patch> ["." <tweak>]] [["-"] <pre-release>] ["+" <build>]
|
||||
|
||||
|
||||
Parsing
|
||||
^^^^^^^
|
||||
|
||||
.. _PARSE:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
version(PARSE <out-var> <string>)
|
||||
|
||||
Attempts to parse the version in ``<string>`` and stores the individual compoents into ``<out-var>_<component>``. If a component is not present in the given version, it will be undefined. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
|
||||
|
||||
Generating
|
||||
^^^^^^^^^^
|
||||
|
||||
.. _GENERATE:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
version(GENERATE <out-var> [COMPRESS] [MAJOR <major>] [MINOR <minor>] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
|
||||
|
||||
Generates a version from the components provided and stores the result in ``<out-var>``. The components ``<major>`` and ``<minor>`` will default to ``0`` if not provided. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
|
||||
|
||||
Modifying
|
||||
^^^^^^^^^
|
||||
|
||||
.. _MODIFY:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
version(MODIFY <out-var> <string> [COMPRESS] [MAJOR <major>] [MINOR <minor] [PATCH <patch>] [TWEAK <tweak>] [PRERELEASE <prerelease>] [BUILD <build>])
|
||||
|
||||
Modifies the version provided in ``<string>`` with the components provided. The components ``<major>``, ``<minor>``, ``<patch>`` and ``<tweak>`` may have a prefix of ``+`` or ``-`` to add and subtract the value, or no prefix to replace. The result of this operation will be stored as a string in ``<out-var>``. If a component did not exist in the original, it will be added to the version as a replace operation. If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message.
|
||||
|
||||
Comparing
|
||||
^^^^^^^^^
|
||||
|
||||
.. _COMPARE:
|
||||
|
||||
.. code-block:: cmake
|
||||
|
||||
version(COMPARE <out-var> <a> <b>)
|
||||
|
||||
Compares the version ``<a>`` against ``<b>`` and stores the result in ``<out-var>``. The provided version will be evaluated in the order MAJOR, MINOR, PATCH, TWEAK, PRERELEASE, and then BUILD. The following results should be expected:
|
||||
|
||||
- If a component is only in ``<a>``, ``<out-var>`` will contain the componenent name prefixed by ``+``.
|
||||
- If a component is only in ``<b>``, ``<out-var>`` will contain the componenent name prefixed by ``-``.
|
||||
- If a component is numerical and the value is larger in ``<a>``, ``<out-var>`` will contain the componenent name prefixed by ``>``.
|
||||
- If a component is numerical and the value is larger in ``<b>``, ``<out-var>`` will contain the componenent name prefixed by ``<``.
|
||||
- If a component is alphanumerical and the value is different in either, ``<out-var>`` will contain the component name with no prefix.
|
||||
- In all other cases, ``<out-var>`` will be empty.
|
||||
- If an error occurred, ``<out-var>_ERROR`` will be defined and contain the error message, and ``<out-var>`` will be undefined.
|
||||
#]=======================================================================]
|
||||
|
||||
function(version)
|
||||
unset(${OUT_VAR} PARENT_SCOPE)
|
||||
|
||||
Reference in New Issue
Block a user