diff options
author | Da Quexian <daquexian566@gmail.com> | 2022-06-22 12:18:06 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-09-26 14:56:54 (GMT) |
commit | 2eb30a7036214ec960f0666163ff44ef754f6afe (patch) | |
tree | 19f7bc19562409245f326da04371acbca8e9ea85 /Tests/RunCMake/add_subdirectory | |
parent | 80e4a155e0feddf1a02fb2701dff5ddbb427552a (diff) | |
download | CMake-2eb30a7036214ec960f0666163ff44ef754f6afe.zip CMake-2eb30a7036214ec960f0666163ff44ef754f6afe.tar.gz CMake-2eb30a7036214ec960f0666163ff44ef754f6afe.tar.bz2 |
add_subdirectory: Add SYSTEM option
Fixes: #22401
Signed-off-by: Da Quexian <daquexian566@gmail.com>
Diffstat (limited to 'Tests/RunCMake/add_subdirectory')
14 files changed, 46 insertions, 0 deletions
diff --git a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake index 951e03c..ddf45af 100644 --- a/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_subdirectory/RunCMakeTest.cmake @@ -3,6 +3,7 @@ include(RunCMake) run_cmake(DoesNotExist) run_cmake(Missing) run_cmake(Function) +run_cmake(System) macro(run_cmake_install case) set(RunCMake_TEST_BINARY_DIR ${RunCMake_BINARY_DIR}/${case}-build) diff --git a/Tests/RunCMake/add_subdirectory/System.cmake b/Tests/RunCMake/add_subdirectory/System.cmake new file mode 100644 index 0000000..45d7d9a --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System.cmake @@ -0,0 +1,22 @@ +enable_language(CXX) + +add_subdirectory(System SYSTEM) + +function(check_target_system target expected_value) + get_target_property(var ${target} SYSTEM) + if ((var AND NOT expected_value) OR (NOT var AND expected_value)) + message(SEND_ERROR "\ +The 'SYSTEM' property of ${target} should be ${expected_value}, \ +but got ${var}") + endif() +endfunction() + +check_target_system(foo OFF) +check_target_system(bar ON) +check_target_system(zot ON) +check_target_system(subsub1foo OFF) +check_target_system(subsub1bar ON) +check_target_system(subsub1zot ON) +check_target_system(subsub2foo OFF) +check_target_system(subsub2bar ON) +check_target_system(subsub2zot ON) diff --git a/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt new file mode 100644 index 0000000..ef74e80 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/CMakeLists.txt @@ -0,0 +1,11 @@ +project(SystemSub NONE) + +add_subdirectory(SubSub1 SYSTEM) +add_subdirectory(SubSub2) + +add_library(bar STATIC bar.cpp) + +add_library(foo STATIC foo.cpp) +set_target_properties(foo PROPERTIES SYSTEM OFF) + +add_executable(zot zot.cpp) diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt new file mode 100644 index 0000000..291339b --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(subsub1bar STATIC bar.cpp) + +add_library(subsub1foo STATIC foo.cpp) +set_target_properties(subsub1foo PROPERTIES SYSTEM OFF) + +add_executable(subsub1zot zot.cpp) diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/bar.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub1/bar.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/bar.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/foo.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub1/foo.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/foo.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub1/zot.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub1/zot.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub1/zot.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub2/CMakeLists.txt b/Tests/RunCMake/add_subdirectory/System/SubSub2/CMakeLists.txt new file mode 100644 index 0000000..5755742 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub2/CMakeLists.txt @@ -0,0 +1,6 @@ +add_library(subsub2bar STATIC bar.cpp) + +add_library(subsub2foo STATIC foo.cpp) +set_target_properties(subsub2foo PROPERTIES SYSTEM OFF) + +add_executable(subsub2zot zot.cpp) diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub2/bar.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub2/bar.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub2/bar.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub2/foo.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub2/foo.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub2/foo.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/SubSub2/zot.cpp b/Tests/RunCMake/add_subdirectory/System/SubSub2/zot.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/SubSub2/zot.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/bar.cpp b/Tests/RunCMake/add_subdirectory/System/bar.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/bar.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/foo.cpp b/Tests/RunCMake/add_subdirectory/System/foo.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/foo.cpp diff --git a/Tests/RunCMake/add_subdirectory/System/zot.cpp b/Tests/RunCMake/add_subdirectory/System/zot.cpp new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/Tests/RunCMake/add_subdirectory/System/zot.cpp |