Merge topic 'fix-buildsystem-target-properties'

b9856862 Tests: Cover set_property for buildsystem target properties
407ff47e cmTarget: Fix memory leak when SOURCES property is cleared
cf74fc24 cmTarget: Fix buildsystem property empty value set and append operations
This commit is contained in:
Brad King 2015-09-08 10:24:38 -04:00 committed by CMake Topic Stage
commit 70ea1d91fa
17 changed files with 90 additions and 31 deletions

View File

@ -1601,33 +1601,45 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
{
this->Internal->IncludeDirectoriesEntries.clear();
this->Internal->IncludeDirectoriesBacktraces.clear();
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
if (value)
{
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_OPTIONS")
{
this->Internal->CompileOptionsEntries.clear();
this->Internal->CompileOptionsBacktraces.clear();
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileOptionsBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileOptionsBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_FEATURES")
{
this->Internal->CompileFeaturesEntries.clear();
this->Internal->CompileFeaturesBacktraces.clear();
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_DEFINITIONS")
{
this->Internal->CompileDefinitionsEntries.clear();
this->Internal->CompileDefinitionsBacktraces.clear();
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
}
}
else if(prop == "EXPORT_NAME" && this->IsImported())
{
@ -1659,6 +1671,7 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Internal->SourceFilesMap.clear();
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
cmGeneratorExpression ge(lfbt);
cmDeleteAll(this->Internal->SourceEntries);
this->Internal->SourceEntries.clear();
cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
this->Internal->SourceEntries.push_back(
@ -1693,27 +1706,39 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
}
else if(prop == "INCLUDE_DIRECTORIES")
{
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
if (value)
{
this->Internal->IncludeDirectoriesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->IncludeDirectoriesBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_OPTIONS")
{
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileOptionsBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileOptionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileOptionsBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_FEATURES")
{
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileFeaturesEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileFeaturesBacktraces.push_back(lfbt);
}
}
else if(prop == "COMPILE_DEFINITIONS")
{
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
if (value)
{
this->Internal->CompileDefinitionsEntries.push_back(value);
cmListFileBacktrace lfbt = this->Makefile->GetBacktrace();
this->Internal->CompileDefinitionsBacktraces.push_back(lfbt);
}
}
else if(prop == "EXPORT_NAME" && this->IsImported())
{

View File

@ -0,0 +1 @@
-- Target COMPILE_DEFINITIONS is 'a;;b;c;;d;;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(COMPILE_DEFINITIONS)

View File

@ -0,0 +1 @@
-- Target COMPILE_FEATURES is 'a;;b;c;;d;;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(COMPILE_FEATURES)

View File

@ -0,0 +1 @@
-- Target COMPILE_OPTIONS is 'a;;b;c;;d;;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(COMPILE_OPTIONS)

View File

@ -0,0 +1,14 @@
macro(test_target_property PROP)
add_custom_target(CustomTarget)
set_property(TARGET CustomTarget PROPERTY ${PROP} x)
set_property(TARGET CustomTarget PROPERTY ${PROP})
set_property(TARGET CustomTarget APPEND PROPERTY ${PROP})
set_property(TARGET CustomTarget PROPERTY ${PROP} a)
set_property(TARGET CustomTarget APPEND PROPERTY ${PROP} "")
set_property(TARGET CustomTarget APPEND PROPERTY ${PROP} b c)
set_property(TARGET CustomTarget APPEND PROPERTY ${PROP})
set_property(TARGET CustomTarget APPEND PROPERTY ${PROP} "d;;e")
get_property(val TARGET CustomTarget PROPERTY ${PROP})
message(STATUS "Target ${PROP} is '${val}'")
set_property(TARGET CustomTarget PROPERTY ${PROP})
endmacro()

View File

@ -0,0 +1 @@
-- Target INCLUDE_DIRECTORIES is 'a;;b;c;;d;;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(INCLUDE_DIRECTORIES)

View File

@ -0,0 +1 @@
-- Target LINK_LIBRARIES is 'a;;b;c;;d;;e'

View File

@ -1,7 +1,2 @@
add_custom_target(CustomTarget)
set_property(TARGET CustomTarget PROPERTY LINK_LIBRARIES)
set_property(TARGET CustomTarget APPEND PROPERTY LINK_LIBRARIES)
get_property(val TARGET CustomTarget PROPERTY LINK_LIBRARIES)
if (NOT "${val}" STREQUAL "")
message(FATAL_ERROR "LINK_LIBRARIES value is '${val}' but should be ''")
endif()
include(Common.cmake)
test_target_property(LINK_LIBRARIES)

View File

@ -1,3 +1,9 @@
include(RunCMake)
run_cmake(COMPILE_DEFINITIONS)
run_cmake(COMPILE_FEATURES)
run_cmake(COMPILE_OPTIONS)
run_cmake(INCLUDE_DIRECTORIES)
run_cmake(LINK_LIBRARIES)
run_cmake(SOURCES)
run_cmake(USER_PROP)

View File

@ -0,0 +1 @@
-- Target SOURCES is 'a;b;c;d;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(SOURCES)

View File

@ -0,0 +1 @@
-- Target USER_PROP is 'a;b;c;d;;e'

View File

@ -0,0 +1,2 @@
include(Common.cmake)
test_target_property(USER_PROP)