summaryrefslogtreecommitdiffstats
path: root/Source
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2020-02-28 16:31:58 (GMT)
committerKitware Robot <kwrobot@kitware.com>2020-02-28 16:32:07 (GMT)
commitf18c72815b78d230957b6862faf4a136edcd7b9c (patch)
tree60ece43430a314644088cff8fc45ca9614f2e865 /Source
parent9afd5f0d3296194694fb05232a4da17b059b77d8 (diff)
parentc794b70f194bcff6f06971767f18473da13950e3 (diff)
downloadCMake-f18c72815b78d230957b6862faf4a136edcd7b9c.zip
CMake-f18c72815b78d230957b6862faf4a136edcd7b9c.tar.gz
CMake-f18c72815b78d230957b6862faf4a136edcd7b9c.tar.bz2
Merge topic 'ninja-multi-variable-shuffle-again'
c794b70f19 Ninja Multi-Config: Always generate build.ninja 9590c3a400 Generator: Don't allow Ninja Multi-Config variables on other generators 7a63dafafb Ninja Multi-Config: Remove "NMC" from variable names Acked-by: Kitware Robot <kwrobot@kitware.com> Merge-request: !4403
Diffstat (limited to 'Source')
-rw-r--r--Source/cmGlobalGenerator.cxx35
-rw-r--r--Source/cmGlobalGenerator.h7
-rw-r--r--Source/cmGlobalNinjaGenerator.cxx30
-rw-r--r--Source/cmGlobalNinjaGenerator.h4
4 files changed, 59 insertions, 17 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx
index ff6ad9d..0404715 100644
--- a/Source/cmGlobalGenerator.cxx
+++ b/Source/cmGlobalGenerator.cxx
@@ -1361,8 +1361,43 @@ void cmGlobalGenerator::ComputeBuildFileGenerators()
}
}
+bool cmGlobalGenerator::UnsupportedVariableIsDefined(const std::string& name,
+ bool supported) const
+{
+ if (!supported && this->Makefiles.front()->GetDefinition(name)) {
+ std::ostringstream e;
+ /* clang-format off */
+ e <<
+ "Generator\n"
+ " " << this->GetName() << "\n"
+ "does not support variable\n"
+ " " << name << "\n"
+ "but it has been specified."
+ ;
+ /* clang-format on */
+ this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR, e.str());
+ return true;
+ }
+
+ return false;
+}
+
bool cmGlobalGenerator::Compute()
{
+ // Make sure unsupported variables are not used.
+ if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_BUILD_TYPE",
+ this->SupportsDefaultBuildType())) {
+ return false;
+ }
+ if (this->UnsupportedVariableIsDefined("CMAKE_CROSS_CONFIGS",
+ this->SupportsCrossConfigs())) {
+ return false;
+ }
+ if (this->UnsupportedVariableIsDefined("CMAKE_DEFAULT_CONFIGS",
+ this->SupportsDefaultConfigs())) {
+ return false;
+ }
+
// Some generators track files replaced during the Generate.
// Start with an empty vector:
this->FilesReplacedDuringGenerate.clear();
diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h
index 0e7e03d..ba997b2 100644
--- a/Source/cmGlobalGenerator.h
+++ b/Source/cmGlobalGenerator.h
@@ -455,6 +455,10 @@ public:
/** Generate an <output>.rule file path for a given command output. */
virtual std::string GenerateRuleFile(std::string const& output) const;
+ virtual bool SupportsDefaultBuildType() const { return false; }
+ virtual bool SupportsCrossConfigs() const { return false; }
+ virtual bool SupportsDefaultConfigs() const { return false; }
+
static std::string EscapeJSON(const std::string& s);
void ProcessEvaluationFiles();
@@ -674,6 +678,9 @@ private:
virtual const char* GetBuildIgnoreErrorsFlag() const { return nullptr; }
+ bool UnsupportedVariableIsDefined(const std::string& name,
+ bool supported) const;
+
// Cache directory content and target files to be built.
struct DirectoryContent
{
diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx
index 12a5167..86b1e0b 100644
--- a/Source/cmGlobalNinjaGenerator.cxx
+++ b/Source/cmGlobalNinjaGenerator.cxx
@@ -2490,8 +2490,7 @@ bool cmGlobalNinjaMultiGenerator::OpenBuildFileStreams()
return false;
}
*this->DefaultFileStream
- << "# This file is a convenience file generated by\n"
- << "# CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG.\n\n"
+ << "# Build using rules for '" << this->DefaultFileConfig << "'.\n\n"
<< "include " << GetNinjaImplFilename(this->DefaultFileConfig) << "\n\n";
}
@@ -2608,9 +2607,6 @@ bool cmGlobalNinjaMultiGenerator::InspectConfigTypeVariables()
std::string cmGlobalNinjaMultiGenerator::GetDefaultBuildConfig() const
{
- if (this->DefaultFileConfig.empty()) {
- return "Debug";
- }
return "";
}
@@ -2626,12 +2622,14 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
std::set<std::string> configs(configsVec.cbegin(), configsVec.cend());
this->DefaultFileConfig =
- state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG");
- if (!this->DefaultFileConfig.empty() &&
- !configs.count(this->DefaultFileConfig)) {
+ state.GetSafeCacheEntryValue("CMAKE_DEFAULT_BUILD_TYPE");
+ if (this->DefaultFileConfig.empty()) {
+ this->DefaultFileConfig = configsVec.front();
+ }
+ if (!configs.count(this->DefaultFileConfig)) {
std::ostringstream msg;
msg << "The configuration specified by "
- << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG (" << this->DefaultFileConfig
+ << "CMAKE_DEFAULT_BUILD_TYPE (" << this->DefaultFileConfig
<< ") is not present in CMAKE_CONFIGURATION_TYPES";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
@@ -2639,12 +2637,12 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
}
std::vector<std::string> crossConfigsVec;
- cmExpandList(state.GetSafeCacheEntryValue("CMAKE_NMC_CROSS_CONFIGS"),
+ cmExpandList(state.GetSafeCacheEntryValue("CMAKE_CROSS_CONFIGS"),
crossConfigsVec);
auto crossConfigs = ListSubsetWithAll(configs, configs, crossConfigsVec);
if (!crossConfigs) {
std::ostringstream msg;
- msg << "CMAKE_NMC_CROSS_CONFIGS is not a subset of "
+ msg << "CMAKE_CROSS_CONFIGS is not a subset of "
<< "CMAKE_CONFIGURATION_TYPES";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
@@ -2653,7 +2651,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
this->CrossConfigs = *crossConfigs;
auto defaultConfigsString =
- state.GetSafeCacheEntryValue("CMAKE_NMC_DEFAULT_CONFIGS");
+ state.GetSafeCacheEntryValue("CMAKE_DEFAULT_CONFIGS");
if (defaultConfigsString.empty()) {
defaultConfigsString = this->DefaultFileConfig;
}
@@ -2661,9 +2659,8 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
defaultConfigsString != this->DefaultFileConfig &&
(this->DefaultFileConfig.empty() || this->CrossConfigs.empty())) {
std::ostringstream msg;
- msg << "CMAKE_NMC_DEFAULT_CONFIGS cannot be used without "
- << "CMAKE_NMC_DEFAULT_BUILD_FILE_CONFIG or "
- << "CMAKE_NMC_CROSS_CONFIGS";
+ msg << "CMAKE_DEFAULT_CONFIGS cannot be used without "
+ << "CMAKE_DEFAULT_BUILD_TYPE or CMAKE_CROSS_CONFIGS";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
return false;
@@ -2677,8 +2674,7 @@ bool cmGlobalNinjaMultiGenerator::ReadCacheEntriesForBuild(
this->CrossConfigs, defaultConfigsVec);
if (!defaultConfigs) {
std::ostringstream msg;
- msg << "CMAKE_NMC_DEFAULT_CONFIGS is not a subset of "
- << "CMAKE_NMC_CROSS_CONFIGS";
+ msg << "CMAKE_DEFAULT_CONFIGS is not a subset of CMAKE_CROSS_CONFIGS";
this->GetCMakeInstance()->IssueMessage(MessageType::FATAL_ERROR,
msg.str());
return false;
diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h
index 3db8356..5668dd1 100644
--- a/Source/cmGlobalNinjaGenerator.h
+++ b/Source/cmGlobalNinjaGenerator.h
@@ -640,6 +640,10 @@ public:
bool ReadCacheEntriesForBuild(const cmState& state) override;
+ bool SupportsDefaultBuildType() const override { return true; }
+ bool SupportsCrossConfigs() const override { return true; }
+ bool SupportsDefaultConfigs() const override { return true; }
+
protected:
bool OpenBuildFileStreams() override;
void CloseBuildFileStreams() override;