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.
This commit is contained in:
parent
24861459b5
commit
33207a9a87
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue