diff options
author | Brad King <brad.king@kitware.com> | 2016-01-28 15:12:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2016-01-28 15:33:26 (GMT) |
commit | d257d68138a00758910bbca3dd77dcfcc04e65cc (patch) | |
tree | 9c0eff84d7fc1268f7f57f656a3f6e7b835b78d2 /Tests/RunCMake/add_custom_command | |
parent | 4d53e0a75e3ccddf14f556e88302573f14aa8830 (diff) | |
download | CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.zip CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.tar.gz CMake-d257d68138a00758910bbca3dd77dcfcc04e65cc.tar.bz2 |
add_custom_command: Clarify error when TARGET is out of scope (#15681)
The add_custom_command(TARGET) signature only works for targets defined
in the current directory. Clarify this in the error message when the
target exists but was defined elsewhere.
Inspired-by: Bartosz Kosiorek <gang65@poczta.onet.pl>
Diffstat (limited to 'Tests/RunCMake/add_custom_command')
8 files changed, 17 insertions, 0 deletions
diff --git a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake index 2f5c938..397c63d 100644 --- a/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake +++ b/Tests/RunCMake/add_custom_command/RunCMakeTest.cmake @@ -8,3 +8,5 @@ run_cmake(NoOutputOrTarget) run_cmake(OutputAndTarget) run_cmake(SourceByproducts) run_cmake(SourceUsesTerminal) +run_cmake(TargetImported) +run_cmake(TargetNotInDir) diff --git a/Tests/RunCMake/add_custom_command/TargetImported-result.txt b/Tests/RunCMake/add_custom_command/TargetImported-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetImported-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt b/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt new file mode 100644 index 0000000..44c4ad8 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetImported-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TargetImported.cmake:2 \(add_custom_command\): + TARGET 'TargetImported' is IMPORTED and does not build here. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_custom_command/TargetImported.cmake b/Tests/RunCMake/add_custom_command/TargetImported.cmake new file mode 100644 index 0000000..c0f2d66 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetImported.cmake @@ -0,0 +1,2 @@ +add_library(TargetImported UNKNOWN IMPORTED) +add_custom_command(TARGET TargetImported COMMAND ${CMAKE_COMMAND} -E echo tada) diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetNotInDir-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt new file mode 100644 index 0000000..91876a0 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetNotInDir-stderr.txt @@ -0,0 +1,4 @@ +^CMake Error at TargetNotInDir.cmake:2 \(add_custom_command\): + TARGET 'TargetNotInDir' was not created in this directory. +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\)$ diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake b/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake new file mode 100644 index 0000000..a551026 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetNotInDir.cmake @@ -0,0 +1,2 @@ +add_subdirectory(TargetNotInDir) +add_custom_command(TARGET TargetNotInDir COMMAND ${CMAKE_COMMAND} -E echo tada) diff --git a/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt b/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt new file mode 100644 index 0000000..3d51d27 --- /dev/null +++ b/Tests/RunCMake/add_custom_command/TargetNotInDir/CMakeLists.txt @@ -0,0 +1 @@ +add_custom_target(TargetNotInDir) |