Commit 2d3aa942 authored by Brad King's avatar Brad King
Browse files

cmGlobalGenerator: Allow FindMakeProgram to fail

Revise its signature to return `bool` so that it can fail and abort
configuration early.
parent 7aa99619
Pipeline #31893 passed with stage
......@@ -269,12 +269,13 @@ bool cmGlobalGenerator::IsExportedTargetsFile(
}
// Find the make program for the generator, required for try compiles
void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
{
if (this->FindMakeProgramFile.empty()) {
cmSystemTools::Error(
"Generator implementation error, "
"all generators must specify this->FindMakeProgramFile");
return false;
}
if (!mf->GetDefinition("CMAKE_MAKE_PROGRAM") ||
cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
......@@ -292,7 +293,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
<< "probably need to select a different build tool.";
cmSystemTools::Error(err.str().c_str());
cmSystemTools::SetFatalErrorOccured();
return;
return false;
}
std::string makeProgram = mf->GetRequiredDefinition("CMAKE_MAKE_PROGRAM");
// if there are spaces in the make program use short path
......@@ -311,6 +312,7 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf)
mf->AddCacheDefinition("CMAKE_MAKE_PROGRAM", makeProgram.c_str(),
"make program", cmStateEnums::FILEPATH);
}
return true;
}
bool cmGlobalGenerator::CheckLanguages(
......@@ -426,7 +428,9 @@ void cmGlobalGenerator::EnableLanguage(
mf->AddDefinition("CMAKE_PLATFORM_INFO_DIR", rootBin.c_str());
// find and make sure CMAKE_MAKE_PROGRAM is defined
this->FindMakeProgram(mf);
if (!this->FindMakeProgram(mf)) {
return;
}
if (!this->CheckLanguages(languages, mf)) {
return;
......
......@@ -250,7 +250,7 @@ public:
/*
* Determine what program to use for building the project.
*/
virtual void FindMakeProgram(cmMakefile*);
virtual bool FindMakeProgram(cmMakefile*);
///! Find a target by name by searching the local generators.
cmTarget* FindTarget(const std::string& name,
......
......@@ -73,7 +73,7 @@ void cmGlobalGhsMultiGenerator::EnableLanguage(
this->cmGlobalGenerator::EnableLanguage(l, mf, optional);
}
void cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* mf)
{
// The GHS generator knows how to lookup its build tool
// directly instead of needing a helper module to do it, so we
......@@ -82,6 +82,7 @@ void cmGlobalGhsMultiGenerator::FindMakeProgram(cmMakefile* mf)
mf->AddDefinition("CMAKE_MAKE_PROGRAM",
this->GetGhsBuildCommand().c_str());
}
return true;
}
std::string const& cmGlobalGhsMultiGenerator::GetGhsBuildCommand()
......
......@@ -57,7 +57,7 @@ public:
/*
* Determine what program to use for building the project.
*/
virtual void FindMakeProgram(cmMakefile*);
bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
cmGeneratedFileStream* GetBuildFileStream()
{
......
......@@ -553,9 +553,11 @@ void cmGlobalNinjaGenerator::Generate()
this->CloseBuildFileStream();
}
void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
{
this->cmGlobalGenerator::FindMakeProgram(mf);
if (!this->cmGlobalGenerator::FindMakeProgram(mf)) {
return false;
}
if (const char* ninjaCommand = mf->GetDefinition("CMAKE_MAKE_PROGRAM")) {
this->NinjaCommand = ninjaCommand;
std::vector<std::string> command;
......@@ -567,6 +569,7 @@ void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf)
this->NinjaVersion = cmSystemTools::TrimWhitespace(version);
this->CheckNinjaFeatures();
}
return true;
}
void cmGlobalNinjaGenerator::CheckNinjaFeatures()
......
......@@ -357,7 +357,7 @@ protected:
private:
std::string GetEditCacheCommand() const CM_OVERRIDE;
void FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
void CheckNinjaFeatures();
bool CheckLanguages(std::vector<std::string> const& languages,
cmMakefile* mf) const CM_OVERRIDE;
......
......@@ -357,11 +357,14 @@ cmGlobalVisualStudio10Generator::GetPlatformToolsetHostArchitecture() const
return CM_NULLPTR;
}
void cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalVisualStudio10Generator::FindMakeProgram(cmMakefile* mf)
{
this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf);
if (!this->cmGlobalVisualStudio8Generator::FindMakeProgram(mf)) {
return false;
}
mf->AddDefinition("CMAKE_VS_MSBUILD_COMMAND",
this->GetMSBuildCommand().c_str());
return true;
}
std::string const& cmGlobalVisualStudio10Generator::GetMSBuildCommand()
......
......@@ -84,7 +84,7 @@ public:
virtual const char* GetToolsVersion() { return "4.0"; }
virtual void FindMakeProgram(cmMakefile*);
bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
static std::string GetInstalledNsightTegraVersion();
......
......@@ -123,11 +123,14 @@ void cmGlobalVisualStudio7Generator::EnableLanguage(
}
}
void cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalVisualStudio7Generator::FindMakeProgram(cmMakefile* mf)
{
this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf);
if (!this->cmGlobalVisualStudioGenerator::FindMakeProgram(mf)) {
return false;
}
mf->AddDefinition("CMAKE_VS_DEVENV_COMMAND",
this->GetDevEnvCommand().c_str());
return true;
}
std::string const& cmGlobalVisualStudio7Generator::GetDevEnvCommand()
......
......@@ -91,7 +91,7 @@ public:
const char* GetIntelProjectVersion();
virtual void FindMakeProgram(cmMakefile*);
bool FindMakeProgram(cmMakefile* mf) CM_OVERRIDE;
/** Is the Microsoft Assembler enabled? */
bool IsMasmEnabled() const { return this->MasmEnabled; }
......
......@@ -395,7 +395,7 @@ void cmGlobalVisualStudioGenerator::ComputeVSTargetDepends(
}
}
void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
{
// Visual Studio generators know how to lookup their build tool
// directly instead of needing a helper module to do it, so we
......@@ -403,6 +403,7 @@ void cmGlobalVisualStudioGenerator::FindMakeProgram(cmMakefile* mf)
if (cmSystemTools::IsOff(mf->GetDefinition("CMAKE_MAKE_PROGRAM"))) {
mf->AddDefinition("CMAKE_MAKE_PROGRAM", this->GetVSMakeProgram().c_str());
}
return true;
}
std::string cmGlobalVisualStudioGenerator::GetUtilityDepend(
......
......@@ -102,7 +102,7 @@ public:
};
class OrderedTargetDependSet;
virtual void FindMakeProgram(cmMakefile*);
bool FindMakeProgram(cmMakefile*) CM_OVERRIDE;
virtual std::string ExpandCFGIntDir(const std::string& str,
const std::string& config) const;
......
......@@ -182,7 +182,7 @@ cmGlobalGenerator* cmGlobalXCodeGenerator::Factory::CreateGlobalGenerator(
#endif
}
void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
bool cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
{
// The Xcode generator knows how to lookup its build tool
// directly instead of needing a helper module to do it, so we
......@@ -191,6 +191,7 @@ void cmGlobalXCodeGenerator::FindMakeProgram(cmMakefile* mf)
mf->AddDefinition("CMAKE_MAKE_PROGRAM",
this->GetXcodeBuildCommand().c_str());
}
return true;
}
std::string const& cmGlobalXCodeGenerator::GetXcodeBuildCommand()
......
......@@ -58,7 +58,7 @@ public:
const std::string& suffix,
std::string& dir);
virtual void FindMakeProgram(cmMakefile*);
bool FindMakeProgram(cmMakefile*) CM_OVERRIDE;
///! What is the configurations directory variable called?
virtual const char* GetCMakeCFGIntDir() const;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment