From f0a23aa3dbbe2751bbb4969e1371380561b566ee Mon Sep 17 00:00:00 2001 From: Brad King Date: Wed, 21 Sep 2016 13:52:01 -0400 Subject: Ninja: Refactor Fortran rejection logic Delay rejection of Fortran until after we've determined the version of the `ninja` tool to be used. This will later allow us to enable Fortran support based on the version of ninja. While at it, make the rejection an immediate fatal error. Also provide a stack trace so readers know what code tried to enable Fortran. --- Source/cmGlobalGenerator.cxx | 10 ++++++++++ Source/cmGlobalGenerator.h | 2 ++ Source/cmGlobalNinjaGenerator.cxx | 16 +++++++++++++--- Source/cmGlobalNinjaGenerator.h | 2 ++ 4 files changed, 27 insertions(+), 3 deletions(-) diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index 4772474..95747f2 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -319,6 +319,12 @@ void cmGlobalGenerator::FindMakeProgram(cmMakefile* mf) } } +bool cmGlobalGenerator::CheckLanguages( + std::vector const& /* languages */, cmMakefile* /* mf */) const +{ + return true; +} + // enable the given language // // The following files are loaded in this order: @@ -428,6 +434,10 @@ void cmGlobalGenerator::EnableLanguage( // find and make sure CMAKE_MAKE_PROGRAM is defined this->FindMakeProgram(mf); + if (!this->CheckLanguages(languages, mf)) { + return; + } + // try and load the CMakeSystem.cmake if it is there std::string fpath = rootBin; bool const readCMakeSystem = !mf->GetDefinition("CMAKE_SYSTEM_LOADED"); diff --git a/Source/cmGlobalGenerator.h b/Source/cmGlobalGenerator.h index f7b2e59..7bc389d 100644 --- a/Source/cmGlobalGenerator.h +++ b/Source/cmGlobalGenerator.h @@ -381,6 +381,8 @@ protected: void SetLanguageEnabledFlag(const std::string& l, cmMakefile* mf); void SetLanguageEnabledMaps(const std::string& l, cmMakefile* mf); void FillExtensionToLanguageMap(const std::string& l, cmMakefile* mf); + virtual bool CheckLanguages(std::vector const& languages, + cmMakefile* mf) const; virtual void PrintCompilerAdvice(std::ostream& os, std::string const& lang, const char* envVar) const; diff --git a/Source/cmGlobalNinjaGenerator.cxx b/Source/cmGlobalNinjaGenerator.cxx index b913621..8146ea5 100644 --- a/Source/cmGlobalNinjaGenerator.cxx +++ b/Source/cmGlobalNinjaGenerator.cxx @@ -561,12 +561,22 @@ void cmGlobalNinjaGenerator::FindMakeProgram(cmMakefile* mf) } } +bool cmGlobalNinjaGenerator::CheckLanguages( + std::vector const& languages, cmMakefile* mf) const +{ + if (std::find(languages.begin(), languages.end(), "Fortran") != + languages.end()) { + mf->IssueMessage(cmake::FATAL_ERROR, + "The Ninja generator does not support Fortran yet."); + cmSystemTools::SetFatalErrorOccured(); + return false; + } + return true; +} + void cmGlobalNinjaGenerator::EnableLanguage( std::vector const& langs, cmMakefile* mf, bool optional) { - if (std::find(langs.begin(), langs.end(), "Fortran") != langs.end()) { - cmSystemTools::Error("The Ninja generator does not support Fortran yet."); - } this->cmGlobalGenerator::EnableLanguage(langs, mf, optional); for (std::vector::const_iterator l = langs.begin(); l != langs.end(); ++l) { diff --git a/Source/cmGlobalNinjaGenerator.h b/Source/cmGlobalNinjaGenerator.h index 0201685..ac7a6b1 100644 --- a/Source/cmGlobalNinjaGenerator.h +++ b/Source/cmGlobalNinjaGenerator.h @@ -355,6 +355,8 @@ protected: private: std::string GetEditCacheCommand() const CM_OVERRIDE; void FindMakeProgram(cmMakefile* mf) CM_OVERRIDE; + bool CheckLanguages(std::vector const& languages, + cmMakefile* mf) const CM_OVERRIDE; void OpenBuildFileStream(); void CloseBuildFileStream(); -- cgit v0.12