mirror of
https://github.com/reactos/CMake.git
synced 2024-12-25 04:56:06 +00:00
9db3116226
Ancient versions of CMake required else(), endif(), and similar block termination commands to have arguments matching the command starting the block. This is no longer the preferred style. Run the following shell code: for c in else endif endforeach endfunction endmacro endwhile; do echo 's/\b'"$c"'\(\s*\)(.\+)/'"$c"'\1()/' done >convert.sed && git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' '*CMakeLists.txt' | egrep -z -v '^(Utilities/cm|Source/kwsys/)' | egrep -z -v 'Tests/CMakeTests/While-Endwhile-' | xargs -0 sed -i -f convert.sed && rm convert.sed
56 lines
1.2 KiB
CMake
56 lines
1.2 KiB
CMake
cmake_minimum_required(VERSION 2.6)
|
|
project(Unset C)
|
|
|
|
# Local variable
|
|
set(x 42)
|
|
if(NOT x EQUAL 42)
|
|
message(FATAL_ERROR "x!=42")
|
|
endif()
|
|
|
|
if(NOT DEFINED x)
|
|
message(FATAL_ERROR "x should be defined!")
|
|
endif()
|
|
|
|
unset(x)
|
|
if(DEFINED x)
|
|
message(FATAL_ERROR "x should be undefined now!")
|
|
endif()
|
|
|
|
# Local variable test unset via set()
|
|
set(x 43)
|
|
if(NOT x EQUAL 43)
|
|
message(FATAL_ERROR "x!=43")
|
|
endif()
|
|
set(x)
|
|
if(DEFINED x)
|
|
message(FATAL_ERROR "x should be undefined now!")
|
|
endif()
|
|
|
|
# Cache variable
|
|
set(BAR "test" CACHE STRING "documentation")
|
|
if(NOT DEFINED BAR)
|
|
message(FATAL_ERROR "BAR not defined")
|
|
endif()
|
|
|
|
# Test interaction of cache entries with variables.
|
|
set(BAR "test-var")
|
|
if(NOT "$CACHE{BAR}" STREQUAL "test")
|
|
message(FATAL_ERROR "\$CACHE{BAR} changed by variable BAR")
|
|
endif()
|
|
if(NOT "${BAR}" STREQUAL "test-var")
|
|
message(FATAL_ERROR "\${BAR} not separate from \$CACHE{BAR}")
|
|
endif()
|
|
unset(BAR)
|
|
if(NOT "${BAR}" STREQUAL "test")
|
|
message(FATAL_ERROR "\${BAR} does not fall through to \$CACHE{BAR}")
|
|
endif()
|
|
|
|
# Test unsetting of CACHE entry.
|
|
unset(BAR CACHE)
|
|
if(DEFINED BAR)
|
|
message(FATAL_ERROR "BAR still defined")
|
|
endif()
|
|
|
|
|
|
add_executable(Unset unset.c)
|