diff options
author | Brad King <brad.king@kitware.com> | 2020-10-27 11:09:25 (GMT) |
---|---|---|
committer | Kitware Robot <kwrobot@kitware.com> | 2020-10-27 11:10:24 (GMT) |
commit | ecab18bb7ccfc8e91f1465aec32f98afd1b2a4ef (patch) | |
tree | 2303389c7f3d678cdad0379fcb63480a646b2681 /Tests | |
parent | 80e2163f826a76134e34874e953979ee70f8b972 (diff) | |
parent | 1a3d125de8b06a57cde26f12426601f422e5c755 (diff) | |
download | CMake-ecab18bb7ccfc8e91f1465aec32f98afd1b2a4ef.zip CMake-ecab18bb7ccfc8e91f1465aec32f98afd1b2a4ef.tar.gz CMake-ecab18bb7ccfc8e91f1465aec32f98afd1b2a4ef.tar.bz2 |
Merge topic 'issue-21034'
1a3d125de8 target_sources: Support custom targets
Acked-by: Kitware Robot <kwrobot@kitware.com>
Merge-request: !5421
Diffstat (limited to 'Tests')
13 files changed, 47 insertions, 0 deletions
diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetCheckProperty.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetCheckProperty.cmake new file mode 100644 index 0000000..1787e87 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetCheckProperty.cmake @@ -0,0 +1,16 @@ +add_custom_target(target1 ALL) +target_sources(target1 PRIVATE main.cpp) +get_property(actualProp1 TARGET target1 PROPERTY SOURCES) +set(desiredProp1 main.cpp) +if(NOT desiredProp1 STREQUAL actualProp1) + message("source property not set. desired: \"${desiredProp1}\" actual: \"${actualProp1}\"") +endif() + +add_custom_target(target2 ALL SOURCES main.cpp) +target_sources(target2 PRIVATE empty_1.cpp empty_2.cpp) +target_sources(target2 PRIVATE empty_3.cpp) +get_property(actualProp2 TARGET target2 PROPERTY SOURCES) +set(desiredProp2 main.cpp empty_1.cpp empty_2.cpp empty_3.cpp) +if (NOT desiredProp2 STREQUAL actualProp2) + message("source property not set. desired: \"${desiredProp2}\" actual: \"${actualProp2}\"") +endif() diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetGenx.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetGenx.cmake new file mode 100644 index 0000000..0078eab --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetGenx.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PRIVATE $<IF:1,${CMAKE_CURRENT_LIST_DIR}/main.cpp,${CMAKE_CURRENT_LIST_DIR}/empty_1.cpp>) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-result.txt b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-stderr.txt b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-stderr.txt new file mode 100644 index 0000000..9334bf6 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetInterfaceSources.cmake:2 \(target_sources\): + target_sources may only set PRIVATE properties on custom targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources.cmake new file mode 100644 index 0000000..42a8ca2 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetInterfaceSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target INTERFACE main.cpp) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetPrivateSources.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetPrivateSources.cmake new file mode 100644 index 0000000..11f0258 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetPrivateSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PRIVATE main.cpp) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-result.txt b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-stderr.txt b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-stderr.txt new file mode 100644 index 0000000..afba4be --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetPublicSources.cmake:2 \(target_sources\): + target_sources may only set PRIVATE properties on custom targets +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources.cmake new file mode 100644 index 0000000..d9e82c0 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetPublicSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target PUBLIC main.cpp) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetSources-result.txt b/Tests/RunCMake/TargetSources/AddCustomTargetSources-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetSources-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetSources-stderr.txt b/Tests/RunCMake/TargetSources/AddCustomTargetSources-stderr.txt new file mode 100644 index 0000000..4a153e9 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetSources-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at AddCustomTargetSources.cmake:2 \(target_sources\): + target_sources called with invalid arguments +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/TargetSources/AddCustomTargetSources.cmake b/Tests/RunCMake/TargetSources/AddCustomTargetSources.cmake new file mode 100644 index 0000000..dd688d3 --- /dev/null +++ b/Tests/RunCMake/TargetSources/AddCustomTargetSources.cmake @@ -0,0 +1,2 @@ +add_custom_target(target ALL) +target_sources(target main.cpp) diff --git a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake index 0d462ba..b56ee44 100644 --- a/Tests/RunCMake/TargetSources/RunCMakeTest.cmake +++ b/Tests/RunCMake/TargetSources/RunCMakeTest.cmake @@ -14,3 +14,9 @@ run_cmake(RelativePathInSubdirInterface) run_cmake(RelativePathInSubdirPrivate) run_cmake(RelativePathInSubdirInclude) run_cmake(ExportBuild) +run_cmake(AddCustomTargetPublicSources) +run_cmake(AddCustomTargetPrivateSources) +run_cmake(AddCustomTargetInterfaceSources) +run_cmake(AddCustomTargetSources) +run_cmake(AddCustomTargetCheckProperty) +run_cmake(AddCustomTargetGenx) |