diff options
author | Brad King <brad.king@kitware.com> | 2015-06-23 14:56:47 -0400 |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2015-06-25 09:14:26 -0400 |
commit | 30c2e1dd16e061fbabffa35816cb893d81ff0dcf (patch) | |
tree | e4409727504fc359fe48c8509601fc124277e371 /Tests | |
parent | a6916a6c6e397bda8b381f65dbfc59d3c52f8525 (diff) | |
download | cmake-30c2e1dd16e061fbabffa35816cb893d81ff0dcf.tar.gz |
cmTarget: Fix diagnostic of target_link_libraries in wrong directory (#15626)
Since commit v3.3.0-rc1~62^2~5 (cmTarget: Store only cmListFileContext
for CMP0023 handling, 2015-05-18) a call to target_link_libraries on a
target that was defined in another (non-ancestor) directory crashes
because no execution context is left active. Fix this by getting the
execution context from the actual cmMakefile where the current
target_link_libraries call takes place. Test this by verifying that
such calls correctly produce an error diagnostic instead of crashing.
Diffstat (limited to 'Tests')
6 files changed, 11 insertions, 0 deletions
diff --git a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake index f97022e1b4..533c6a15eb 100644 --- a/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake +++ b/Tests/RunCMake/target_link_libraries/RunCMakeTest.cmake @@ -6,3 +6,4 @@ run_cmake(CMP0023-WARN-2) run_cmake(CMP0023-NEW-2) run_cmake(MixedSignature) run_cmake(Separate-PRIVATE-LINK_PRIVATE-uses) +run_cmake(SubDirTarget) diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt new file mode 100644 index 0000000000..d00491fd7e --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt new file mode 100644 index 0000000000..5cd1f23d7b --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget-stderr.txt @@ -0,0 +1,5 @@ +^CMake Error at SubDirTarget.cmake:[0-9]+ \(target_link_libraries\): + Attempt to add link library "m" to target "subexe" which is not built in + this directory. +Call Stack \(most recent call first\): + CMakeLists.txt:[0-9]+ \(include\)$ diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake b/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake new file mode 100644 index 0000000000..32431cecc0 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget.cmake @@ -0,0 +1,3 @@ +enable_language(C) +add_subdirectory(SubDirTarget) +target_link_libraries(subexe m) diff --git a/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt b/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt new file mode 100644 index 0000000000..b0b23809a6 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/SubDirTarget/CMakeLists.txt @@ -0,0 +1 @@ +add_executable(subexe ../empty.c) diff --git a/Tests/RunCMake/target_link_libraries/empty.c b/Tests/RunCMake/target_link_libraries/empty.c new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/Tests/RunCMake/target_link_libraries/empty.c |