diff options
author | Craig Scott <craig.scott@crascit.com> | 2018-05-03 21:17:33 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2018-05-03 21:18:38 (GMT) |
commit | 7de29da7c49da68aee421c646a676422f3b9d563 (patch) | |
tree | 558f2d71fa4ca4a208b130bc12773baca2941763 /Modules/CPack.cmake | |
parent | f1aedbf99acf21bbe9f2d766be8d159bd397cc89 (diff) | |
parent | af1c48871cedc29eb0dc773556c606c670df55ee (diff) | |
download | CMake-7de29da7c49da68aee421c646a676422f3b9d563.zip CMake-7de29da7c49da68aee421c646a676422f3b9d563.tar.gz CMake-7de29da7c49da68aee421c646a676422f3b9d563.tar.bz2 |
Merge topic 'feature/cpack-default-package-version'
af1c48871c CPack: Use project version as default for `CPACK_PACKAGE_VERSION`
Acked-by: Kitware Robot <kwrobot@kitware.com>
Acked-by: Harry Mallon <hjmallon@gmail.com>
Merge-request: !2020
Diffstat (limited to 'Modules/CPack.cmake')
-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 a71f84a..720b972 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 # @@ -367,11 +387,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 |