1
0
mirror of https://github.com/Kitware/CMake.git synced 2025-10-14 02:08:27 +08:00

set: Add test cases for setting ENV{VAR} to empty

The behavior differs by platform and if the variable is already set.
Encode existing behavior in tests to preserve it until intentionally
changed.

Issue: #27285
This commit is contained in:
Brad King
2025-10-06 20:08:34 -04:00
parent a878d1c490
commit 20761cf349
4 changed files with 22 additions and 0 deletions

View File

@@ -0,0 +1,2 @@
^-- ENV{UNSET_THEN_EMPTY} is not defined
-- ENV{SET_THEN_EMPTY} is not defined$

View File

@@ -0,0 +1,2 @@
^-- ENV{UNSET_THEN_EMPTY} is not defined
-- ENV{SET_THEN_EMPTY} is defined to ''$

View File

@@ -0,0 +1,15 @@
unset(ENV{UNSET_THEN_EMPTY})
set(ENV{UNSET_THEN_EMPTY} "")
if(DEFINED ENV{UNSET_THEN_EMPTY})
message(STATUS "ENV{UNSET_THEN_EMPTY} is defined to '$ENV{UNSET_THEN_EMPTY}'")
else()
message(STATUS "ENV{UNSET_THEN_EMPTY} is not defined")
endif()
set(ENV{SET_THEN_EMPTY} "set")
set(ENV{SET_THEN_EMPTY} "")
if(DEFINED ENV{SET_THEN_EMPTY})
message(STATUS "ENV{SET_THEN_EMPTY} is defined to '$ENV{SET_THEN_EMPTY}'")
else()
message(STATUS "ENV{SET_THEN_EMPTY} is not defined")
endif()

View File

@@ -12,3 +12,6 @@ run_cmake(CacheUnknownArguments)
run_cmake(CacheMissingArguments)
run_cmake(CacheWrongTYPE)
run_cmake(CacheSetUnset)
# set(ENV{}) syntax
run_cmake_script(Env)