summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CursesDialog/cmCursesMainForm.cxx5
-rw-r--r--Source/QtDialog/QCMake.cxx96
-rw-r--r--Source/cmComputeLinkInformation.cxx4
-rw-r--r--Source/cmComputeLinkInformation.h2
-rw-r--r--Source/cmFindLibraryCommand.cxx8
-rw-r--r--Source/cmNinjaTargetGenerator.cxx102
-rw-r--r--Source/cmNinjaTargetGenerator.h6
8 files changed, 160 insertions, 65 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index f629903..9ac9d0a 100644
--- a/Source/CMakeVersion.cmake
+++ b/Source/CMakeVersion.cmake
@@ -1,7 +1,7 @@
# CMake version number components.
set(CMake_VERSION_MAJOR 3)
set(CMake_VERSION_MINOR 28)
-set(CMake_VERSION_PATCH 20240103)
+set(CMake_VERSION_PATCH 20240108)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CursesDialog/cmCursesMainForm.cxx b/Source/CursesDialog/cmCursesMainForm.cxx
index 77a0048..72460f3 100644
--- a/Source/CursesDialog/cmCursesMainForm.cxx
+++ b/Source/CursesDialog/cmCursesMainForm.cxx
@@ -962,6 +962,11 @@ int cmCursesMainForm::LoadCache(const char* /*unused*/)
if (r < 0) {
return r;
}
+
+ // Process presets before loading the cache
+ this->CMakeInstance->ProcessPresetVariables();
+ this->CMakeInstance->ProcessPresetEnvironment();
+
this->CMakeInstance->SetCacheArgs(this->Args);
this->CMakeInstance->PreLoadCMakeFiles();
return r;
diff --git a/Source/QtDialog/QCMake.cxx b/Source/QtDialog/QCMake.cxx
index f43f05f..8d63f6d 100644
--- a/Source/QtDialog/QCMake.cxx
+++ b/Source/QtDialog/QCMake.cxx
@@ -378,6 +378,54 @@ void QCMake::setProperties(const QCMakePropertyList& newProps)
this->CMakeInstance->SaveCache(this->BinaryDirectory.toStdString());
}
+namespace {
+template <typename T>
+QCMakeProperty cache_to_property(const T& v)
+{
+ QCMakeProperty prop;
+ prop.Key = QString::fromStdString(v.first);
+ prop.Value = QString::fromStdString(v.second->Value);
+ prop.Type = QCMakeProperty::STRING;
+ if (!v.second->Type.empty()) {
+ auto type = cmState::StringToCacheEntryType(v.second->Type);
+ switch (type) {
+ case cmStateEnums::BOOL:
+ prop.Type = QCMakeProperty::BOOL;
+ prop.Value = cmIsOn(v.second->Value);
+ break;
+ case cmStateEnums::PATH:
+ prop.Type = QCMakeProperty::PATH;
+ break;
+ case cmStateEnums::FILEPATH:
+ prop.Type = QCMakeProperty::FILEPATH;
+ break;
+ default:
+ prop.Type = QCMakeProperty::STRING;
+ break;
+ }
+ }
+ return prop;
+}
+
+void add_to_property_list(QCMakePropertyList& list, QCMakeProperty&& prop)
+{
+ // QCMakeCacheModel prefers variables earlier in the list rather than
+ // later, so overwrite them if they already exist rather than simply
+ // appending
+ bool found = false;
+ for (auto& orig : list) {
+ if (orig.Key == prop.Key) {
+ orig = prop;
+ found = true;
+ break;
+ }
+ }
+ if (!found) {
+ list.append(prop);
+ }
+}
+}
+
QCMakePropertyList QCMake::properties() const
{
QCMakePropertyList ret;
@@ -423,47 +471,21 @@ QCMakePropertyList QCMake::properties() const
auto const& p =
this->CMakePresetsGraph.ConfigurePresets.at(presetName).Expanded;
if (p) {
+ if (!p->ToolchainFile.empty()) {
+ using CacheVariable = cmCMakePresetsGraph::CacheVariable;
+ CacheVariable var{ "FILEPATH", p->ToolchainFile };
+ std::pair<std::string, cm::optional<CacheVariable>> value = {
+ "CMAKE_TOOLCHAIN_FILE", var
+ };
+ auto prop = cache_to_property(value);
+ add_to_property_list(ret, std::move(prop));
+ }
for (auto const& v : p->CacheVariables) {
if (!v.second) {
continue;
}
- QCMakeProperty prop;
- prop.Key = QString::fromStdString(v.first);
- prop.Value = QString::fromStdString(v.second->Value);
- prop.Type = QCMakeProperty::STRING;
- if (!v.second->Type.empty()) {
- auto type = cmState::StringToCacheEntryType(v.second->Type);
- switch (type) {
- case cmStateEnums::BOOL:
- prop.Type = QCMakeProperty::BOOL;
- prop.Value = cmIsOn(v.second->Value);
- break;
- case cmStateEnums::PATH:
- prop.Type = QCMakeProperty::PATH;
- break;
- case cmStateEnums::FILEPATH:
- prop.Type = QCMakeProperty::FILEPATH;
- break;
- default:
- prop.Type = QCMakeProperty::STRING;
- break;
- }
- }
-
- // QCMakeCacheModel prefers variables earlier in the list rather than
- // later, so overwrite them if they already exist rather than simply
- // appending
- bool found = false;
- for (auto& orig : ret) {
- if (orig.Key == prop.Key) {
- orig = prop;
- found = true;
- break;
- }
- }
- if (!found) {
- ret.append(prop);
- }
+ auto prop = cache_to_property(v);
+ add_to_property_list(ret, std::move(prop));
}
}
}
diff --git a/Source/cmComputeLinkInformation.cxx b/Source/cmComputeLinkInformation.cxx
index 1b69f6e..e7bef68 100644
--- a/Source/cmComputeLinkInformation.cxx
+++ b/Source/cmComputeLinkInformation.cxx
@@ -260,7 +260,7 @@ cmComputeLinkInformation::cmComputeLinkInformation(
, Config(config)
{
// Check whether to recognize OpenBSD-style library versioned names.
- this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ this->IsOpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_OPENBSD_VERSIONING");
// Allocate internals.
@@ -1574,7 +1574,7 @@ std::string cmComputeLinkInformation::CreateExtensionRegex(
libext += ')';
// Add an optional OpenBSD-style version or major.minor.version component.
- if (this->OpenBSD || type == LinkShared) {
+ if (this->IsOpenBSD || type == LinkShared) {
libext += "(\\.[0-9]+)*";
}
diff --git a/Source/cmComputeLinkInformation.h b/Source/cmComputeLinkInformation.h
index 3ee995f..2a06530 100644
--- a/Source/cmComputeLinkInformation.h
+++ b/Source/cmComputeLinkInformation.h
@@ -254,7 +254,7 @@ private:
std::unique_ptr<cmOrderDirectories> OrderRuntimeSearchPath;
bool OldLinkDirMode;
- bool OpenBSD;
+ bool IsOpenBSD;
bool LinkDependsNoShared;
bool RuntimeUseChrpath;
bool NoSONameUsesPath;
diff --git a/Source/cmFindLibraryCommand.cxx b/Source/cmFindLibraryCommand.cxx
index df77ad0..9df7665 100644
--- a/Source/cmFindLibraryCommand.cxx
+++ b/Source/cmFindLibraryCommand.cxx
@@ -207,7 +207,7 @@ struct cmFindLibraryHelper
std::string BestPath;
// Support for OpenBSD shared library naming: lib<name>.so.<major>.<minor>
- bool OpenBSD;
+ bool IsOpenBSD;
bool DebugMode;
@@ -320,7 +320,7 @@ cmFindLibraryHelper::cmFindLibraryHelper(std::string debugName, cmMakefile* mf,
this->RegexFromList(this->SuffixRegexStr, this->Suffixes);
// Check whether to use OpenBSD-style library version comparisons.
- this->OpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
+ this->IsOpenBSD = this->Makefile->GetState()->GetGlobalPropertyAsBool(
"FIND_LIBRARY_USE_OPENBSD_VERSIONING");
}
@@ -390,7 +390,7 @@ void cmFindLibraryHelper::AddName(std::string const& name)
std::string regex = cmStrCat('^', this->PrefixRegexStr);
this->RegexFromLiteral(regex, name);
regex += this->SuffixRegexStr;
- if (this->OpenBSD) {
+ if (this->IsOpenBSD) {
regex += "(\\.[0-9]+\\.[0-9]+)?";
}
regex += "$";
@@ -472,7 +472,7 @@ bool cmFindLibraryHelper::CheckDirectoryForName(std::string const& path,
size_type suffix = this->GetSuffixIndex(name.Regex.match(2));
unsigned int major = 0;
unsigned int minor = 0;
- if (this->OpenBSD) {
+ if (this->IsOpenBSD) {
sscanf(name.Regex.match(3).c_str(), ".%u.%u", &major, &minor);
}
if (this->BestPath.empty() || prefix < bestPrefix ||
diff --git a/Source/cmNinjaTargetGenerator.cxx b/Source/cmNinjaTargetGenerator.cxx
index 7ea479e..bc75a95 100644
--- a/Source/cmNinjaTargetGenerator.cxx
+++ b/Source/cmNinjaTargetGenerator.cxx
@@ -1916,7 +1916,6 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
// indistinguishable from the old behavior.
//
// FIXME(#25490): Add response file support to Swift object build step
- // FIXME(#25491): Include all files in module in compile_commands.json
if (sources.empty()) {
return;
@@ -1951,6 +1950,10 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
this->LanguageCompilerRule(language, config, WithScanning::No));
cmNinjaVars& vars = objBuild.Variables;
+ // The swift toolchain leaves outputs untouched if there are no meaningful
+ // changes to input files (e.g. addition of a comment).
+ vars.emplace("restat", "1");
+
std::string const moduleName =
getTargetPropertyOrDefault(target, "Swift_MODULE_NAME", target.GetName());
std::string const moduleDirectory = getTargetPropertyOrDefault(
@@ -2027,15 +2030,7 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
std::string const sourceFilePath = this->GetCompiledSourceNinjaPath(sf);
objBuild.ExplicitDeps.push_back(sourceFilePath);
- if (isSingleOutput) {
- if (firstForConfig) {
- this->ExportObjectCompileCommand(
- language, sourceFilePath, objectDir, targetObjectFilename,
- cmSystemTools::GetFilenamePath(targetObjectFilename), vars["FLAGS"],
- vars["DEFINES"], vars["INCLUDES"],
- /*compile pdb*/ "", /*target pdb*/ "", config, WithScanning::No);
- }
- } else {
+ if (!isSingleOutput) {
// Object outputs
std::string const objectFilepath =
this->ConvertToNinjaPath(this->GetObjectFilePath(sf, config));
@@ -2045,16 +2040,6 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
// Add OFM data
this->EmitSwiftDependencyInfo(sf, config);
-
- // Emit compile commands
- if (firstForConfig) {
- this->ExportObjectCompileCommand(
- language, sourceFilePath, objectDir, objectFilepath,
- cmSystemTools::GetFilenamePath(objectFilepath), vars["FLAGS"],
- vars["DEFINES"], vars["INCLUDES"],
- /*compile pdb*/ "",
- /*target pdb*/ "", config, WithScanning::No);
- }
}
}
@@ -2062,6 +2047,12 @@ void cmNinjaTargetGenerator::WriteSwiftObjectBuildStatement(
this->GenerateSwiftOutputFileMap(config, vars["FLAGS"]);
}
+ if (firstForConfig) {
+ this->ExportSwiftObjectCompileCommand(
+ sources, targetObjectFilename, vars["FLAGS"], vars["DEFINES"],
+ vars["INCLUDES"], config, isSingleOutput);
+ }
+
for (cmTargetDepend const& dep :
this->GetGlobalGenerator()->GetTargetDirectDepends(&target)) {
if (!dep->IsLanguageUsed("Swift", config)) {
@@ -2326,6 +2317,77 @@ void cmNinjaTargetGenerator::ExportObjectCompileCommand(
objectFileName);
}
+void cmNinjaTargetGenerator::ExportSwiftObjectCompileCommand(
+ std::vector<cmSourceFile const*> const& moduleSourceFiles,
+ std::string const& moduleObjectFilename, std::string const& flags,
+ std::string const& defines, std::string const& includes,
+ std::string const& outputConfig, bool singleOutput)
+{
+ if (!this->GeneratorTarget->GetPropertyAsBool("EXPORT_COMPILE_COMMANDS")) {
+ return;
+ }
+
+ auto escapeSourceFileName = [this](std::string srcFilename) -> std::string {
+ if (!cmSystemTools::FileIsFullPath(srcFilename)) {
+ srcFilename =
+ cmSystemTools::CollapseFullPath(srcFilename,
+ this->GetGlobalGenerator()
+ ->GetCMakeInstance()
+ ->GetHomeOutputDirectory());
+ }
+
+ return this->LocalGenerator->ConvertToOutputFormat(
+ srcFilename, cmOutputConverter::SHELL);
+ };
+
+ cmRulePlaceholderExpander::RuleVariables compileObjectVars;
+ compileObjectVars.Language = "Swift";
+ compileObjectVars.Flags = flags.c_str();
+ compileObjectVars.Defines = defines.c_str();
+ compileObjectVars.Includes = includes.c_str();
+
+ // Build up the list of source files in the module
+ std::vector<std::string> filenames;
+ filenames.reserve(moduleSourceFiles.size());
+ for (cmSourceFile const* sf : moduleSourceFiles) {
+ filenames.emplace_back(
+ escapeSourceFileName(this->GetCompiledSourceNinjaPath(sf)));
+ }
+ // Note that `escapedSourceFilenames` must remain alive until the
+ // compileObjectVars is consumed or Source will be a dangling pointer.
+ std::string const escapedSourceFilenames = cmJoin(filenames, " ");
+ compileObjectVars.Source = escapedSourceFilenames.c_str();
+
+ std::string const& compileCommand =
+ this->Makefile->GetRequiredDefinition("CMAKE_Swift_COMPILE_OBJECT");
+ cmList compileCmds(compileCommand);
+
+ auto rulePlaceholderExpander =
+ this->GetLocalGenerator()->CreateRulePlaceholderExpander();
+
+ for (cmSourceFile const* sf : moduleSourceFiles) {
+ std::string const sourceFilename = this->GetCompiledSourceNinjaPath(sf);
+ std::string objectFilename = moduleObjectFilename;
+
+ if (!singleOutput) {
+ // If it's not single-output, each source file gets a separate object
+ objectFilename = this->GetObjectFilePath(sf, outputConfig);
+ }
+ compileObjectVars.Objects = objectFilename.c_str();
+
+ for (std::string& cmd : compileCmds) {
+ rulePlaceholderExpander->ExpandRuleVariables(this->GetLocalGenerator(),
+ cmd, compileObjectVars);
+ }
+
+ std::string commandLine = this->GetLocalGenerator()->BuildCommandLine(
+ compileCmds, outputConfig, outputConfig);
+
+ this->GetGlobalGenerator()->AddCXXCompileCommand(
+ commandLine, sourceFilename, objectFilename);
+ }
+}
+
void cmNinjaTargetGenerator::AdditionalCleanFiles(const std::string& config)
{
if (cmValue prop_value =
diff --git a/Source/cmNinjaTargetGenerator.h b/Source/cmNinjaTargetGenerator.h
index b55c460..f081117 100644
--- a/Source/cmNinjaTargetGenerator.h
+++ b/Source/cmNinjaTargetGenerator.h
@@ -195,6 +195,12 @@ protected:
std::string const& targetCompilePdb, std::string const& targetPdb,
std::string const& outputConfig, WithScanning withScanning);
+ void ExportSwiftObjectCompileCommand(
+ std::vector<cmSourceFile const*> const& moduleSourceFiles,
+ std::string const& moduleObjectFilename, std::string const& flags,
+ std::string const& defines, std::string const& includes,
+ std::string const& outputConfig, bool singleOutput);
+
void AdditionalCleanFiles(const std::string& config);
cmNinjaDeps GetObjects(const std::string& config) const;