From af1c727a1fb188365a5ad285f47a37db401e85d5 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 20 Dec 2002 11:20:49 -0500 Subject: [PATCH] ENH: add a check to make sure cmake can find the c or C++ compiler for trycompile --- Source/cmGlobalUnixMakefileGenerator.cxx | 37 ++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx index 35bf3bf97..823d742e0 100644 --- a/Source/cmGlobalUnixMakefileGenerator.cxx +++ b/Source/cmGlobalUnixMakefileGenerator.cxx @@ -30,6 +30,43 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, { mf->AddDefinition("CMAKE_CFG_INTDIR","."); this->cmGlobalGenerator::EnableLanguage(lang, mf); + if(!lang) + { + lang = "CXX"; + } + if(lang[0] == 'C') + { + if(!mf->GetDefinition("CMAKE_C_COMPILER")) + { + cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage"); + return; + } + std::string path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_C_COMPILER")); + if(path.size() == 0) + { + std::string message = "your C compiler: "; + message += mf->GetDefinition("CMAKE_C_COMPILER"); + message += " was not found in your path. " + "For CMake to correctly use try compile commands, the compiler must " + "be in your path. Please add the compiler to your PATH environment," + " and re-run CMake."; + cmSystemTools::Error(message.c_str()); + } + if(strcmp(lang, "CXX") == 0) + { + path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_CXX_COMPILER")); + if(path.size() == 0) + { + std::string message = "your C++ compiler: "; + message += mf->GetDefinition("CMAKE_CXX_COMPILER"); + message += " was not found in your path. " + "For CMake to correctly use try compile commands, the compiler must " + "be in your path. Please add the compiler to your PATH environment," + " and re-run CMake."; + cmSystemTools::Error(message.c_str()); + } + } + } } ///! Create a local generator appropriate to this Global Generator