diff options
author | Bill Hoffman <bill.hoffman@kitware.com> | 2003-01-21 17:50:48 (GMT) |
---|---|---|
committer | Bill Hoffman <bill.hoffman@kitware.com> | 2003-01-21 17:50:48 (GMT) |
commit | 2f4ea98a4cf35b0aa6ced86c98c4b96984ef4fb7 (patch) | |
tree | 2e7ba2c7d45537691296edc194f605f623bcc3a7 /Source | |
parent | 110bc04bd0125ef746ad8ea239c632831f7c5075 (diff) | |
download | CMake-2f4ea98a4cf35b0aa6ced86c98c4b96984ef4fb7.zip CMake-2f4ea98a4cf35b0aa6ced86c98c4b96984ef4fb7.tar.gz CMake-2f4ea98a4cf35b0aa6ced86c98c4b96984ef4fb7.tar.bz2 |
add a fatal error, and make sure c and c++ compilers work before using them
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmGlobalGenerator.cxx | 6 | ||||
-rw-r--r-- | Source/cmGlobalUnixMakefileGenerator.cxx | 25 | ||||
-rw-r--r-- | Source/cmMakefile.cxx | 17 | ||||
-rw-r--r-- | Source/cmMessageCommand.cxx | 20 | ||||
-rw-r--r-- | Source/cmMessageCommand.h | 2 | ||||
-rw-r--r-- | Source/cmSystemTools.cxx | 5 | ||||
-rw-r--r-- | Source/cmSystemTools.h | 16 |
7 files changed, 72 insertions, 19 deletions
diff --git a/Source/cmGlobalGenerator.cxx b/Source/cmGlobalGenerator.cxx index edbed80..e5991e4 100644 --- a/Source/cmGlobalGenerator.cxx +++ b/Source/cmGlobalGenerator.cxx @@ -213,12 +213,14 @@ void cmGlobalGenerator::EnableLanguage(const char* lang, { if (!m_CMakeInstance->GetIsInTryCompile()) { + std::string ifpath = root + "/Modules/CMakeTestCCompiler.cmake"; + mf->ReadListFile(0,ifpath.c_str()); // for old versions of CMake ListFiles const char* versionValue = mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); if (atof(versionValue) <= 1.4) { - std::string ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake"; + ifpath = root + "/Modules/CMakeBackwardCompatibilityC.cmake"; mf->ReadListFile(0,ifpath.c_str()); } } @@ -227,6 +229,8 @@ void cmGlobalGenerator::EnableLanguage(const char* lang, { if (!m_CMakeInstance->GetIsInTryCompile()) { + std::string ifpath = root + "/Modules/CMakeTestCXXCompiler.cmake"; + mf->ReadListFile(0,ifpath.c_str()); // for old versions of CMake ListFiles const char* versionValue = mf->GetDefinition("CMAKE_BACKWARDS_COMPATIBILITY"); diff --git a/Source/cmGlobalUnixMakefileGenerator.cxx b/Source/cmGlobalUnixMakefileGenerator.cxx index 823d742..d11954e 100644 --- a/Source/cmGlobalUnixMakefileGenerator.cxx +++ b/Source/cmGlobalUnixMakefileGenerator.cxx @@ -41,11 +41,19 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, cmSystemTools::Error("CMAKE_C_COMPILER not set, after EnableLanguage"); return; } - std::string path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_C_COMPILER")); + const char* cc = mf->GetDefinition("CMAKE_C_COMPILER"); + std::string path = cmSystemTools::FindProgram(cc); if(path.size() == 0) { std::string message = "your C compiler: "; - message += mf->GetDefinition("CMAKE_C_COMPILER"); + if(cc) + { + message += cc; + } + else + { + message += "(NULL)"; + } 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," @@ -54,11 +62,20 @@ void cmGlobalUnixMakefileGenerator::EnableLanguage(const char* lang, } if(strcmp(lang, "CXX") == 0) { - path = cmSystemTools::FindProgram(mf->GetDefinition("CMAKE_CXX_COMPILER")); + const char* cxx = mf->GetDefinition("CMAKE_CXX_COMPILER"); + path = cmSystemTools::FindProgram(cxx); if(path.size() == 0) { std::string message = "your C++ compiler: "; - message += mf->GetDefinition("CMAKE_CXX_COMPILER"); + if(cxx) + { + message += cxx; + } + else + { + message += "(NULL)"; + } + 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," diff --git a/Source/cmMakefile.cxx b/Source/cmMakefile.cxx index 75878ce..a567f83 100644 --- a/Source/cmMakefile.cxx +++ b/Source/cmMakefile.cxx @@ -176,7 +176,7 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff) cmCommand* usedCommand = rm->Clone(); usedCommand->SetMakefile(this); bool keepCommand = false; - if(usedCommand->GetEnabled()) + if(usedCommand->GetEnabled() && !cmSystemTools::GetFatalErrorOccured()) { // if not running in inherit mode or // if the command is inherited then InitialPass it. @@ -208,12 +208,15 @@ bool cmMakefile::ExecuteCommand(const cmListFileFunction& lff) } else { - cmOStringStream error; - error << "Error in cmake code at\n" - << lff.m_FilePath << ":" << lff.m_Line << ":\n" - << "Unknown CMake command \"" << lff.m_Name.c_str() << "\"."; - cmSystemTools::Error(error.str().c_str()); - result = false; + if(!cmSystemTools::GetFatalErrorOccured()) + { + cmOStringStream error; + error << "Error in cmake code at\n" + << lff.m_FilePath << ":" << lff.m_Line << ":\n" + << "Unknown CMake command \"" << lff.m_Name.c_str() << "\"."; + cmSystemTools::Error(error.str().c_str()); + result = false; + } } return result; diff --git a/Source/cmMessageCommand.cxx b/Source/cmMessageCommand.cxx index c6e8e16..e1722be 100644 --- a/Source/cmMessageCommand.cxx +++ b/Source/cmMessageCommand.cxx @@ -28,6 +28,7 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args) std::vector<std::string>::const_iterator i = args.begin(); bool send_error = false; + bool fatal_error = false; bool status = false; if (*i == "SEND_ERROR") { @@ -36,11 +37,19 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args) } else { - if (*i == "STATUS") + if (*i == "STATUS") + { + status = true; + ++i; + } + else + { + if (*i == "FATAL_ERROR") { - status = true; - ++i; + fatal_error = true; + ++i; } + } } for(;i != args.end(); ++i) @@ -63,7 +72,10 @@ bool cmMessageCommand::InitialPass(std::vector<std::string> const& args) cmSystemTools::Message(message.c_str()); } } - + if(fatal_error) + { + cmSystemTools::SetFatalErrorOccured(); + } return true; } diff --git a/Source/cmMessageCommand.h b/Source/cmMessageCommand.h index a312edc..6ff5512 100644 --- a/Source/cmMessageCommand.h +++ b/Source/cmMessageCommand.h @@ -60,7 +60,7 @@ public: virtual const char* GetFullDocumentation() { return - "MESSAGE([SEND_ERROR | STATUS] \"message to display\"...)\n" + "MESSAGE([SEND_ERROR | STATUS | FATAL_ERROR] \"message to display\"...)\n" "The arguments are messages to display. If the first argument is SEND_ERROR then an error is raised. If the first argument is STATUS then the message is diaplyed in the progress line for the GUI"; } diff --git a/Source/cmSystemTools.cxx b/Source/cmSystemTools.cxx index 6b10ab2..4b71bf4 100644 --- a/Source/cmSystemTools.cxx +++ b/Source/cmSystemTools.cxx @@ -129,6 +129,7 @@ cmSystemTools::GetTime(void) bool cmSystemTools::s_RunCommandHideConsole = false; bool cmSystemTools::s_DisableRunCommandOutput = false; bool cmSystemTools::s_ErrorOccured = false; +bool cmSystemTools::s_FatalErrorOccured = false; bool cmSystemTools::s_DisableMessages = false; std::string cmSystemTools::s_Windows9xComspecSubstitute = "command.com"; @@ -1536,6 +1537,10 @@ std::string cmSystemTools::FindProgram(const char* name, const std::vector<std::string>& userPaths, bool no_system_path) { + if(!name) + { + return ""; + } // See if the executable exists as written. if(cmSystemTools::FileExists(name) && !cmSystemTools::FileIsDirectory(name)) diff --git a/Source/cmSystemTools.h b/Source/cmSystemTools.h index 167926a..9c3d2ae 100644 --- a/Source/cmSystemTools.h +++ b/Source/cmSystemTools.h @@ -162,12 +162,23 @@ public: ///! Return true if there was an error at any point. static bool GetErrorOccuredFlag() { - return cmSystemTools::s_ErrorOccured; + return cmSystemTools::s_ErrorOccured || cmSystemTools::s_FatalErrorOccured; + } + ///! If this is set to true, cmake stops processing commands. + static void SetFatalErrorOccured() + { + cmSystemTools::s_FatalErrorOccured = true; + } + ///! Return true if there was an error at any point. + static bool GetFatalErrorOccured() + { + return cmSystemTools::s_FatalErrorOccured; } - ///! Set the error occured flag back to false + ///! Set the error occured flag and fatal error back to false static void ResetErrorOccuredFlag() { + cmSystemTools::s_FatalErrorOccured = false; cmSystemTools::s_ErrorOccured = false; } @@ -364,6 +375,7 @@ protected: private: static bool s_RunCommandHideConsole; static bool s_ErrorOccured; + static bool s_FatalErrorOccured; static bool s_DisableMessages; static bool s_DisableRunCommandOutput; static ErrorCallback s_ErrorCallback; |