summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
Diffstat (limited to 'Source')
-rw-r--r--Source/CMakeVersion.cmake2
-rw-r--r--Source/CPack/cpack.cxx4
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx13
-rw-r--r--Source/cmGlobalNinjaGenerator.h1
-rw-r--r--Source/cmGlobalXCodeGenerator.cxx43
-rw-r--r--Source/cmVSSetupHelper.cxx23
-rw-r--r--Source/cmake.cxx16
-rw-r--r--Source/cmake.h13
-rw-r--r--Source/cmakemain.cxx32
9 files changed, 105 insertions, 42 deletions
diff --git a/Source/CMakeVersion.cmake b/Source/CMakeVersion.cmake
index 2735e49..d08660a 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 25)
-set(CMake_VERSION_PATCH 20221024)
+set(CMake_VERSION_PATCH 20221027)
#set(CMake_VERSION_RC 0)
set(CMake_VERSION_IS_DIRTY 0)
diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx
index 631bfd9..f06946b 100644
--- a/Source/CPack/cpack.cxx
+++ b/Source/CPack/cpack.cxx
@@ -173,8 +173,8 @@ int main(int argc, char const* const* argv)
CommandArgument{ "--debug", CommandArgument::Values::Zero, debugLambda },
CommandArgument{ "--config", CommandArgument::Values::One,
CommandArgument::setToValue(cpackConfigFile) },
- CommandArgument{ "--trace", CommandArgument::Values::One, traceLambda },
- CommandArgument{ "--trace-expand", CommandArgument::Values::One,
+ CommandArgument{ "--trace", CommandArgument::Values::Zero, traceLambda },
+ CommandArgument{ "--trace-expand", CommandArgument::Values::Zero,
traceExpandLambda },
CommandArgument{ "-C", CommandArgument::Values::One,
CommandArgument::setToValue(cpackBuildConfig) },
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index c326ca6..077de42 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -1030,19 +1030,6 @@ bool cmGlobalNinjaGenerator::OpenBuildFileStreams()
return false;
}
- // New buffer size 8 MiB
- constexpr auto buildFileStreamBufferSize = 8 * 1024 * 1024;
-
- // Ensure the buffer is allocated
- if (!this->BuildFileStreamBuffer) {
- this->BuildFileStreamBuffer =
- cm::make_unique<char[]>(buildFileStreamBufferSize);
- }
-
- // Enlarge the internal buffer of the `BuildFileStream`
- this->BuildFileStream->rdbuf()->pubsetbuf(this->BuildFileStreamBuffer.get(),
- buildFileStreamBufferSize);
-
// Write a comment about this file.
*this->BuildFileStream
<< "# This file contains all the build statements describing the\n"
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index dc4f444..defa264 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -531,7 +531,6 @@ private:
/// The file containing the build statement. (the relationship of the
/// compilation DAG).
std::unique_ptr<cmGeneratedFileStream> BuildFileStream;
- std::unique_ptr<char[]> BuildFileStreamBuffer;
/// The file containing the rule statements. (The action attached to each
/// edge of the compilation DAG).
std::unique_ptr<cmGeneratedFileStream> RulesFileStream;
diff --git a/Source/cmGlobalXCodeGenerator.cxx b/Source/cmGlobalXCodeGenerator.cxx
index bc703e5..98dea3a 100644
--- a/Source/cmGlobalXCodeGenerator.cxx
+++ b/Source/cmGlobalXCodeGenerator.cxx
@@ -2387,7 +2387,20 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
gtgt->GetName());
return;
}
- std::string const& langForPreprocessor = llang;
+
+ // Choose a language to use for target-wide preprocessor definitions.
+ static const char* ppLangs[] = { "CXX", "C", "OBJCXX", "OBJC" };
+ std::string langForPreprocessor;
+ if (cm::contains(ppLangs, llang)) {
+ langForPreprocessor = llang;
+ } else {
+ for (const char* l : ppLangs) {
+ if (languages.count(l)) {
+ langForPreprocessor = l;
+ break;
+ }
+ }
+ }
if (gtgt->IsIPOEnabled(llang, configName)) {
const char* ltoValue =
@@ -2404,13 +2417,8 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
// Add preprocessor definitions for this target and configuration.
BuildObjectListOrString ppDefs(this, true);
- if (languages.count("Swift")) {
- // FIXME: Xcode warns that Swift does not support definition values.
- // C/CXX sources mixed in Swift targets will not see CMAKE_INTDIR.
- } else {
- this->AppendDefines(
- ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
- }
+ this->AppendDefines(
+ ppDefs, "CMAKE_INTDIR=\"$(CONFIGURATION)$(EFFECTIVE_PLATFORM_NAME)\"");
if (const std::string* exportMacro = gtgt->GetExportMacro()) {
// Add the export symbol definition for shared library objects.
this->AppendDefines(ppDefs, exportMacro->c_str());
@@ -2424,15 +2432,28 @@ void cmGlobalXCodeGenerator::CreateBuildSettings(cmGeneratorTarget* gtgt,
buildSettings->AddAttribute("GCC_PREPROCESSOR_DEFINITIONS",
ppDefs.CreateList());
if (languages.count("Swift")) {
+ // Swift uses a separate attribute for definitions.
+ std::vector<std::string> targetSwiftDefines;
+ gtgt->GetCompileDefinitions(targetSwiftDefines, configName, "Swift");
+ // Remove the '=value' parts, as Swift does not support them.
+ std::for_each(targetSwiftDefines.begin(), targetSwiftDefines.end(),
+ [](std::string& def) {
+ std::string::size_type pos = def.find('=');
+ if (pos != std::string::npos) {
+ def.erase(pos);
+ }
+ });
if (this->XcodeVersion < 80) {
std::string defineString;
- std::set<std::string> defines(targetDefines.begin(),
- targetDefines.end());
+ std::set<std::string> defines(targetSwiftDefines.begin(),
+ targetSwiftDefines.end());
this->CurrentLocalGenerator->JoinDefines(defines, defineString, "Swift");
cflags["Swift"] += " " + defineString;
} else {
+ BuildObjectListOrString swiftDefs(this, true);
+ this->AppendDefines(swiftDefs, targetSwiftDefines);
buildSettings->AddAttribute("SWIFT_ACTIVE_COMPILATION_CONDITIONS",
- ppDefs.CreateList());
+ swiftDefs.CreateList());
}
}
diff --git a/Source/cmVSSetupHelper.cxx b/Source/cmVSSetupHelper.cxx
index 1a3e72e..8764f21 100644
--- a/Source/cmVSSetupHelper.cxx
+++ b/Source/cmVSSetupHelper.cxx
@@ -300,13 +300,32 @@ bool cmVSSetupAPIHelper::IsEWDKEnabled()
return false;
}
+#if !defined(CMAKE_BOOTSTRAP)
+namespace {
+std::string FindVsWhereCommand()
+{
+ std::string vswhere;
+ static const char* programFiles[] = { "ProgramFiles(x86)", "ProgramFiles" };
+ for (const char* pf : programFiles) {
+ if (cmSystemTools::GetEnv(pf, vswhere)) {
+ vswhere += "/Microsoft Visual Studio/Installer/vswhere.exe";
+ if (cmSystemTools::FileExists(vswhere)) {
+ return vswhere;
+ }
+ }
+ }
+ vswhere = "vswhere.exe";
+ return vswhere;
+}
+}
+#endif
+
bool cmVSSetupAPIHelper::EnumerateVSInstancesWithVswhere(
std::vector<VSInstanceInfo>& VSInstances)
{
#if !defined(CMAKE_BOOTSTRAP)
// Construct vswhere command to get installed VS instances in JSON format
- std::string vswhereExe = getenv("ProgramFiles(x86)") +
- std::string(R"(\Microsoft Visual Studio\Installer\vswhere.exe)");
+ std::string vswhereExe = FindVsWhereCommand();
std::vector<std::string> vswhereCmd = { vswhereExe, "-format", "json" };
// Execute vswhere command and capture JSON output
diff --git a/Source/cmake.cxx b/Source/cmake.cxx
index 73b8e88..c068894 100644
--- a/Source/cmake.cxx
+++ b/Source/cmake.cxx
@@ -3742,7 +3742,8 @@ std::function<int()> cmake::BuildWorkflowStep(
}
#endif
-int cmake::Workflow(const std::string& presetName, bool listPresets)
+int cmake::Workflow(const std::string& presetName,
+ WorkflowListPresets listPresets, WorkflowFresh fresh)
{
#ifndef CMAKE_BOOTSTRAP
this->SetHomeDirectory(cmSystemTools::GetCurrentWorkingDirectory());
@@ -3757,7 +3758,7 @@ int cmake::Workflow(const std::string& presetName, bool listPresets)
return 1;
}
- if (listPresets) {
+ if (listPresets == WorkflowListPresets::Yes) {
settingsFile.PrintWorkflowPresetList();
return 0;
}
@@ -3824,10 +3825,13 @@ int cmake::Workflow(const std::string& presetName, bool listPresets)
if (!configurePreset) {
return 1;
}
- steps.emplace_back(
- stepNumber, "configure"_s, step.PresetName,
- this->BuildWorkflowStep({ cmSystemTools::GetCMakeCommand(),
- "--preset", step.PresetName }));
+ std::vector<std::string> args{ cmSystemTools::GetCMakeCommand(),
+ "--preset", step.PresetName };
+ if (fresh == WorkflowFresh::Yes) {
+ args.emplace_back("--fresh");
+ }
+ steps.emplace_back(stepNumber, "configure"_s, step.PresetName,
+ this->BuildWorkflowStep(args));
} break;
case cmCMakePresetsGraph::WorkflowPreset::WorkflowStep::Type::Build: {
auto const* buildPreset = this->FindPresetForWorkflow(
diff --git a/Source/cmake.h b/Source/cmake.h
index 5b5425c..4e7bb54 100644
--- a/Source/cmake.h
+++ b/Source/cmake.h
@@ -611,7 +611,18 @@ public:
bool Open(const std::string& dir, bool dryRun);
//! run the --workflow option
- int Workflow(const std::string& presetName, bool listPresets);
+ enum class WorkflowListPresets
+ {
+ No,
+ Yes,
+ };
+ enum class WorkflowFresh
+ {
+ No,
+ Yes,
+ };
+ int Workflow(const std::string& presetName, WorkflowListPresets listPresets,
+ WorkflowFresh fresh);
void UnwatchUnusedCli(const std::string& var);
void WatchUnusedCli(const std::string& var);
diff --git a/Source/cmakemain.cxx b/Source/cmakemain.cxx
index 928c1ba..43bebc1 100644
--- a/Source/cmakemain.cxx
+++ b/Source/cmakemain.cxx
@@ -917,8 +917,11 @@ int do_workflow(int ac, char const* const* av)
std::cerr << "This cmake does not support --workflow\n";
return -1;
#else
+ using WorkflowListPresets = cmake::WorkflowListPresets;
+ using WorkflowFresh = cmake::WorkflowFresh;
std::string presetName;
- bool listPresets = false;
+ auto listPresets = WorkflowListPresets::No;
+ auto fresh = WorkflowFresh::No;
using CommandArgument =
cmCommandLineArgument<bool(std::string const& value)>;
@@ -927,7 +930,15 @@ int do_workflow(int ac, char const* const* av)
CommandArgument{ "--preset", CommandArgument::Values::One,
CommandArgument::setToValue(presetName) },
CommandArgument{ "--list-presets", CommandArgument::Values::Zero,
- CommandArgument::setToTrue(listPresets) }
+ [&listPresets](const std::string&) -> bool {
+ listPresets = WorkflowListPresets::Yes;
+ return true;
+ } },
+ CommandArgument{ "--fresh", CommandArgument::Values::Zero,
+ [&fresh](const std::string&) -> bool {
+ fresh = WorkflowFresh::Yes;
+ return true;
+ } },
};
std::vector<std::string> inputArgs;
@@ -949,14 +960,25 @@ int do_workflow(int ac, char const* const* av)
}
if (!(matched && parsed)) {
if (!matched) {
+ presetName.clear();
+ listPresets = WorkflowListPresets::No;
std::cerr << "Unknown argument " << arg << std::endl;
}
break;
}
}
- if (presetName.empty() && !listPresets) {
- std::cerr << "TODO: Usage\n";
+ if (presetName.empty() && listPresets == WorkflowListPresets::No) {
+ /* clang-format off */
+ std::cerr <<
+ "Usage: cmake --workflow [options]\n"
+ "Options:\n"
+ " --preset <preset> = Workflow preset to execute.\n"
+ " --list-presets = List available workflow presets.\n"
+ " --fresh = Configure a fresh build tree, removing any "
+ "existing cache file.\n"
+ ;
+ /* clang-format on */
return 1;
}
@@ -969,7 +991,7 @@ int do_workflow(int ac, char const* const* av)
cmakemainProgressCallback(msg, prog, &cm);
});
- return cm.Workflow(presetName, listPresets);
+ return cm.Workflow(presetName, listPresets, fresh);
#endif
}