set: Add unit tests for set/unset PARENT_SCOPE

Create a RunCMake.set test to cover set() command cases, starting with
PARENT_SCOPE.
This commit is contained in:
Daniele E. Domenichelli 2013-11-13 09:18:18 +01:00 committed by Brad King
parent bc280f1c81
commit bf755c7c38
5 changed files with 41 additions and 0 deletions

View File

@ -107,6 +107,7 @@ add_RunCMake_test(list)
add_RunCMake_test(message) add_RunCMake_test(message)
add_RunCMake_test(string) add_RunCMake_test(string)
add_RunCMake_test(try_compile) add_RunCMake_test(try_compile)
add_RunCMake_test(set)
add_RunCMake_test(variable_watch) add_RunCMake_test(variable_watch)
add_RunCMake_test(CMP0004) add_RunCMake_test(CMP0004)
add_RunCMake_test(TargetPolicies) add_RunCMake_test(TargetPolicies)

View File

@ -0,0 +1,3 @@
cmake_minimum_required(VERSION 2.8.12)
project(${RunCMake_TEST} NONE)
include(${RunCMake_TEST}.cmake)

View File

@ -0,0 +1 @@
0

View File

@ -0,0 +1,33 @@
set(FOO )
set(BAR "bar")
set(BAZ "baz")
set(BOO "boo")
function(_parent_scope)
set(FOO "foo" PARENT_SCOPE)
set(BAR "" PARENT_SCOPE)
set(BAZ PARENT_SCOPE)
unset(BOO PARENT_SCOPE)
endfunction()
_parent_scope()
if(NOT DEFINED FOO)
message(FATAL_ERROR "FOO not defined")
elseif(NOT "${FOO}" STREQUAL "foo")
message(FATAL_ERROR "FOO should be \"foo\", not \"${FOO}\"")
endif()
if(NOT DEFINED BAR)
message(FATAL_ERROR "BAR not defined")
elseif(NOT "${BAR}" STREQUAL "")
message(FATAL_ERROR "BAR should be an empty string, not \"${BAR}\"")
endif()
if(DEFINED BAZ)
message(FATAL_ERROR "BAZ defined")
endif()
if(DEFINED BOO)
message(FATAL_ERROR "BOO defined")
endif()

View File

@ -0,0 +1,3 @@
include(RunCMake)
run_cmake(PARENT_SCOPE)