diff options
author | Brad King <brad.king@kitware.com> | 2015-11-24 14:26:37 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-11-24 14:26:37 (GMT) |
commit | db7457452cfbf6734d0ff6e3ba8700e9df46c2ae (patch) | |
tree | abafe6a68b36f93b822d1281cef3a37e86fae802 /Tests | |
parent | 7c74de8de8be5a03a572f476bedc9d4c5ca6c0a0 (diff) | |
parent | 010c5959864a10f4b83907fb058006e118dd740d (diff) | |
download | CMake-db7457452cfbf6734d0ff6e3ba8700e9df46c2ae.zip CMake-db7457452cfbf6734d0ff6e3ba8700e9df46c2ae.tar.gz CMake-db7457452cfbf6734d0ff6e3ba8700e9df46c2ae.tar.bz2 |
Merge topic 'test-add_subdirectory-in-function'
010c5959 Tests: Add case for add_subdirectory inside a function
Diffstat (limited to 'Tests')
4 files changed, 33 insertions, 0 deletions
diff --git a/Tests/RunCMake/add_subdirectory/Function-stdout.txt b/Tests/RunCMake/add_subdirectory/Function-stdout.txt new file mode 100644 index 0000000..16fa857 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Function-stdout.txt @@ -0,0 +1,10 @@ +-- var='1' before my_add_subdirectory +-- var='2' in my_add_subdirectory before add_subdirectory +-- var='2' in subdirectory before set +-- var='3' in subdirectory after set +-- var_sub='' in subdirectory after set PARENT_SCOPE +-- var='2' in my_add_subdirectory after add_subdirectory +-- var_sub='sub' in my_add_subdirectory after add_subdirectory +-- var='1' after my_add_subdirectory +-- var_sub='' after my_add_subdirectory +-- var='3' taken from subdirectory diff --git a/Tests/RunCMake/add_subdirectory/Function.cmake b/Tests/RunCMake/add_subdirectory/Function.cmake new file mode 100644 index 0000000..e804da9 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Function.cmake @@ -0,0 +1,17 @@ +function(my_add_subdirectory dir) + set(var 2) + message(STATUS "var='${var}' in my_add_subdirectory before add_subdirectory") + add_subdirectory(${dir}) + message(STATUS "var='${var}' in my_add_subdirectory after add_subdirectory") + message(STATUS "var_sub='${var_sub}' in my_add_subdirectory after add_subdirectory") +endfunction() + +set(var 1) + +message(STATUS "var='${var}' before my_add_subdirectory") +my_add_subdirectory(Function) +message(STATUS "var='${var}' after my_add_subdirectory") +message(STATUS "var_sub='${var_sub}' after my_add_subdirectory") + +get_directory_property(sub_var DIRECTORY Function DEFINITION var) +message(STATUS "var='${sub_var}' taken from subdirectory") diff --git a/Tests/RunCMake/add_subdirectory/Function/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/Function/CMakeLists.txt new file mode 100644 index 0000000..7b9e801 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/Function/CMakeLists.txt @@ -0,0 +1,5 @@ +message(STATUS "var='${var}' in subdirectory before set") +set(var 3) +message(STATUS "var='${var}' in subdirectory after set") +set(var_sub sub PARENT_SCOPE) +message(STATUS "var_sub='${var_sub}' in subdirectory after set PARENT_SCOPE") diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index a3ddec8..9d514e1 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(DoesNotExist) run_cmake(Missing) +run_cmake(Function) |