diff options
author | Alex Turbov <i.zaufi@gmail.com> | 2018-04-29 14:09:40 (GMT) |
---|---|---|
committer | Craig Scott <craig.scott@crascit.com> | 2018-05-02 22:26:03 (GMT) |
commit | af1c48871cedc29eb0dc773556c606c670df55ee (patch) | |
tree | b63e5a9cbfe70122491e277978cbe50f6ec254fc /Modules | |
parent | 1925fe9fed9ef4007e344fdf1fa598e9ad523c4c (diff) | |
download | CMake-af1c48871cedc29eb0dc773556c606c670df55ee.zip CMake-af1c48871cedc29eb0dc773556c606c670df55ee.tar.gz CMake-af1c48871cedc29eb0dc773556c606c670df55ee.tar.bz2 |
CPack: Use project version as default for `CPACK_PACKAGE_VERSION`
* Introduce `CMAKE_PROJECT_VERSION` and the corresponsing components:
`CMAKE_PROJECT_VERSION_MAJOR`, `CMAKE_PROJECT_VERSION_MINOR`,
`CMAKE_PROJECT_VERSION_PATCH` and `CMAKE_PROJECT_VERSION_TWEAK`.
* `CPack` module use `CMAKE_PROJECT_VERSION_MAJOR`,
`CMAKE_PROJECT_VERSION_MINOR` and `CMAKE_PROJECT_VERSION_PATCH`
to initialize corresponsing CPack variables.
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/CPack.cmake | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/Modules/CPack.cmake b/Modules/CPack.cmake index 3ff8be6..9bd13c3 100644 --- a/Modules/CPack.cmake +++ b/Modules/CPack.cmake @@ -80,15 +80,35 @@ # # .. variable:: CPACK_PACKAGE_VERSION_MAJOR # -# Package major Version. Default value is 0. +# Package major version. This variable will always be set, but its default +# value depends on whether or not version details were given to the +# :command:`project` command in the top level CMakeLists.txt file. If version +# details were given, the default value will be +# :variable:`CMAKE_PROJECT_VERSION_MAJOR`. If no version details were given, +# a default version of 0.1.1 will be assumed, leading to +# ``CPACK_PACKAGE_VERSION_MAJOR`` having a default value of 0. # # .. variable:: CPACK_PACKAGE_VERSION_MINOR # -# Package minor Version. Default value is 1. +# Package minor version. The default value is determined based on whether or +# not version details were given to the :command:`project` command in the top +# level CMakeLists.txt file. If version details were given, the default +# value will be :variable:`CMAKE_PROJECT_VERSION_MINOR`, but if no minor +# version component was specified then ``CPACK_PACKAGE_VERSION_MINOR`` will be +# left unset. If no project version was given at all, a default version of +# 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_MINOR`` having a +# default value of 1. # # .. variable:: CPACK_PACKAGE_VERSION_PATCH # -# Package patch Version. Default value is 1. +# Package patch version. The default value is determined based on whether or +# not version details were given to the :command:`project` command in the top +# level CMakeLists.txt file. If version details were given, the default +# value will be :variable:`CMAKE_PROJECT_VERSION_PATCH`, but if no patch +# version component was specified then ``CPACK_PACKAGE_VERSION_PATCH`` will be +# left unset. If no project version was given at all, a default version of +# 0.1.1 will be assumed, leading to ``CPACK_PACKAGE_VERSION_PATCH`` having a +# default value of 1. # # .. variable:: CPACK_PACKAGE_DESCRIPTION_FILE # @@ -368,11 +388,28 @@ endfunction() # Set the package name _cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}") -_cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0") -_cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1") -_cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1") -_cpack_set_default(CPACK_PACKAGE_VERSION - "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +if(CMAKE_PROJECT_VERSION_MAJOR) + _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}") + if(CMAKE_PROJECT_VERSION_MINOR) + _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}") + if(CMAKE_PROJECT_VERSION_PATCH) + _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "${CMAKE_PROJECT_VERSION_PATCH}") + _cpack_set_default(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + else() + _cpack_set_default(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}") + endif() + else() + _cpack_set_default(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}") + endif() +else() + _cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "0") + _cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "1") + _cpack_set_default(CPACK_PACKAGE_VERSION_PATCH "1") + _cpack_set_default(CPACK_PACKAGE_VERSION + "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") +endif() _cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity") if(CMAKE_PROJECT_DESCRIPTION) _cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY |