mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-24 15:38:54 -06:00
If a single-value keyword is followed by an empty string, the command unsets the variable for that keyword instead of setting it to the empty string. This is inconsistent and unexpected. Add policy CMP0174 which ensures the variable for a single-value keyword is always set when any value is given, not just for a non-empty value. The new CMP0174 policy only affects the PARSE_ARGV form of cmake_parse_arguments. The older form silently drops all empty string arguments before processing the argument list. Fixes: #25972
33 lines
1.1 KiB
CMake
33 lines
1.1 KiB
CMake
function(TEST variable)
|
|
if(ARGC GREATER 2)
|
|
set(i 0)
|
|
foreach(value IN LISTS ${variable})
|
|
math(EXPR j "${i} + 1")
|
|
set(${variable}[${i}] "${value}")
|
|
TEST(${variable}[${i}] "${ARGV${j}}")
|
|
set(i ${j})
|
|
endforeach()
|
|
else()
|
|
set(expected "${ARGN}")
|
|
if("${expected}" STREQUAL "UNDEFINED")
|
|
if(DEFINED ${variable})
|
|
message(FATAL_ERROR "'${variable}' shall be undefined but has value '${${variable}}'")
|
|
endif()
|
|
elseif(NOT DEFINED ${variable})
|
|
message(FATAL_ERROR "'${variable}' should be defined but is not")
|
|
elseif("${expected}" STREQUAL "FALSE")
|
|
if(NOT ${variable} STREQUAL "FALSE")
|
|
message(FATAL_ERROR "'${variable}' shall be FALSE")
|
|
endif()
|
|
elseif("${expected}" STREQUAL "TRUE")
|
|
if(NOT ${variable} STREQUAL "TRUE")
|
|
message(FATAL_ERROR "'${variable}' shall be TRUE")
|
|
endif()
|
|
else()
|
|
if(NOT ${variable} STREQUAL "${expected}")
|
|
message(FATAL_ERROR "'${variable}' shall be '${expected}' but has value '${${variable}}'")
|
|
endif()
|
|
endif()
|
|
endif()
|
|
endfunction()
|