summaryrefslogtreecommitdiffstats
path: root/Source/cmNinjaTargetGenerator.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'Source/cmNinjaTargetGenerator.cxx')
-rw-r--r--Source/cmNinjaTargetGenerator.cxx264
1 files changed, 152 insertions, 112 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 486ed8d..701c44f 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -7,6 +7,8 @@
#include <iterator>
#include <map>
#include <ostream>
+#include <unordered_map>
+#include <unordered_set>
#include <utility>
#include <cm/memory>
@@ -94,17 +96,19 @@ cmGlobalNinjaGenerator* cmNinjaTargetGenerator::GetGlobalGenerator() const
std::string cmNinjaTargetGenerator::LanguageCompilerRule(
const std::string& lang, const std::string& config) const
{
- return lang + "_COMPILER__" +
- cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) +
- "_" + config;
+ return cmStrCat(
+ lang, "_COMPILER__",
+ cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
+ '_', config);
}
std::string cmNinjaTargetGenerator::LanguagePreprocessRule(
std::string const& lang, const std::string& config) const
{
- return lang + "_PREPROCESS__" +
- cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) +
- "_" + config;
+ return cmStrCat(
+ lang, "_PREPROCESS__",
+ cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
+ '_', config);
}
bool cmNinjaTargetGenerator::NeedExplicitPreprocessing(
@@ -129,9 +133,10 @@ bool cmNinjaTargetGenerator::CompilePreprocessedSourceWithDefines(
std::string cmNinjaTargetGenerator::LanguageDyndepRule(
const std::string& lang, const std::string& config) const
{
- return lang + "_DYNDEP__" +
- cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()) +
- "_" + config;
+ return cmStrCat(
+ lang, "_DYNDEP__",
+ cmGlobalNinjaGenerator::EncodeRuleName(this->GeneratorTarget->GetName()),
+ '_', config);
}
bool cmNinjaTargetGenerator::NeedDyndep(std::string const& lang) const
@@ -154,7 +159,26 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
cmSourceFile const* source, const std::string& language,
const std::string& config)
{
- std::string flags = this->GetFlags(language, config);
+ std::vector<std::string> architectures;
+ std::unordered_map<std::string, std::string> pchSources;
+ this->GeneratorTarget->GetAppleArchs(config, architectures);
+ if (architectures.empty()) {
+ architectures.emplace_back();
+ }
+
+ std::string filterArch;
+ for (const std::string& arch : architectures) {
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(config, language, arch);
+ if (pchSource == source->GetFullPath()) {
+ filterArch = arch;
+ }
+ if (!pchSource.empty()) {
+ pchSources.insert(std::make_pair(pchSource, arch));
+ }
+ }
+
+ std::string flags = this->GetFlags(language, config, filterArch);
// Add Fortran format flags.
if (language == "Fortran") {
@@ -166,26 +190,24 @@ std::string cmNinjaTargetGenerator::ComputeFlagsForObject(
this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string COMPILE_FLAGS("COMPILE_FLAGS");
- if (const char* cflags = source->GetProperty(COMPILE_FLAGS)) {
+ if (cmProp cflags = source->GetProperty(COMPILE_FLAGS)) {
this->LocalGenerator->AppendFlags(
- flags, genexInterpreter.Evaluate(cflags, COMPILE_FLAGS));
+ flags, genexInterpreter.Evaluate(*cflags, COMPILE_FLAGS));
}
const std::string COMPILE_OPTIONS("COMPILE_OPTIONS");
- if (const char* coptions = source->GetProperty(COMPILE_OPTIONS)) {
+ if (cmProp coptions = source->GetProperty(COMPILE_OPTIONS)) {
this->LocalGenerator->AppendCompileOptions(
- flags, genexInterpreter.Evaluate(coptions, COMPILE_OPTIONS));
+ flags, genexInterpreter.Evaluate(*coptions, COMPILE_OPTIONS));
}
// Add precompile headers compile options.
- const std::string pchSource =
- this->GeneratorTarget->GetPchSource(config, language);
-
- if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
std::string pchOptions;
- if (source->GetFullPath() == pchSource) {
- pchOptions =
- this->GeneratorTarget->GetPchCreateCompileOptions(config, language);
+ auto pchIt = pchSources.find(source->GetFullPath());
+ if (pchIt != pchSources.end()) {
+ pchOptions = this->GeneratorTarget->GetPchCreateCompileOptions(
+ config, language, pchIt->second);
} else {
pchOptions =
this->GeneratorTarget->GetPchUseCompileOptions(config, language);
@@ -219,8 +241,8 @@ void cmNinjaTargetGenerator::AddIncludeFlags(std::string& languageFlags,
bool cmNinjaTargetGenerator::NeedDepTypeMSVC(const std::string& lang) const
{
- std::string const& deptype =
- this->GetMakefile()->GetSafeDefinition("CMAKE_NINJA_DEPTYPE_" + lang);
+ std::string const& deptype = this->GetMakefile()->GetSafeDefinition(
+ cmStrCat("CMAKE_NINJA_DEPTYPE_", lang));
if (deptype == "msvc") {
return true;
}
@@ -259,17 +281,17 @@ std::string cmNinjaTargetGenerator::ComputeDefines(cmSourceFile const* source,
}
const std::string COMPILE_DEFINITIONS("COMPILE_DEFINITIONS");
- if (const char* compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
+ if (cmProp compile_defs = source->GetProperty(COMPILE_DEFINITIONS)) {
this->LocalGenerator->AppendDefines(
- defines, genexInterpreter.Evaluate(compile_defs, COMPILE_DEFINITIONS));
+ defines, genexInterpreter.Evaluate(*compile_defs, COMPILE_DEFINITIONS));
}
std::string defPropName =
cmStrCat("COMPILE_DEFINITIONS_", cmSystemTools::UpperCase(config));
- if (const char* config_compile_defs = source->GetProperty(defPropName)) {
+ if (cmProp config_compile_defs = source->GetProperty(defPropName)) {
this->LocalGenerator->AppendDefines(
defines,
- genexInterpreter.Evaluate(config_compile_defs, COMPILE_DEFINITIONS));
+ genexInterpreter.Evaluate(*config_compile_defs, COMPILE_DEFINITIONS));
}
std::string definesString = this->GetDefines(language, config);
@@ -287,9 +309,9 @@ std::string cmNinjaTargetGenerator::ComputeIncludes(
this->LocalGenerator, config, this->GeneratorTarget, language);
const std::string INCLUDE_DIRECTORIES("INCLUDE_DIRECTORIES");
- if (const char* cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
+ if (cmProp cincludes = source->GetProperty(INCLUDE_DIRECTORIES)) {
this->LocalGenerator->AppendIncludeDirectories(
- includes, genexInterpreter.Evaluate(cincludes, INCLUDE_DIRECTORIES),
+ includes, genexInterpreter.Evaluate(*cincludes, INCLUDE_DIRECTORIES),
*source);
}
@@ -355,13 +377,12 @@ std::string cmNinjaTargetGenerator::GetObjectFilePath(
{
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) {
- path += "/";
+ path += '/';
}
std::string const& objectName = this->GeneratorTarget->GetObjectName(source);
- path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- path += this->GetGlobalGenerator()->ConfigDirectory(config);
- path += "/";
- path += objectName;
+ path += cmStrCat(
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ this->GetGlobalGenerator()->ConfigDirectory(config), '/', objectName);
return path;
}
@@ -389,16 +410,15 @@ std::string cmNinjaTargetGenerator::GetPreprocessedFilePath(
this->GetGlobalGenerator()->GetLanguageOutputExtension(*source);
assert(objName.size() >= objExt.size());
std::string const ppName =
- objName.substr(0, objName.size() - objExt.size()) + "-pp." + ppExt;
+ cmStrCat(objName.substr(0, objName.size() - objExt.size()), "-pp.", ppExt);
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) {
- path += "/";
+ path += '/';
}
- path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- path += this->GetGlobalGenerator()->ConfigDirectory(config);
- path += "/";
- path += ppName;
+ path +=
+ cmStrCat(this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ this->GetGlobalGenerator()->ConfigDirectory(config), '/', ppName);
return path;
}
@@ -407,13 +427,11 @@ std::string cmNinjaTargetGenerator::GetDyndepFilePath(
{
std::string path = this->LocalGenerator->GetHomeRelativeOutputPath();
if (!path.empty()) {
- path += "/";
+ path += '/';
}
- path += this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget);
- path += this->GetGlobalGenerator()->ConfigDirectory(config);
- path += "/";
- path += lang;
- path += ".dd";
+ path += cmStrCat(
+ this->LocalGenerator->GetTargetDirectory(this->GeneratorTarget),
+ this->GetGlobalGenerator()->ConfigDirectory(config), '/', lang, ".dd");
return path;
}
@@ -442,8 +460,7 @@ std::string cmNinjaTargetGenerator::GetTargetFilePath(
if (path.empty() || path == ".") {
return name;
}
- path += "/";
- path += name;
+ path += cmStrCat('/', name);
return path;
}
@@ -497,7 +514,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
cmRulePlaceholderExpander::RuleVariables vars;
vars.CMTargetName = this->GetGeneratorTarget()->GetName().c_str();
vars.CMTargetType =
- cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType());
+ cmState::GetTargetTypeName(this->GetGeneratorTarget()->GetType()).c_str();
vars.Language = lang.c_str();
vars.Source = "$in";
vars.Object = "$out";
@@ -522,7 +539,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
bool const lang_supports_response = lang != "RC";
if (lang_supports_response && this->ForceResponseFile()) {
std::string const responseFlagVar =
- "CMAKE_" + lang + "_RESPONSE_FILE_FLAG";
+ cmStrCat("CMAKE_", lang, "_RESPONSE_FILE_FLAG");
responseFlag = this->Makefile->GetSafeDefinition(responseFlagVar);
if (responseFlag.empty() && lang != "CUDA") {
responseFlag = "@";
@@ -587,7 +604,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.RspFile = "$RSP_FILE";
rule.RspContent =
cmStrCat(' ', ppVars.Defines, ' ', ppVars.Includes, ' ', ppFlags);
- ppFlags = responseFlag + rule.RspFile;
+ ppFlags = cmStrCat(responseFlag, rule.RspFile);
ppVars.Defines = "";
ppVars.Includes = "";
}
@@ -658,7 +675,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.RspFile = "$RSP_FILE";
rule.RspContent =
cmStrCat(' ', vars.Defines, ' ', vars.Includes, ' ', flags);
- flags = responseFlag + rule.RspFile;
+ flags = cmStrCat(responseFlag, rule.RspFile);
vars.Defines = "";
vars.Includes = "";
}
@@ -671,7 +688,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
rule.DepType = "msvc";
rule.DepFile.clear();
flags += " /showIncludes";
- } else if (mf->IsOn("CMAKE_NINJA_CMCLDEPS_" + lang)) {
+ } else if (mf->IsOn(cmStrCat("CMAKE_NINJA_CMCLDEPS_", lang))) {
// For the MS resource compiler we need cmcldeps, but skip dependencies
// for source-file try_compile cases because they are always fresh.
if (!mf->GetIsSourceFileTryCompile()) {
@@ -688,14 +705,14 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
} else {
rule.DepType = "gcc";
rule.DepFile = "$DEP_FILE";
- const std::string flagsName = "CMAKE_DEPFILE_FLAGS_" + lang;
+ const std::string flagsName = cmStrCat("CMAKE_DEPFILE_FLAGS_", lang);
std::string depfileFlags = mf->GetSafeDefinition(flagsName);
if (!depfileFlags.empty()) {
cmSystemTools::ReplaceString(depfileFlags, "<DEPFILE>", "$DEP_FILE");
cmSystemTools::ReplaceString(depfileFlags, "<OBJECT>", "$out");
cmSystemTools::ReplaceString(depfileFlags, "<CMAKE_C_COMPILER>",
mf->GetDefinition("CMAKE_C_COMPILER"));
- flags += " " + depfileFlags;
+ flags += cmStrCat(' ', depfileFlags);
}
}
@@ -718,7 +735,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds);
} else {
- const std::string cmdVar = "CMAKE_" + lang + "_COMPILE_OBJECT";
+ const std::string cmdVar = cmStrCat("CMAKE_", lang, "_COMPILE_OBJECT");
const std::string& compileCmd = mf->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds);
}
@@ -728,7 +745,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
if (!compileCmds.empty() &&
(lang == "C" || lang == "CXX" || lang == "Fortran" || lang == "CUDA" ||
lang == "OBJC" || lang == "OBJCXX")) {
- std::string const clauncher_prop = lang + "_COMPILER_LAUNCHER";
+ std::string const clauncher_prop = cmStrCat(lang, "_COMPILER_LAUNCHER");
const char* clauncher = this->GeneratorTarget->GetProperty(clauncher_prop);
if (clauncher && *clauncher) {
compilerLauncher = clauncher;
@@ -737,13 +754,13 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
// Maybe insert an include-what-you-use runner.
if (!compileCmds.empty() && (lang == "C" || lang == "CXX")) {
- std::string const iwyu_prop = lang + "_INCLUDE_WHAT_YOU_USE";
+ std::string const iwyu_prop = cmStrCat(lang, "_INCLUDE_WHAT_YOU_USE");
const char* iwyu = this->GeneratorTarget->GetProperty(iwyu_prop);
- std::string const tidy_prop = lang + "_CLANG_TIDY";
+ std::string const tidy_prop = cmStrCat(lang, "_CLANG_TIDY");
const char* tidy = this->GeneratorTarget->GetProperty(tidy_prop);
- std::string const cpplint_prop = lang + "_CPPLINT";
+ std::string const cpplint_prop = cmStrCat(lang, "_CPPLINT");
const char* cpplint = this->GeneratorTarget->GetProperty(cpplint_prop);
- std::string const cppcheck_prop = lang + "_CPPCHECK";
+ std::string const cppcheck_prop = cmStrCat(lang, "_CPPCHECK");
const char* cppcheck = this->GeneratorTarget->GetProperty(cppcheck_prop);
if ((iwyu && *iwyu) || (tidy && *tidy) || (cpplint && *cpplint) ||
(cppcheck && *cppcheck)) {
@@ -751,18 +768,19 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
if (!compilerLauncher.empty()) {
// In __run_co_compile case the launcher command is supplied
// via --launcher=<maybe-list> and consumed
- run_iwyu += " --launcher=";
- run_iwyu += this->LocalGenerator->EscapeForShell(compilerLauncher);
+ run_iwyu +=
+ cmStrCat(" --launcher=",
+ this->LocalGenerator->EscapeForShell(compilerLauncher));
compilerLauncher.clear();
}
if (iwyu && *iwyu) {
- run_iwyu += " --iwyu=";
- run_iwyu += this->GetLocalGenerator()->EscapeForShell(iwyu);
+ run_iwyu += cmStrCat(" --iwyu=",
+ this->GetLocalGenerator()->EscapeForShell(iwyu));
}
if (tidy && *tidy) {
run_iwyu += " --tidy=";
const char* driverMode = this->Makefile->GetDefinition(
- "CMAKE_" + lang + "_CLANG_TIDY_DRIVER_MODE");
+ cmStrCat("CMAKE_", lang, "_CLANG_TIDY_DRIVER_MODE"));
if (!(driverMode && *driverMode)) {
driverMode = lang == "C" ? "gcc" : "g++";
}
@@ -770,12 +788,12 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
cmStrCat(tidy, ";--extra-arg-before=--driver-mode=", driverMode));
}
if (cpplint && *cpplint) {
- run_iwyu += " --cpplint=";
- run_iwyu += this->GetLocalGenerator()->EscapeForShell(cpplint);
+ run_iwyu += cmStrCat(
+ " --cpplint=", this->GetLocalGenerator()->EscapeForShell(cpplint));
}
if (cppcheck && *cppcheck) {
- run_iwyu += " --cppcheck=";
- run_iwyu += this->GetLocalGenerator()->EscapeForShell(cppcheck);
+ run_iwyu += cmStrCat(
+ " --cppcheck=", this->GetLocalGenerator()->EscapeForShell(cppcheck));
}
if ((tidy && *tidy) || (cpplint && *cpplint) ||
(cppcheck && *cppcheck)) {
@@ -797,7 +815,7 @@ void cmNinjaTargetGenerator::WriteCompileRule(const std::string& lang,
i = this->LocalGenerator->EscapeForShell(i);
}
}
- compileCmds.front().insert(0, cmJoin(args, " ") + " ");
+ compileCmds.front().insert(0, cmStrCat(cmJoin(args, " "), ' '));
}
if (!compileCmds.empty()) {
@@ -872,7 +890,8 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
{
cmNinjaBuild build("phony");
- build.Comment = "Order-only phony target for " + this->GetTargetName();
+ build.Comment =
+ cmStrCat("Order-only phony target for ", this->GetTargetName());
build.Outputs.push_back(this->OrderDependsTargetForTarget(config));
cmNinjaDeps& orderOnlyDeps = build.OrderOnlyDeps;
@@ -960,9 +979,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatements(
if (const char* name = target->GetProperty("Swift_DEPENDENCIES_FILE")) {
return name;
}
- return this->ConvertToNinjaPath(target->GetSupportDirectory() + "/" +
- config + "/" + target->GetName() +
- ".swiftdeps");
+ return this->ConvertToNinjaPath(
+ cmStrCat(target->GetSupportDirectory(), '/', config, '/',
+ target->GetName(), ".swiftdeps"));
}();
// build the global target dependencies
@@ -994,7 +1013,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
std::string cmakeVarLang = cmStrCat("CMAKE_", language);
// build response file name
- std::string cmakeLinkVar = cmakeVarLang + "_RESPONSE_FILE_FLAG";
+ std::string cmakeLinkVar = cmStrCat(cmakeVarLang, "_RESPONSE_FILE_FLAG");
const char* flag = GetMakefile()->GetDefinition(cmakeLinkVar);
@@ -1019,14 +1038,15 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
if (!replaceExt) {
// use original code
vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- objectFileName + ".d", cmOutputConverter::SHELL);
+ cmStrCat(objectFileName, ".d"), cmOutputConverter::SHELL);
} else {
// Replace the original source file extension with the
// depend file extension.
- std::string dependFileName =
- cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d";
+ std::string dependFileName = cmStrCat(
+ cmSystemTools::GetFilenameWithoutLastExtension(objectFileName), ".d");
vars["DEP_FILE"] = this->GetLocalGenerator()->ConvertToOutputFormat(
- objectFileDir + "/" + dependFileName, cmOutputConverter::SHELL);
+ cmStrCat(objectFileDir, '/', dependFileName),
+ cmOutputConverter::SHELL);
}
}
@@ -1049,17 +1069,35 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// Add precompile headers dependencies
std::vector<std::string> depList;
- const std::string pchSource =
- this->GeneratorTarget->GetPchSource(config, language);
- if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
- depList.push_back(this->GeneratorTarget->GetPchHeader(config, language));
- if (source->GetFullPath() != pchSource) {
- depList.push_back(this->GeneratorTarget->GetPchFile(config, language));
+ std::vector<std::string> architectures;
+ this->GeneratorTarget->GetAppleArchs(config, architectures);
+ if (architectures.empty()) {
+ architectures.emplace_back();
+ }
+
+ std::unordered_set<std::string> pchSources;
+ for (const std::string& arch : architectures) {
+ const std::string pchSource =
+ this->GeneratorTarget->GetPchSource(config, language, arch);
+
+ if (!pchSource.empty()) {
+ pchSources.insert(pchSource);
+ }
+ }
+
+ if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ for (const std::string& arch : architectures) {
+ depList.push_back(
+ this->GeneratorTarget->GetPchHeader(config, language, arch));
+ if (pchSources.find(source->GetFullPath()) == pchSources.end()) {
+ depList.push_back(
+ this->GeneratorTarget->GetPchFile(config, language, arch));
+ }
}
}
- if (const char* objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
- std::vector<std::string> objDepList = cmExpandedList(objectDeps);
+ if (cmProp objectDeps = source->GetProperty("OBJECT_DEPENDS")) {
+ std::vector<std::string> objDepList = cmExpandedList(*objectDeps);
std::copy(objDepList.begin(), objDepList.end(),
std::back_inserter(depList));
}
@@ -1101,7 +1139,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->ConvertToNinjaPath(this->GetPreprocessedFilePath(source, config));
ppBuild.Outputs.push_back(ppFileName);
- ppBuild.RspFile = ppFileName + ".rsp";
+ ppBuild.RspFile = cmStrCat(ppFileName, ".rsp");
bool const compilePP = this->UsePreprocessedSource(language);
bool const compilePPWithDefines =
@@ -1130,7 +1168,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
// In case compilation requires flags that are incompatible with
// preprocessing, include them here.
std::string const& postFlag = this->Makefile->GetSafeDefinition(
- "CMAKE_" + language + "_POSTPROCESS_FLAG");
+ cmStrCat("CMAKE_", language, "_POSTPROCESS_FLAG"));
this->LocalGenerator->AppendFlags(vars["FLAGS"], postFlag);
}
@@ -1158,13 +1196,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
sourceDirectory, this->GeneratorTarget, language, false, false,
config);
- vars["INCLUDES"] = sourceDirectoryFlag + " " + vars["INCLUDES"];
+ vars["INCLUDES"] = cmStrCat(sourceDirectoryFlag, ' ', vars["INCLUDES"]);
}
// Explicit preprocessing always uses a depfile.
ppBuild.Variables["DEP_FILE"] =
this->GetLocalGenerator()->ConvertToOutputFormat(
- objectFileName + ".pp.d", cmOutputConverter::SHELL);
+ cmStrCat(objectFileName, ".pp.d"), cmOutputConverter::SHELL);
if (compilePP) {
// The actual compilation does not need a depfile because it
// depends on the already-preprocessed source.
@@ -1177,7 +1215,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
ppBuild.Variables["OBJ_FILE"] = objectFileName;
// Tell dependency scanner where to store dyndep intermediate results.
- std::string const ddiFile = objectFileName + ".ddi";
+ std::string const ddiFile = cmStrCat(objectFileName, ".ddi");
ppBuild.Variables["DYNDEP_INTERMEDIATE_FILE"] = ddiFile;
ppBuild.ImplicitOuts.push_back(ddiFile);
if (firstForConfig) {
@@ -1207,8 +1245,9 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
vars);
- if (!pchSource.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
- if (source->GetFullPath() == pchSource) {
+ if (!pchSources.empty() && !source->GetProperty("SKIP_PRECOMPILE_HEADERS")) {
+ auto pchIt = pchSources.find(source->GetFullPath());
+ if (pchIt != pchSources.end()) {
this->addPoolNinjaVariable("JOB_POOL_PRECOMPILE_HEADER",
this->GetGeneratorTarget(), vars);
}
@@ -1216,7 +1255,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
this->SetMsvcTargetPdbVariable(vars, config);
- objBuild.RspFile = objectFileName + ".rsp";
+ objBuild.RspFile = cmStrCat(objectFileName, ".rsp");
if (language == "Swift") {
this->EmitSwiftDependencyInfo(source, config);
@@ -1225,10 +1264,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
objBuild, commandLineLengthLimit);
}
- if (const char* objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
+ if (cmProp objectOutputs = source->GetProperty("OBJECT_OUTPUTS")) {
cmNinjaBuild build("phony");
build.Comment = "Additional output files.";
- build.Outputs = cmExpandedList(objectOutputs);
+ build.Outputs = cmExpandedList(*objectOutputs);
std::transform(build.Outputs.begin(), build.Outputs.end(),
build.Outputs.begin(), MapToNinjaPath());
build.ExplicitDeps = objBuild.Outputs;
@@ -1242,8 +1281,8 @@ void cmNinjaTargetGenerator::WriteTargetDependInfo(std::string const& lang,
{
Json::Value tdi(Json::objectValue);
tdi["language"] = lang;
- tdi["compiler-id"] =
- this->Makefile->GetSafeDefinition("CMAKE_" + lang + "_COMPILER_ID");
+ tdi["compiler-id"] = this->Makefile->GetSafeDefinition(
+ cmStrCat("CMAKE_", lang, "_COMPILER_ID"));
if (lang == "Fortran") {
std::string mod_dir = this->GeneratorTarget->GetFortranModuleDirectory(
@@ -1292,16 +1331,16 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
std::string const objectFilePath =
this->ConvertToNinjaPath(this->GetObjectFilePath(source, config));
std::string const swiftDepsPath = [source, objectFilePath]() -> std::string {
- if (const char* name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
- return name;
+ if (cmProp name = source->GetProperty("Swift_DEPENDENCIES_FILE")) {
+ return *name;
}
- return objectFilePath + ".swiftdeps";
+ return cmStrCat(objectFilePath, ".swiftdeps");
}();
std::string const swiftDiaPath = [source, objectFilePath]() -> std::string {
- if (const char* name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
- return name;
+ if (cmProp name = source->GetProperty("Swift_DIAGNOSTICS_FILE")) {
+ return *name;
}
- return objectFilePath + ".dia";
+ return cmStrCat(objectFilePath, ".dia");
}();
std::string const makeDepsPath = [this, source, config]() -> std::string {
cmLocalNinjaGenerator const* local = this->GetLocalGenerator();
@@ -1311,12 +1350,13 @@ void cmNinjaTargetGenerator::EmitSwiftDependencyInfo(
cmSystemTools::GetFilenamePath(objectFileName);
if (this->Makefile->IsOn("CMAKE_Swift_DEPFLE_EXTNSION_REPLACE")) {
- std::string dependFileName =
- cmSystemTools::GetFilenameWithoutLastExtension(objectFileName) + ".d";
- return local->ConvertToOutputFormat(objectFileDir + "/" + dependFileName,
- cmOutputConverter::SHELL);
+ std::string dependFileName = cmStrCat(
+ cmSystemTools::GetFilenameWithoutLastExtension(objectFileName), ".d");
+ return local->ConvertToOutputFormat(
+ cmStrCat(objectFileDir, '/', dependFileName),
+ cmOutputConverter::SHELL);
}
- return local->ConvertToOutputFormat(objectFileName + ".d",
+ return local->ConvertToOutputFormat(cmStrCat(objectFileName, ".d"),
cmOutputConverter::SHELL);
}();
@@ -1381,7 +1421,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
this->GetMakefile()->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds);
} else {
- const std::string cmdVar = "CMAKE_" + language + "_COMPILE_OBJECT";
+ const std::string cmdVar = cmStrCat("CMAKE_", language, "_COMPILE_OBJECT");
const std::string& compileCmd =
this->GetMakefile()->GetRequiredDefinition(cmdVar);
cmExpandList(compileCmd, compileCmds);