summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Theophil <stheophil@think-cell.com>2023-10-18 12:39:08 (GMT)
committerBrad King <brad.king@kitware.com>2023-10-18 13:55:28 (GMT)
commit67ddca187cc96b805060fc6d1a140814968ebe39 (patch)
tree17d84f1a90ab72ae7f5975d9e18beadcb543792f
parent7144216f45c402b68ec8d7b5e8050b6536a199aa (diff)
downloadCMake-67ddca187cc96b805060fc6d1a140814968ebe39.zip
CMake-67ddca187cc96b805060fc6d1a140814968ebe39.tar.gz
CMake-67ddca187cc96b805060fc6d1a140814968ebe39.tar.bz2
Ninja: Set TARGET_COMPILE_PDB correctly for compile_commands.json
Previously the Ninja target generator did not set the TARGET_COMPILE_PDB before writing a compiler command to `compile_commands.json`. Fixes: #25214
-rw-r--r--Source/cmNinjaTargetGenerator.cxx17
-rw-r--r--Source/cmNinjaTargetGenerator.h1
2 files changed, 12 insertions, 6 deletions
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 0bda945..a93f9c9 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1409,10 +1409,13 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
}
+ this->SetMsvcTargetPdbVariable(vars, config);
+
if (firstForConfig) {
this->ExportObjectCompileCommand(
language, sourceFilePath, objectDir, objectFileName, objectFileDir,
- vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config);
+ vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"],
+ vars["TARGET_COMPILE_PDB"], vars["TARGET_PDB"], config);
}
objBuild.Outputs.push_back(objectFileName);
@@ -1607,8 +1610,6 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement(
}
}
- this->SetMsvcTargetPdbVariable(vars, config);
-
objBuild.RspFile = cmStrCat(objectFileName, ".rsp");
if (language == "ISPC") {
@@ -1759,10 +1760,13 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement(
vars["CLANG_TIDY_EXPORT_FIXES"] = fixesFile;
}
+ this->SetMsvcTargetPdbVariable(vars, config);
+
if (firstForConfig) {
this->ExportObjectCompileCommand(
language, sourceFilePath, bmiDir, bmiFileName, bmiFileDir, vars["FLAGS"],
- vars["DEFINES"], vars["INCLUDES"], config);
+ vars["DEFINES"], vars["INCLUDES"], vars["TARGET_COMPILE_PDB"],
+ vars["TARGET_PDB"], config);
}
bmiBuild.Outputs.push_back(bmiFileName);
@@ -1833,8 +1837,6 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement(
this->addPoolNinjaVariable("JOB_POOL_COMPILE", this->GetGeneratorTarget(),
vars);
- this->SetMsvcTargetPdbVariable(vars, config);
-
bmiBuild.RspFile = cmStrCat(bmiFileName, ".rsp");
this->GetGlobalGenerator()->WriteBuild(this->GetImplFileStream(fileConfig),
@@ -1966,6 +1968,7 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
std::string const& objectDir, std::string const& objectFileName,
std::string const& objectFileDir, std::string const& flags,
std::string const& defines, std::string const& includes,
+ std::string const& targetCompilePdb, std::string const& targetPdb,
std::string const& outputConfig)
{
if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) {
@@ -2016,6 +2019,8 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
compileObjectVars.Flags = fullFlags.c_str();
compileObjectVars.Defines = defines.c_str();
compileObjectVars.Includes = includes.c_str();
+ compileObjectVars.TargetCompilePDB = targetCompilePdb.c_str();
+ compileObjectVars.TargetPDB = targetPdb.c_str();
// Rule for compiling object file.
std::string cudaCompileMode;
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index 3f56113..2131f6d 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -189,6 +189,7 @@ protected:
std::string const& objectDir, std::string const& objectFileName,
std::string const& objectFileDir, std::string const& flags,
std::string const& defines, std::string const& includes,
+ std::string const& targetCompilePdb, std::string const& targetPdb,
std::string const& outputConfig);
void AdditionalCleanFiles(const std::string& config);