From 73fbad3d93c8d2d7a415cbbcbe01d3370fd71fa6 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 22 Dec 2023 16:18:18 -0500 Subject: cmNinjaTargetGenerator: use scan flag for modmap usage in exported commands See: https://discourse.cmake.org/t/how-to-control-the-location-of-the-c-20-binary-module-interface-bmi-output-directory/7968 --- Source/cmNinjaTargetGenerator.cxx | 18 +++++++++--------- Source/cmNinjaTargetGenerator.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx index 4025918..1d90194 100644 --- a/Source/cmNinjaTargetGenerator.cxx +++ b/Source/cmNinjaTargetGenerator.cxx @@ -1373,8 +1373,10 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( bool const needDyndep = !isPch && this->GeneratorTarget->NeedDyndepForSource(language, config, source); - cmNinjaBuild objBuild(this->LanguageCompilerRule( - language, config, needDyndep ? WithScanning::Yes : WithScanning::No)); + WithScanning withScanning = + needDyndep ? WithScanning::Yes : WithScanning::No; + cmNinjaBuild objBuild( + this->LanguageCompilerRule(language, config, withScanning)); cmNinjaVars& vars = objBuild.Variables; vars["FLAGS"] = this->ComputeFlagsForObject(source, language, config, objectFileName); @@ -1434,7 +1436,7 @@ void cmNinjaTargetGenerator::WriteObjectBuildStatement( if (firstForConfig) { this->ExportObjectCompileCommand( language, sourceFilePath, objectDir, objectFileName, objectFileDir, - vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config); + vars["FLAGS"], vars["DEFINES"], vars["INCLUDES"], config, withScanning); } objBuild.Outputs.push_back(objectFileName); @@ -1780,7 +1782,7 @@ void cmNinjaTargetGenerator::WriteCxxModuleBmiBuildStatement( if (firstForConfig) { this->ExportObjectCompileCommand( language, sourceFilePath, bmiDir, bmiFileName, bmiFileDir, vars["FLAGS"], - vars["DEFINES"], vars["INCLUDES"], config); + vars["DEFINES"], vars["INCLUDES"], config, WithScanning::Yes); } bmiBuild.Outputs.push_back(bmiFileName); @@ -1992,7 +1994,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& outputConfig) + std::string const& outputConfig, WithScanning withScanning) { if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) { return; @@ -2015,14 +2017,12 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand( escapedSourceFileName, cmOutputConverter::SHELL); std::string fullFlags = flags; - { - bool const needDyndep = - this->GetGeneratorTarget()->NeedDyndep(language, outputConfig); + if (withScanning == WithScanning::Yes) { std::string const modmapFormatVar = cmStrCat("CMAKE_", language, "_MODULE_MAP_FORMAT"); std::string const modmapFormat = this->Makefile->GetSafeDefinition(modmapFormatVar); - if (needDyndep && !modmapFormat.empty()) { + if (!modmapFormat.empty()) { std::string modmapFlags = this->GetMakefile()->GetRequiredDefinition( cmStrCat("CMAKE_", language, "_MODULE_MAP_FLAG")); // XXX(modmap): If changing this path construction, change diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h index 3f56113..a9bff1d 100644 --- a/Source/cmNinjaTargetGenerator.h +++ b/Source/cmNinjaTargetGenerator.h @@ -189,7 +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& outputConfig); + std::string const& outputConfig, WithScanning withScanning); void AdditionalCleanFiles(const std::string& config); -- cgit v0.12