diff options
author | Stephen Kelly <steveire@gmail.com> | 2013-02-08 18:12:45 (GMT) |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2013-02-08 18:21:30 (GMT) |
commit | 510fdcb18801076e2041eaae2941375eecc93ec2 (patch) | |
tree | 97cb7b62dc605e8cc8f46cf092ba75911e0a6e6c | |
parent | 4de71786e89ba35190e23ae9e1c05f902c5350ff (diff) | |
download | CMake-510fdcb18801076e2041eaae2941375eecc93ec2.zip CMake-510fdcb18801076e2041eaae2941375eecc93ec2.tar.gz CMake-510fdcb18801076e2041eaae2941375eecc93ec2.tar.bz2 |
Whitelist target types in target_{include_directories,compile_definitions}
Setting include directories or compile definitions on a target created
with add_custom_target does not make sense.
6 files changed, 22 insertions, 1 deletions
diff --git a/Source/cmTargetPropCommandBase.cxx b/Source/cmTargetPropCommandBase.cxx index 18a1d2a..771097c 100644 --- a/Source/cmTargetPropCommandBase.cxx +++ b/Source/cmTargetPropCommandBase.cxx @@ -38,6 +38,15 @@ bool cmTargetPropCommandBase this->HandleMissingTarget(args[0]); return false; } + if ((this->Target->GetType() != cmTarget::SHARED_LIBRARY) + && (this->Target->GetType() != cmTarget::STATIC_LIBRARY) + && (this->Target->GetType() != cmTarget::OBJECT_LIBRARY) + && (this->Target->GetType() != cmTarget::MODULE_LIBRARY) + && (this->Target->GetType() != cmTarget::EXECUTABLE)) + { + this->SetError("called with non-compilable target type"); + return false; + } unsigned int argIndex = 1; diff --git a/Tests/ObjectLibrary/A/CMakeLists.txt b/Tests/ObjectLibrary/A/CMakeLists.txt index 36c86e7..55778ea 100644 --- a/Tests/ObjectLibrary/A/CMakeLists.txt +++ b/Tests/ObjectLibrary/A/CMakeLists.txt @@ -13,6 +13,6 @@ add_custom_command( COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_CURRENT_SOURCE_DIR}/a1.c.in ${CMAKE_CURRENT_BINARY_DIR}/a1.c ) -include_directories(${CMAKE_CURRENT_SOURCE_DIR}) add_library(A OBJECT a1.c a2.c) +target_include_directories(A PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/Tests/RunCMake/include_directories/RunCMakeTest.cmake b/Tests/RunCMake/include_directories/RunCMakeTest.cmake index de37252..ddf268c 100644 --- a/Tests/RunCMake/include_directories/RunCMakeTest.cmake +++ b/Tests/RunCMake/include_directories/RunCMakeTest.cmake @@ -2,3 +2,4 @@ include(RunCMake) run_cmake(NotFoundContent) run_cmake(DebugIncludes) +run_cmake(TID-bad-target) diff --git a/Tests/RunCMake/include_directories/TID-bad-target-result.txt b/Tests/RunCMake/include_directories/TID-bad-target-result.txt new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target-result.txt @@ -0,0 +1 @@ +1 diff --git a/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt b/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt new file mode 100644 index 0000000..481e358 --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target-stderr.txt @@ -0,0 +1,4 @@ +CMake Error at TID-bad-target.cmake:6 \(target_include_directories\): + target_include_directories called with non-compilable target type +Call Stack \(most recent call first\): + CMakeLists.txt:3 \(include\) diff --git a/Tests/RunCMake/include_directories/TID-bad-target.cmake b/Tests/RunCMake/include_directories/TID-bad-target.cmake new file mode 100644 index 0000000..32201c1 --- /dev/null +++ b/Tests/RunCMake/include_directories/TID-bad-target.cmake @@ -0,0 +1,6 @@ + +add_custom_target(check ALL + COMMAND ${CMAKE_COMMAND} -E echo check +) + +target_include_directories(check PRIVATE somedir) |