mirror of
https://github.com/reactos/CMake.git
synced 2024-11-24 12:09:48 +00:00
CPack: Restore support for 0-valued version components
In commit v3.12.0-rc1~136^2 (CPack: Use project version as default for `CPACK_PACKAGE_VERSION`, 2018-04-29) we did not account for the value of `CMAKE_PROJECT_VERSION_{MAJOR,MINOR,PATCH}` having `0`. Fix the logic to distinguish between unprovided version components and `0` components. While at it, add a test case covering the behavior described in the documentation by the original commit. The number of version components in the package name should match those provided to the `project()` command `VERSION` option. Fixes: #18199
This commit is contained in:
parent
f84c15ef2f
commit
ed015bde2b
@ -403,28 +403,31 @@ endfunction()
|
||||
|
||||
# Set the package name
|
||||
_cpack_set_default(CPACK_PACKAGE_NAME "${CMAKE_PROJECT_NAME}")
|
||||
if(CMAKE_PROJECT_VERSION_MAJOR)
|
||||
|
||||
# Set the package version
|
||||
if(CMAKE_PROJECT_VERSION_MAJOR GREATER_EQUAL 0)
|
||||
_cpack_set_default(CPACK_PACKAGE_VERSION_MAJOR "${CMAKE_PROJECT_VERSION_MAJOR}")
|
||||
if(CMAKE_PROJECT_VERSION_MINOR)
|
||||
if(CMAKE_PROJECT_VERSION_MINOR GREATER_EQUAL 0)
|
||||
_cpack_set_default(CPACK_PACKAGE_VERSION_MINOR "${CMAKE_PROJECT_VERSION_MINOR}")
|
||||
if(CMAKE_PROJECT_VERSION_PATCH)
|
||||
if(CMAKE_PROJECT_VERSION_PATCH GREATER_EQUAL 0)
|
||||
_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()
|
||||
if(NOT DEFINED CPACK_PACKAGE_VERSION)
|
||||
set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}")
|
||||
if(CPACK_PACKAGE_VERSION_MINOR GREATER_EQUAL 0)
|
||||
string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_MINOR}")
|
||||
if(CPACK_PACKAGE_VERSION_PATCH GREATER_EQUAL 0)
|
||||
string(APPEND CPACK_PACKAGE_VERSION ".${CPACK_PACKAGE_VERSION_PATCH}")
|
||||
endif()
|
||||
endif()
|
||||
endif()
|
||||
|
||||
_cpack_set_default(CPACK_PACKAGE_VENDOR "Humanity")
|
||||
if(CMAKE_PROJECT_DESCRIPTION)
|
||||
_cpack_set_default(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||
|
@ -4,3 +4,6 @@ run_cmake(Simple)
|
||||
run_cmake(Default)
|
||||
run_cmake(Special)
|
||||
run_cmake(Verbatim)
|
||||
run_cmake(Version1)
|
||||
run_cmake(Version2)
|
||||
run_cmake(Version3)
|
||||
|
6
Tests/RunCMake/CPackConfig/Version1-check.cmake
Normal file
6
Tests/RunCMake/CPackConfig/Version1-check.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
include(${RunCMake_SOURCE_DIR}/check.cmake)
|
||||
|
||||
test_variable(CPACK_PACKAGE_VERSION "0")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MINOR "")
|
||||
test_variable(CPACK_PACKAGE_VERSION_PATCH "")
|
1
Tests/RunCMake/CPackConfig/Version1.cmake
Normal file
1
Tests/RunCMake/CPackConfig/Version1.cmake
Normal file
@ -0,0 +1 @@
|
||||
project(Version LANGUAGES NONE VERSION 0)
|
6
Tests/RunCMake/CPackConfig/Version2-check.cmake
Normal file
6
Tests/RunCMake/CPackConfig/Version2-check.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
include(${RunCMake_SOURCE_DIR}/check.cmake)
|
||||
|
||||
test_variable(CPACK_PACKAGE_VERSION "1.0")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MINOR "0")
|
||||
test_variable(CPACK_PACKAGE_VERSION_PATCH "")
|
1
Tests/RunCMake/CPackConfig/Version2.cmake
Normal file
1
Tests/RunCMake/CPackConfig/Version2.cmake
Normal file
@ -0,0 +1 @@
|
||||
project(Version LANGUAGES NONE VERSION 1.0)
|
6
Tests/RunCMake/CPackConfig/Version3-check.cmake
Normal file
6
Tests/RunCMake/CPackConfig/Version3-check.cmake
Normal file
@ -0,0 +1,6 @@
|
||||
include(${RunCMake_SOURCE_DIR}/check.cmake)
|
||||
|
||||
test_variable(CPACK_PACKAGE_VERSION "1.1.0")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MAJOR "1")
|
||||
test_variable(CPACK_PACKAGE_VERSION_MINOR "1")
|
||||
test_variable(CPACK_PACKAGE_VERSION_PATCH "0")
|
1
Tests/RunCMake/CPackConfig/Version3.cmake
Normal file
1
Tests/RunCMake/CPackConfig/Version3.cmake
Normal file
@ -0,0 +1 @@
|
||||
project(Version LANGUAGES NONE VERSION 1.1.0)
|
Loading…
Reference in New Issue
Block a user