summaryrefslogtreecommitdiffstats
path: root/Source/cmSourceFile.cxx
diff options
context:
space:
mode:
authorJustin Goshi <jgoshi@microsoft.com>2019-09-23 18:21:07 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-26 14:56:52 (GMT)
commitc71ac889ba6565c2a2aa31a403e3ab999abb5570 (patch)
tree65891876434523d5000f1bf53741d240579d09e7 /Source/cmSourceFile.cxx
parentb4087a23538f87efebcc8e4ece248416c242167f (diff)
downloadCMake-c71ac889ba6565c2a2aa31a403e3ab999abb5570.zip
CMake-c71ac889ba6565c2a2aa31a403e3ab999abb5570.tar.gz
CMake-c71ac889ba6565c2a2aa31a403e3ab999abb5570.tar.bz2
cmSourceFile: Add backtraces for a few source properties
Adding backtrace support for INCLUDE_DIRECTORIES, COMPILE_OPTIONS, and COMPILE_DEFINITIONS.
Diffstat (limited to 'Source/cmSourceFile.cxx')
-rw-r--r--Source/cmSourceFile.cxx78
1 files changed, 76 insertions, 2 deletions
diff --git a/Source/cmSourceFile.cxx b/Source/cmSourceFile.cxx
index bd68d04..2a345eb 100644
--- a/Source/cmSourceFile.cxx
+++ b/Source/cmSourceFile.cxx
@@ -6,6 +6,7 @@
#include <utility>
#include "cmGlobalGenerator.h"
+#include "cmListFileCache.h"
#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmProperty.h"
@@ -28,6 +29,11 @@ std::string const& cmSourceFile::GetExtension() const
const std::string cmSourceFile::propLANGUAGE = "LANGUAGE";
const std::string cmSourceFile::propLOCATION = "LOCATION";
const std::string cmSourceFile::propGENERATED = "GENERATED";
+const std::string cmSourceFile::propCOMPILE_DEFINITIONS =
+ "COMPILE_DEFINITIONS";
+const std::string cmSourceFile::propCOMPILE_OPTIONS = "COMPILE_OPTIONS";
+const std::string cmSourceFile::propINCLUDE_DIRECTORIES =
+ "INCLUDE_DIRECTORIES";
void cmSourceFile::SetObjectLibrary(std::string const& objlib)
{
@@ -226,7 +232,27 @@ bool cmSourceFile::Matches(cmSourceFileLocation const& loc)
void cmSourceFile::SetProperty(const std::string& prop, const char* value)
{
- this->Properties.SetProperty(prop, value);
+ if (prop == propINCLUDE_DIRECTORIES) {
+ this->IncludeDirectories.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->IncludeDirectories.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_OPTIONS) {
+ this->CompileOptions.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileOptions.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_DEFINITIONS) {
+ this->CompileDefinitions.clear();
+ if (value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileDefinitions.emplace_back(value, lfbt);
+ }
+ } else {
+ this->Properties.SetProperty(prop, value);
+ }
// Update IsGenerated flag
if (prop == propGENERATED) {
@@ -237,7 +263,24 @@ void cmSourceFile::SetProperty(const std::string& prop, const char* value)
void cmSourceFile::AppendProperty(const std::string& prop, const char* value,
bool asString)
{
- this->Properties.AppendProperty(prop, value, asString);
+ if (prop == propINCLUDE_DIRECTORIES) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->IncludeDirectories.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_OPTIONS) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileOptions.emplace_back(value, lfbt);
+ }
+ } else if (prop == propCOMPILE_DEFINITIONS) {
+ if (value && *value) {
+ cmListFileBacktrace lfbt = this->Location.GetMakefile()->GetBacktrace();
+ this->CompileDefinitions.emplace_back(value, lfbt);
+ }
+ } else {
+ this->Properties.AppendProperty(prop, value, asString);
+ }
// Update IsGenerated flag
if (prop == propGENERATED) {
@@ -287,6 +330,37 @@ const char* cmSourceFile::GetProperty(const std::string& prop) const
return this->FullPath.c_str();
}
+ // Check for the properties with backtraces.
+ if (prop == propINCLUDE_DIRECTORIES) {
+ if (this->IncludeDirectories.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->IncludeDirectories, ";");
+ return output.c_str();
+ }
+
+ if (prop == propCOMPILE_OPTIONS) {
+ if (this->CompileOptions.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->CompileOptions, ";");
+ return output.c_str();
+ }
+
+ if (prop == propCOMPILE_DEFINITIONS) {
+ if (this->CompileDefinitions.empty()) {
+ return nullptr;
+ }
+
+ static std::string output;
+ output = cmJoin(this->CompileDefinitions, ";");
+ return output.c_str();
+ }
+
const char* retVal = this->Properties.GetPropertyValue(prop);
if (!retVal) {
cmMakefile const* mf = this->Location.GetMakefile();