From 272a20f8e554d7c4136119f252f163bcfc64dac0 Mon Sep 17 00:00:00 2001 From: Stephen Kelly Date: Thu, 26 Dec 2013 14:11:23 +0100 Subject: cmTarget: Don't update IMPORTED target compilation properties The include_directories() and add_compile_options() commands should not append to the corresponding target property for IMPORTED targets. This is already the case for add_definitions(). --- Source/cmMakefile.cxx | 2 +- Source/cmTarget.cxx | 48 +++++++++++----------- .../add_compile_options/CMakeLists.txt | 7 ++++ .../target_compile_definitions/CMakeLists.txt | 7 ++++ .../target_include_directories/CMakeLists.txt | 7 ++++ 5 files changed, 47 insertions(+), 24 deletions(-) diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 30a1557..6883f57 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -4045,8 +4045,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type, // Create the target. cmsys::auto_ptr target(new cmTarget); target->SetType(type, name); - target->SetMakefile(this); target->MarkAsImported(); + target->SetMakefile(this); // Add to the set of available imported targets. this->ImportedTargets[name] = target.get(); diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx index b3ad798..6019496 100644 --- a/Source/cmTarget.cxx +++ b/Source/cmTarget.cxx @@ -330,34 +330,36 @@ void cmTarget::SetMakefile(cmMakefile* mf) // Save the backtrace of target construction. this->Makefile->GetBacktrace(this->Internal->Backtrace); - // Initialize the INCLUDE_DIRECTORIES property based on the current value - // of the same directory property: - const std::vector parentIncludes = - this->Makefile->GetIncludeDirectoriesEntries(); - - for (std::vector::const_iterator it - = parentIncludes.begin(); it != parentIncludes.end(); ++it) + if (!this->IsImported()) { - this->InsertInclude(*it); - } + // Initialize the INCLUDE_DIRECTORIES property based on the current value + // of the same directory property: + const std::vector parentIncludes = + this->Makefile->GetIncludeDirectoriesEntries(); - const std::set parentSystemIncludes = - this->Makefile->GetSystemIncludeDirectories(); + for (std::vector::const_iterator it + = parentIncludes.begin(); it != parentIncludes.end(); ++it) + { + this->InsertInclude(*it); + } + const std::set parentSystemIncludes = + this->Makefile->GetSystemIncludeDirectories(); - for (std::set::const_iterator it - = parentSystemIncludes.begin(); - it != parentSystemIncludes.end(); ++it) - { - this->SystemIncludeDirectories.insert(*it); - } + for (std::set::const_iterator it + = parentSystemIncludes.begin(); + it != parentSystemIncludes.end(); ++it) + { + this->SystemIncludeDirectories.insert(*it); + } - const std::vector parentOptions = - this->Makefile->GetCompileOptionsEntries(); + const std::vector parentOptions = + this->Makefile->GetCompileOptionsEntries(); - for (std::vector::const_iterator it - = parentOptions.begin(); it != parentOptions.end(); ++it) - { - this->InsertCompileOption(*it); + for (std::vector::const_iterator it + = parentOptions.begin(); it != parentOptions.end(); ++it) + { + this->InsertCompileOption(*it); + } } if (this->GetType() != INTERFACE_LIBRARY) diff --git a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt index 1652cf6..995b32c 100644 --- a/Tests/CMakeCommands/add_compile_options/CMakeLists.txt +++ b/Tests/CMakeCommands/add_compile_options/CMakeLists.txt @@ -12,3 +12,10 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "GNU") "DO_GNU_TESTS" ) endif() + +add_compile_options(-rtti) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp COMPILE_OPTIONS) +if (_res) + message(SEND_ERROR "add_compile_options populated the COMPILE_OPTIONS target property") +endif() diff --git a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt index 900dbd0..14d40aa 100644 --- a/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt +++ b/Tests/CMakeCommands/target_compile_definitions/CMakeLists.txt @@ -25,3 +25,10 @@ target_compile_definitions(consumer target_compile_definitions(consumer PRIVATE ) + +add_definitions(-DSOME_DEF) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp COMPILE_DEFINITIONS) +if (_res) + message(SEND_ERROR "add_definitions populated the COMPILE_DEFINITIONS target property") +endif() diff --git a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt index 8a564c7..661bbaa 100644 --- a/Tests/CMakeCommands/target_include_directories/CMakeLists.txt +++ b/Tests/CMakeCommands/target_include_directories/CMakeLists.txt @@ -62,3 +62,10 @@ target_include_directories(consumer target_include_directories(consumer SYSTEM PRIVATE ) + +include_directories(${CMAKE_CURRENT_BINARY_DIR}) +add_library(imp UNKNOWN IMPORTED) +get_target_property(_res imp INCLUDE_DIRECTORIES) +if (_res) + message(SEND_ERROR "include_directories populated the INCLUDE_DIRECTORIES target property") +endif() -- cgit v0.12