summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2015-09-08 14:24:38 (GMT)
committerCMake Topic Stage <kwrobot@kitware.com>2015-09-08 14:24:38 (GMT)
commit70ea1d91fad093e9ed8939a309688eef2458d697 (patch)
treebc6c6cbd13a4d6a8f44881d8f466d44ed1903947
parent4da3315db365f3c80ce5202047955f0f2ec9312f (diff)
parentb9856862fe46b04b25d99c3488899d6b12bd6e1a (diff)
downloadCMake-70ea1d91fad093e9ed8939a309688eef2458d697.zip
CMake-70ea1d91fad093e9ed8939a309688eef2458d697.tar.gz
CMake-70ea1d91fad093e9ed8939a309688eef2458d697.tar.bz2
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
-rw-r--r--Source/cmTarget.cxx73
-rw-r--r--Tests/RunCMake/set_property/COMPILE_DEFINITIONS-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/COMPILE_DEFINITIONS.cmake2
-rw-r--r--Tests/RunCMake/set_property/COMPILE_FEATURES-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/COMPILE_FEATURES.cmake2
-rw-r--r--Tests/RunCMake/set_property/COMPILE_OPTIONS-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/COMPILE_OPTIONS.cmake2
-rw-r--r--Tests/RunCMake/set_property/Common.cmake14
-rw-r--r--Tests/RunCMake/set_property/INCLUDE_DIRECTORIES-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/INCLUDE_DIRECTORIES.cmake2
-rw-r--r--Tests/RunCMake/set_property/LINK_LIBRARIES-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/LINK_LIBRARIES.cmake9
-rw-r--r--Tests/RunCMake/set_property/RunCMakeTest.cmake6
-rw-r--r--Tests/RunCMake/set_property/SOURCES-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/SOURCES.cmake2
-rw-r--r--Tests/RunCMake/set_property/USER_PROP-stdout.txt1
-rw-r--r--Tests/RunCMake/set_property/USER_PROP.cmake2
17 files changed, 90 insertions, 31 deletions
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 590654d..3425f34 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -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())
{
diff --git a/Tests/RunCMake/set_property/COMPILE_DEFINITIONS-stdout.txt b/Tests/RunCMake/set_property/COMPILE_DEFINITIONS-stdout.txt
new file mode 100644
index 0000000..b85f41d
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_DEFINITIONS-stdout.txt
@@ -0,0 +1 @@
+-- Target COMPILE_DEFINITIONS is 'a;;b;c;;d;;e'
diff --git a/Tests/RunCMake/set_property/COMPILE_DEFINITIONS.cmake b/Tests/RunCMake/set_property/COMPILE_DEFINITIONS.cmake
new file mode 100644
index 0000000..ec07ce9
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_DEFINITIONS.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(COMPILE_DEFINITIONS)
diff --git a/Tests/RunCMake/set_property/COMPILE_FEATURES-stdout.txt b/Tests/RunCMake/set_property/COMPILE_FEATURES-stdout.txt
new file mode 100644
index 0000000..81ef170
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_FEATURES-stdout.txt
@@ -0,0 +1 @@
+-- Target COMPILE_FEATURES is 'a;;b;c;;d;;e'
diff --git a/Tests/RunCMake/set_property/COMPILE_FEATURES.cmake b/Tests/RunCMake/set_property/COMPILE_FEATURES.cmake
new file mode 100644
index 0000000..1ab52ef
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_FEATURES.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(COMPILE_FEATURES)
diff --git a/Tests/RunCMake/set_property/COMPILE_OPTIONS-stdout.txt b/Tests/RunCMake/set_property/COMPILE_OPTIONS-stdout.txt
new file mode 100644
index 0000000..f18451a
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_OPTIONS-stdout.txt
@@ -0,0 +1 @@
+-- Target COMPILE_OPTIONS is 'a;;b;c;;d;;e'
diff --git a/Tests/RunCMake/set_property/COMPILE_OPTIONS.cmake b/Tests/RunCMake/set_property/COMPILE_OPTIONS.cmake
new file mode 100644
index 0000000..da20ec8
--- /dev/null
+++ b/Tests/RunCMake/set_property/COMPILE_OPTIONS.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(COMPILE_OPTIONS)
diff --git a/Tests/RunCMake/set_property/Common.cmake b/Tests/RunCMake/set_property/Common.cmake
new file mode 100644
index 0000000..b359487
--- /dev/null
+++ b/Tests/RunCMake/set_property/Common.cmake
@@ -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()
diff --git a/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES-stdout.txt b/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES-stdout.txt
new file mode 100644
index 0000000..f9970ce
--- /dev/null
+++ b/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES-stdout.txt
@@ -0,0 +1 @@
+-- Target INCLUDE_DIRECTORIES is 'a;;b;c;;d;;e'
diff --git a/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES.cmake b/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES.cmake
new file mode 100644
index 0000000..8f44aee
--- /dev/null
+++ b/Tests/RunCMake/set_property/INCLUDE_DIRECTORIES.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(INCLUDE_DIRECTORIES)
diff --git a/Tests/RunCMake/set_property/LINK_LIBRARIES-stdout.txt b/Tests/RunCMake/set_property/LINK_LIBRARIES-stdout.txt
new file mode 100644
index 0000000..1f7663b
--- /dev/null
+++ b/Tests/RunCMake/set_property/LINK_LIBRARIES-stdout.txt
@@ -0,0 +1 @@
+-- Target LINK_LIBRARIES is 'a;;b;c;;d;;e'
diff --git a/Tests/RunCMake/set_property/LINK_LIBRARIES.cmake b/Tests/RunCMake/set_property/LINK_LIBRARIES.cmake
index 994e874..5155f59 100644
--- a/Tests/RunCMake/set_property/LINK_LIBRARIES.cmake
+++ b/Tests/RunCMake/set_property/LINK_LIBRARIES.cmake
@@ -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)
diff --git a/Tests/RunCMake/set_property/RunCMakeTest.cmake b/Tests/RunCMake/set_property/RunCMakeTest.cmake
index 54e63f7..37c7124 100644
--- a/Tests/RunCMake/set_property/RunCMakeTest.cmake
+++ b/Tests/RunCMake/set_property/RunCMakeTest.cmake
@@ -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)
diff --git a/Tests/RunCMake/set_property/SOURCES-stdout.txt b/Tests/RunCMake/set_property/SOURCES-stdout.txt
new file mode 100644
index 0000000..921d5b1
--- /dev/null
+++ b/Tests/RunCMake/set_property/SOURCES-stdout.txt
@@ -0,0 +1 @@
+-- Target SOURCES is 'a;b;c;d;e'
diff --git a/Tests/RunCMake/set_property/SOURCES.cmake b/Tests/RunCMake/set_property/SOURCES.cmake
new file mode 100644
index 0000000..820641e
--- /dev/null
+++ b/Tests/RunCMake/set_property/SOURCES.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(SOURCES)
diff --git a/Tests/RunCMake/set_property/USER_PROP-stdout.txt b/Tests/RunCMake/set_property/USER_PROP-stdout.txt
new file mode 100644
index 0000000..eaf6e37
--- /dev/null
+++ b/Tests/RunCMake/set_property/USER_PROP-stdout.txt
@@ -0,0 +1 @@
+-- Target USER_PROP is 'a;b;c;d;;e'
diff --git a/Tests/RunCMake/set_property/USER_PROP.cmake b/Tests/RunCMake/set_property/USER_PROP.cmake
new file mode 100644
index 0000000..e1f88e1
--- /dev/null
+++ b/Tests/RunCMake/set_property/USER_PROP.cmake
@@ -0,0 +1,2 @@
+include(Common.cmake)
+test_target_property(USER_PROP)