Files
CMake/Tests/RunCMake/project/Omissions.cmake
T
Matthew Woehlke 04dadd0138 Tests: Ensure project() clears unspecified properties
Add a unit test to ensure that various project-related variables are set
to empty when values are not provided in the project() call.
2025-06-10 15:07:29 -04:00

25 lines
680 B
CMake

function(_expect_empty NAME)
if(NOT DEFINED ${NAME})
message(SEND_ERROR "Variable '${NAME}' is not defined")
elseif(NOT "${${NAME}}" STREQUAL "")
message(SEND_ERROR
"Variable '${NAME}' has value '${${NAME}}' (expected: empty)")
endif()
endfunction()
function(expect_empty SUFFIX)
_expect_empty(PROJECT_${SUFFIX})
_expect_empty(CMAKE_PROJECT_${SUFFIX})
_expect_empty(${PROJECT_NAME}_${SUFFIX})
endfunction()
project(Omissions LANGUAGES)
expect_empty(VERSION)
expect_empty(VERSION_MAJOR)
expect_empty(VERSION_MINOR)
expect_empty(VERSION_PATCH)
expect_empty(VERSION_TWEAK)
expect_empty(COMPAT_VERSION)
expect_empty(DESCRIPTION)
expect_empty(HOMEPAGE_URL)