summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Kelly <steveire@gmail.com>2013-07-08 18:18:42 (GMT)
committerStephen Kelly <steveire@gmail.com>2014-04-02 21:14:02 (GMT)
commit81ad69e056d6c6dd2360e3345f6d99f268ee9e54 (patch)
tree3787019041ef423a2d62be2ca7a85599ee193712
parent6e636f2ebaf78141f4d0a36c96804b9a1bc89857 (diff)
downloadCMake-81ad69e056d6c6dd2360e3345f6d99f268ee9e54.zip
CMake-81ad69e056d6c6dd2360e3345f6d99f268ee9e54.tar.gz
CMake-81ad69e056d6c6dd2360e3345f6d99f268ee9e54.tar.bz2
Make the SOURCES target property writable.
-rw-r--r--Help/prop_tgt/SOURCES.rst3
-rw-r--r--Help/release/dev/target-SOURCES-write.rst6
-rw-r--r--Source/cmTarget.cxx38
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug-stderr.txt8
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebug.cmake4
-rw-r--r--Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt9
-rw-r--r--Tests/RunCMake/TargetSources/empty_3.cpp7
-rw-r--r--Tests/SourcesProperty/CMakeLists.txt2
-rw-r--r--Tests/SourcesProperty/iface.h2
-rw-r--r--Tests/SourcesProperty/main.cpp2
-rw-r--r--Tests/SourcesProperty/prop.cpp5
11 files changed, 83 insertions, 3 deletions
diff --git a/Help/prop_tgt/SOURCES.rst b/Help/prop_tgt/SOURCES.rst
index 833b65a..493643e 100644
--- a/Help/prop_tgt/SOURCES.rst
+++ b/Help/prop_tgt/SOURCES.rst
@@ -3,5 +3,4 @@ SOURCES
Source names specified for a target.
-Read-only list of sources specified for a target. The names returned
-are suitable for passing to the set_source_files_properties command.
+List of sources specified for a target.
diff --git a/Help/release/dev/target-SOURCES-write.rst b/Help/release/dev/target-SOURCES-write.rst
new file mode 100644
index 0000000..a754a73
--- /dev/null
+++ b/Help/release/dev/target-SOURCES-write.rst
@@ -0,0 +1,6 @@
+target-SOURCES-write.rst
+------------------------
+
+* It is now possible to write and append to the :prop_tgt:`SOURCES` target
+ property. The :variable:`CMAKE_DEBUG_TARGET_PROPERTIES` variable may be
+ used to trace the origin of sources.
diff --git a/Source/cmTarget.cxx b/Source/cmTarget.cxx
index 10ecbfa..475bcdb 100644
--- a/Source/cmTarget.cxx
+++ b/Source/cmTarget.cxx
@@ -1697,6 +1697,25 @@ void cmTarget::SetProperty(const std::string& prop, const char* value)
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
+ if (prop == "SOURCES")
+ {
+ if(this->IsImported())
+ {
+ cmOStringStream e;
+ e << "SOURCES property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ this->Internal->SourceEntries.clear();
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
this->Properties.SetProperty(prop, value, cmProperty::TARGET);
this->MaybeInvalidatePropertyCache(prop);
}
@@ -1764,6 +1783,25 @@ void cmTarget::AppendProperty(const std::string& prop, const char* value,
this->Internal->LinkImplementationPropertyEntries.push_back(entry);
return;
}
+ if (prop == "SOURCES")
+ {
+ if(this->IsImported())
+ {
+ cmOStringStream e;
+ e << "SOURCES property can't be set on imported targets (\""
+ << this->Name << "\")\n";
+ this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
+ return;
+ }
+
+ cmListFileBacktrace lfbt;
+ this->Makefile->GetBacktrace(lfbt);
+ cmGeneratorExpression ge(lfbt);
+ cmsys::auto_ptr<cmCompiledGeneratorExpression> cge = ge.Parse(value);
+ this->Internal->SourceEntries.push_back(
+ new cmTargetInternals::TargetPropertyEntry(cge));
+ return;
+ }
this->Properties.AppendProperty(prop, value, cmProperty::TARGET, asString);
this->MaybeInvalidatePropertyCache(prop);
}
diff --git a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
index dad9fee..6b7453f 100644
--- a/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
+++ b/Tests/RunCMake/TargetSources/OriginDebug-stderr.txt
@@ -6,6 +6,14 @@ CMake Debug Log at OriginDebug.cmake:13 \(add_library\):
Call Stack \(most recent call first\):
CMakeLists.txt:3 \(include\)
+
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+ CMakeLists.txt:3 \(include\)
++
CMake Debug Log at OriginDebug.cmake:14 \(target_link_libraries\):
Used sources for target OriginDebug:
diff --git a/Tests/RunCMake/TargetSources/OriginDebug.cmake b/Tests/RunCMake/TargetSources/OriginDebug.cmake
index 911a7d4..3fa5858 100644
--- a/Tests/RunCMake/TargetSources/OriginDebug.cmake
+++ b/Tests/RunCMake/TargetSources/OriginDebug.cmake
@@ -12,3 +12,7 @@ set_property(TARGET iface PROPERTY INTERFACE_SOURCES
add_library(OriginDebug empty_2.cpp)
target_link_libraries(OriginDebug iface)
+
+set_property(TARGET OriginDebug APPEND PROPERTY SOURCES
+ empty_3.cpp
+)
diff --git a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
index 9797870..683c2e9 100644
--- a/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
+++ b/Tests/RunCMake/TargetSources/OriginDebugIDE-stderr.txt
@@ -7,6 +7,15 @@ Call Stack \(most recent call first\):
OriginDebugIDE.cmake:4 \(include\)
CMakeLists.txt:3 \(include\)
+
+CMake Debug Log at OriginDebug.cmake:16 \(set_property\):
+ Used sources for target OriginDebug:
+
+ \* .*Tests/RunCMake/TargetSources/empty_3.cpp
+
+Call Stack \(most recent call first\):
+ OriginDebugIDE.cmake:4 \(include\)
+ CMakeLists.txt:3 \(include\)
++
CMake Debug Log:
Used sources for target OriginDebug:
diff --git a/Tests/RunCMake/TargetSources/empty_3.cpp b/Tests/RunCMake/TargetSources/empty_3.cpp
new file mode 100644
index 0000000..bfbbdde
--- /dev/null
+++ b/Tests/RunCMake/TargetSources/empty_3.cpp
@@ -0,0 +1,7 @@
+#ifdef _WIN32
+__declspec(dllexport)
+#endif
+int empty()
+{
+ return 0;
+}
diff --git a/Tests/SourcesProperty/CMakeLists.txt b/Tests/SourcesProperty/CMakeLists.txt
index 0b3097e..6c99e00 100644
--- a/Tests/SourcesProperty/CMakeLists.txt
+++ b/Tests/SourcesProperty/CMakeLists.txt
@@ -8,3 +8,5 @@ set_property(TARGET iface PROPERTY INTERFACE_SOURCES iface.cpp)
add_executable(SourcesProperty main.cpp)
target_link_libraries(SourcesProperty iface)
+
+set_property(TARGET SourcesProperty APPEND PROPERTY SOURCES prop.cpp)
diff --git a/Tests/SourcesProperty/iface.h b/Tests/SourcesProperty/iface.h
index 2cac248..6da80a4 100644
--- a/Tests/SourcesProperty/iface.h
+++ b/Tests/SourcesProperty/iface.h
@@ -1,2 +1,4 @@
int iface();
+
+int prop();
diff --git a/Tests/SourcesProperty/main.cpp b/Tests/SourcesProperty/main.cpp
index ae4f305..33a97f4 100644
--- a/Tests/SourcesProperty/main.cpp
+++ b/Tests/SourcesProperty/main.cpp
@@ -3,5 +3,5 @@
int main(int argc, char** argv)
{
- return iface();
+ return iface() + prop();
}
diff --git a/Tests/SourcesProperty/prop.cpp b/Tests/SourcesProperty/prop.cpp
new file mode 100644
index 0000000..e343431
--- /dev/null
+++ b/Tests/SourcesProperty/prop.cpp
@@ -0,0 +1,5 @@
+
+int prop()
+{
+ return 0;
+}