From b9c4cff45a8cc24ce4d18ba66d57b713be08ccfc Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Thu, 5 Jan 2006 13:27:48 -0500 Subject: [PATCH] ENH: More debugging and work on PackageMaker code --- Source/CPack/cmCPackGenericGenerator.cxx | 16 ++++++++++++++-- Source/CPack/cpack.cxx | 7 +++++-- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/Source/CPack/cmCPackGenericGenerator.cxx b/Source/CPack/cmCPackGenericGenerator.cxx index 7c1eb51f5..7f77178ea 100644 --- a/Source/CPack/cmCPackGenericGenerator.cxx +++ b/Source/CPack/cmCPackGenericGenerator.cxx @@ -328,12 +328,13 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) // do CMAKE_ROOT, look for the environment variable first std::string cMakeRoot; std::string modules; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT" << std::endl); if (getenv("CMAKE_ROOT")) { cMakeRoot = getenv("CMAKE_ROOT"); modules = cMakeRoot + "/Modules/CMake.cmake"; } - if(!cmSystemTools::FileExists(modules.c_str())) + if(modules.empty() || !cmSystemTools::FileExists(modules.c_str())) { // next try exe/.. cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); @@ -344,6 +345,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) } // is there no Modules direcory there? modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } if (!cmSystemTools::FileExists(modules.c_str())) @@ -351,6 +353,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) // try exe/../share/cmake cMakeRoot += CMAKE_DATA_DIR; modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } #ifdef CMAKE_ROOT_DIR if (!cmSystemTools::FileExists(modules.c_str())) @@ -358,6 +361,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) // try compiled in root directory cMakeRoot = CMAKE_ROOT_DIR; modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } #endif #ifdef CMAKE_PREFIX @@ -366,6 +370,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) // try compiled in install prefix cMakeRoot = CMAKE_PREFIX CMAKE_DATA_DIR; modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } #endif if (!cmSystemTools::FileExists(modules.c_str())) @@ -374,6 +379,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); cMakeRoot += CMAKE_DATA_DIR; modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } if(!cmSystemTools::FileExists(modules.c_str())) { @@ -381,6 +387,7 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) cMakeRoot = cmSystemTools::GetProgramPath(m_CMakeSelf.c_str()); // is there no Modules direcory there? modules = cMakeRoot + "/Modules/CMake.cmake"; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << modules.c_str() << std::endl); } if (!cmSystemTools::FileExists(modules.c_str())) { @@ -392,6 +399,8 @@ int cmCPackGenericGenerator::FindRunningCMake(const char* arg0) return 0; } m_CMakeRoot = cMakeRoot; + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Looking for CMAKE_ROOT: " << m_CMakeRoot.c_str() << std::endl); + this->SetOption("CMAKE_ROOT", m_CMakeRoot.c_str()); return 1; } @@ -441,7 +450,10 @@ const char* cmCPackGenericGenerator::GetInstallPath() //---------------------------------------------------------------------- std::string cmCPackGenericGenerator::FindTemplate(const char* name) { - return m_MakefileMap->GetModulesFile(name); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: " << name << std::endl); + std::string ffile = m_MakefileMap->GetModulesFile(name); + cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: " << ffile.c_str() << std::endl); + return ffile; } //---------------------------------------------------------------------- diff --git a/Source/CPack/cpack.cxx b/Source/CPack/cpack.cxx index 8c0857fe5..4d35d7752 100644 --- a/Source/CPack/cpack.cxx +++ b/Source/CPack/cpack.cxx @@ -282,7 +282,10 @@ int main (int argc, char *argv[]) cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize CPack generator: " << generator.c_str() << std::endl); parsed = 0; } - cpackGenerator->Initialize(gen, mf); + if ( !cpackGenerator->Initialize(gen, mf) ) + { + parsed = 0; + } if ( parsed && !cpackGenerator->FindRunningCMake(argv[0]) ) { cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Cannot initialize the generator" << std::endl); @@ -337,7 +340,7 @@ int main (int argc, char *argv[]) int res = cpackGenerator->ProcessGenerator(); if ( !res ) { - cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error when generating package: " << cpackProjectName.c_str() << std::endl); + cmCPack_Log(&log, cmCPackLog::LOG_ERROR, "Error when generating package: " << projName << std::endl); return 1; }