diff options
author | Brad King <brad.king@kitware.com> | 2009-09-16 13:52:04 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-09-16 13:52:04 (GMT) |
commit | 33207a9a87d53b7cb97e0b30bc36dccad3c50289 (patch) | |
tree | 4c338b3a7a05a9be853ead611250123f724ae751 /Tests/FunctionTest | |
parent | 24861459b59ea61dd920971bc8ddc9bbbd04242e (diff) | |
download | CMake-33207a9a87d53b7cb97e0b30bc36dccad3c50289.zip CMake-33207a9a87d53b7cb97e0b30bc36dccad3c50289.tar.gz CMake-33207a9a87d53b7cb97e0b30bc36dccad3c50289.tar.bz2 |
Test add_subdirectory inside function
This commit teaches the FunctionTest to check variable scope behavior
when a subdirectory is added inside a function call. Any PARENT_SCOPE
sets in the subdirectory should affect only the function scope which
called add_subdirectory and not its parent scope.
Diffstat (limited to 'Tests/FunctionTest')
-rw-r--r-- | Tests/FunctionTest/CMakeLists.txt | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/Tests/FunctionTest/CMakeLists.txt b/Tests/FunctionTest/CMakeLists.txt index 2f62c27..ef55173 100644 --- a/Tests/FunctionTest/CMakeLists.txt +++ b/Tests/FunctionTest/CMakeLists.txt @@ -130,4 +130,39 @@ ELSE(DEFINED SUBDIR_DEFINED) FAILED("Subdir Define Test" "(${SUBDIR_DEFINED})") ENDIF(DEFINED SUBDIR_DEFINED) +# Test function-scoped directory. +FUNCTION(ADD_SUBDIR2 dir) + ADD_SUBDIRECTORY("${dir}" "${dir}2") + # The parent scope sets in the subdir should be visible here. + IF(DEFINED SUBDIR_UNDEFINED) + FAILED("Subdir Function Undefine Test 1" "(${SUBDIR_UNDEFINED})") + ELSE(DEFINED SUBDIR_UNDEFINED) + PASS("Subdir Function Undefine Test 1" "(${SUBDIR_UNDEFINED})") + ENDIF(DEFINED SUBDIR_UNDEFINED) + IF(DEFINED SUBDIR_DEFINED) + PASS("Subdir Function Define Test 1" "(${SUBDIR_DEFINED})") + ELSE(DEFINED SUBDIR_DEFINED) + FAILED("Subdir Function Define Test 1" "(${SUBDIR_DEFINED})") + ENDIF(DEFINED SUBDIR_DEFINED) +ENDFUNCTION(ADD_SUBDIR2) + +# Reset test variables. +SET(SUBDIR_UNDEFINED 1) +SET(SUBDIR_DEFINED) + +# Run test function. +ADD_SUBDIR2(SubDirScope) + +# The parent scope sets in the subdir should not be visible here. +IF(DEFINED SUBDIR_UNDEFINED) + PASS("Subdir Function Undefine Test 2" "(${SUBDIR_UNDEFINED})") +ELSE(DEFINED SUBDIR_UNDEFINED) + FAILED("Subdir Function Undefine Test 2" "(${SUBDIR_UNDEFINED})") +ENDIF(DEFINED SUBDIR_UNDEFINED) +IF(DEFINED SUBDIR_DEFINED) + FAILED("Subdir Function Define Test 2" "(${SUBDIR_DEFINED})") +ELSE(DEFINED SUBDIR_DEFINED) + PASS("Subdir Function Define Test 2" "(${SUBDIR_DEFINED})") +ENDIF(DEFINED SUBDIR_DEFINED) + ADD_EXECUTABLE(FunctionTest functionTest.c) |