Files
CMake/Tests/RunCMake/project/VersionSubdir/CMakeLists.txt
T
Vito Gamberini aa16b8eb9a project: Revert changes to VERSION handling
In c4d12d7d we changed how the project command handles various variables
and made the behavior consistent across all variables controlled by
the project command. The conditions under which project() modifies the
various VERSION variables are non-intuitive, but can be observed as
side-effects.

Because this behavior is observable, it requires a policy to be changed.
This commit reverts to the previous behavior until a policy is added
and adds a test for that behavior.

Fixes: #27142
2025-09-02 00:35:24 -04:00

25 lines
915 B
CMake

project(WithVersion LANGUAGES NONE VERSION 1.1.1.1)
project(SubdirNoVersion LANGUAGES NONE)
foreach(post "" "_MAJOR" "_MINOR" "_PATCH" "_TWEAK")
if(NOT DEFINED PROJECT_VERSION${post})
message(SEND_ERROR "PROJECT_VERSION${post} is not defined when previous project version was provided")
continue()
endif()
if(NOT PROJECT_VERSION${post} STREQUAL "")
message(SEND_ERROR "PROJECT_VERSION${post} has value '${PROJECT_VERSION${post}}' when empty string is expected")
endif()
endforeach()
if(NOT CMAKE_PROJECT_VERSION STREQUAL "1.1.1.1")
message(SEND_ERROR "CMAKE_PROJECT_VERSION has value '${CMAKE_PROJECT_VERION}' when 1.1.1.1 is expected")
endif()
foreach(post "_MAJOR" "_MINOR" "_PATCH" "_TWEAK")
if(NOT CMAKE_PROJECT_VERSION${post} STREQUAL "1")
message(SEND_ERROR "CMAKE_PROJECT_VERSION${post} has value '${CMAKE_PROJECT_VERSION${post}}' when 1 is expected")
endif()
endforeach()