summaryrefslogtreecommitdiffstats
path: root/Source/cmFileAPICodemodel.cxx
diff options
context:
space:
mode:
authorJustin Goshi <jgoshi@microsoft.com>2019-09-24 19:19:49 (GMT)
committerBrad King <brad.king@kitware.com>2019-09-26 14:56:52 (GMT)
commit8b84c046faa9d6e52b99855a955bd7b6f48e9a8b (patch)
tree7cac01f0a25d97fe924ae42600193ffc2644beff /Source/cmFileAPICodemodel.cxx
parentc71ac889ba6565c2a2aa31a403e3ab999abb5570 (diff)
downloadCMake-8b84c046faa9d6e52b99855a955bd7b6f48e9a8b.zip
CMake-8b84c046faa9d6e52b99855a955bd7b6f48e9a8b.tar.gz
CMake-8b84c046faa9d6e52b99855a955bd7b6f48e9a8b.tar.bz2
fileapi: add some source property backtraces
Support backtraces for COMPILE_DEFINITIONS, COMPILE_OPTIONS, and INCLUDE_DIRECTORIES source properties.
Diffstat (limited to 'Source/cmFileAPICodemodel.cxx')
-rw-r--r--Source/cmFileAPICodemodel.cxx66
1 files changed, 44 insertions, 22 deletions
diff --git a/Source/cmFileAPICodemodel.cxx b/Source/cmFileAPICodemodel.cxx
index 96ea071..fbdb975 100644
--- a/Source/cmFileAPICodemodel.cxx
+++ b/Source/cmFileAPICodemodel.cxx
@@ -858,47 +858,69 @@ CompileData Target::BuildCompileData(cmSourceFile* sf)
fd.Flags.emplace_back(std::move(flags), JBTIndex());
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = sf->GetProperty(COMPILE_OPTIONS)) {
- std::string flags;
- lg->AppendCompileOptions(
- flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
- fd.Flags.emplace_back(std::move(flags), JBTIndex());
+ for (BT<std::string> tmpOpt : sf->GetCompileOptions()) {
+ tmpOpt.Value = genexInterpreter.Evaluate(tmpOpt.Value, COMPILE_OPTIONS);
+ // After generator evaluation we need to use the AppendCompileOptions
+ // method so we handle situations where backtrace entries have lists
+ // and properly escape flags.
+ std::string tmp;
+ lg->AppendCompileOptions(tmp, tmpOpt.Value);
+ BT<std::string> opt(tmp, tmpOpt.Backtrace);
+ fd.Flags.emplace_back(this->ToJBT(opt));
}
// Add include directories from source file properties.
{
- std::vector<std::string> includes;
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = sf->GetProperty(INCLUDE_DIRECTORIES)) {
- const std::string& evaluatedIncludes =
- genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES);
- lg->AppendIncludeDirectories(includes, evaluatedIncludes, *sf);
-
- for (std::string const& include : includes) {
- bool const isSystemInclude = this->GT->IsSystemIncludeDirectory(
- include, this->Config, fd.Language);
- fd.Includes.emplace_back(include, isSystemInclude);
+ for (BT<std::string> tmpInclude : sf->GetIncludeDirectories()) {
+ tmpInclude.Value =
+ genexInterpreter.Evaluate(tmpInclude.Value, INCLUDE_DIRECTORIES);
+
+ // After generator evaluation we need to use the AppendIncludeDirectories
+ // method so we handle situations where backtrace entries have lists.
+ std::vector<std::string> tmp;
+ lg->AppendIncludeDirectories(tmp, tmpInclude.Value, *sf);
+ for (std::string& i : tmp) {
+ bool const isSystemInclude =
+ this->GT->IsSystemIncludeDirectory(i, this->Config, fd.Language);
+ BT<std::string> include(i, tmpInclude.Backtrace);
+ fd.Includes.emplace_back(this->ToJBT(include), isSystemInclude);
}
}
}
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- std::set<std::string> fileDefines;
- if (const char* defs = sf->GetProperty(COMPILE_DEFINITIONS)) {
- lg->AppendDefines(fileDefines,
- genexInterpreter.Evaluate(defs, COMPILE_DEFINITIONS));
+ std::set<BT<std::string>> fileDefines;
+ for (BT<std::string> tmpDef : sf->GetCompileDefinitions()) {
+ tmpDef.Value =
+ genexInterpreter.Evaluate(tmpDef.Value, COMPILE_DEFINITIONS);
+
+ // After generator evaluation we need to use the AppendDefines method
+ // so we handle situations where backtrace entries have lists.
+ std::set<std::string> tmp;
+ lg->AppendDefines(tmp, tmpDef.Value);
+ for (const std::string& i : tmp) {
+ BT<std::string> def(i, tmpDef.Backtrace);
+ fileDefines.insert(def);
+ }
}
+ std::set<std::string> configFileDefines;
const std::string defPropName =
"COMPILE_DEFINITIONS_" + cmSystemTools::UpperCase(this->Config);
if (const char* config_defs = sf->GetProperty(defPropName)) {
lg->AppendDefines(
- fileDefines,
+ configFileDefines,
genexInterpreter.Evaluate(config_defs, COMPILE_DEFINITIONS));
}
- fd.Defines.reserve(fileDefines.size());
- for (std::string const& d : fileDefines) {
+ fd.Defines.reserve(fileDefines.size() + configFileDefines.size());
+
+ for (BT<std::string> const& def : fileDefines) {
+ fd.Defines.emplace_back(this->ToJBT(def));
+ }
+
+ for (std::string const& d : configFileDefines) {
fd.Defines.emplace_back(d, JBTIndex());
}