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().
This commit is contained in:
Stephen Kelly 2013-12-26 14:11:23 +01:00
parent 03d842a982
commit 272a20f8e5
5 changed files with 47 additions and 24 deletions

View File

@ -4045,8 +4045,8 @@ cmMakefile::AddImportedTarget(const char* name, cmTarget::TargetType type,
// Create the target.
cmsys::auto_ptr<cmTarget> 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();

View File

@ -330,6 +330,8 @@ void cmTarget::SetMakefile(cmMakefile* mf)
// Save the backtrace of target construction.
this->Makefile->GetBacktrace(this->Internal->Backtrace);
if (!this->IsImported())
{
// Initialize the INCLUDE_DIRECTORIES property based on the current value
// of the same directory property:
const std::vector<cmValueWithOrigin> parentIncludes =
@ -340,7 +342,6 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
this->InsertInclude(*it);
}
const std::set<cmStdString> parentSystemIncludes =
this->Makefile->GetSystemIncludeDirectories();
@ -359,6 +360,7 @@ void cmTarget::SetMakefile(cmMakefile* mf)
{
this->InsertCompileOption(*it);
}
}
if (this->GetType() != INTERFACE_LIBRARY)
{

View File

@ -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()

View File

@ -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()

View File

@ -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()