From f055e512ae5e6f808e321ca27f3a9bcfd4ba1165 Mon Sep 17 00:00:00 2001 From: Luis Ibanez Date: Fri, 15 Jun 2001 07:51:55 -0400 Subject: [PATCH] ENH: Absolute path to cmake resolved --- .../CMakeSetupGUIImplementation.cxx | 67 +++++++++++++------ .../FLTKDialog/CMakeSetupGUIImplementation.h | 1 + Source/FLTKDialog/FLTKDialog.cxx | 3 +- .../FLTKPropertyNameButtonWithHelp.cxx | 9 +-- 4 files changed, 54 insertions(+), 26 deletions(-) diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx index 08ad2e8ed..ea91e5fa1 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx @@ -1,14 +1,14 @@ #include "CMakeSetupGUIImplementation.h" -#include "FL/fl_file_chooser.H" -#include "FL/filename.H" -#include "FL/fl_ask.H" +#include "Fl/fl_file_chooser.H" +#include "Fl/filename.H" +#include "Fl/fl_ask.H" #include "cstring" #include "../cmCacheManager.h" #include "../cmMakefile.h" #include #include "FLTKPropertyList.h" -#include "FL/fl_draw.H" +#include "Fl/fl_draw.H" #include "../cmake.h" @@ -20,22 +20,6 @@ CMakeSetupGUIImplementation ::CMakeSetupGUIImplementation() { m_BuildPathChanged = false; - -// Construct the full path to cmake executable - -#if defined(_WIN32) - char fname[1024]; - ::GetModuleFileName(NULL,fname,1023); // Didn't found this method. (?) - m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str(); - m_PathToExecutable += "/cmake.exe"; -#else - char fullPathToCMake[1024]; - filename_absolute( fullPathToCMake, "../cmake" ); - m_PathToExecutable = fullPathToCMake; -#endif - - std::cout << "Path to CMake executable " << m_PathToExecutable << std::endl; - } @@ -130,6 +114,47 @@ CMakeSetupGUIImplementation +/** + * Set path to executable. Used to get the path to CMake + */ +void +CMakeSetupGUIImplementation +::SetPathToExecutable( const char * path ) +{ + m_PathToExecutable = path; + + char expandedPath[1024]; + filename_expand( expandedPath, path ); + + char absolutePath[1024]; + filename_absolute( absolutePath, expandedPath ); + + char * p = absolutePath + strlen( absolutePath ); + while( *p != '/' && *p != '\\' ) + { + p--; + } + p--; + while( *p != '/' && *p != '\\' ) + { + p--; + } + *p = '\0'; + + std::cout << "absolutePath = " << absolutePath << std::endl; + + m_PathToExecutable = absolutePath; + +#if defined(_WIN32) + m_PathToExecutable += "/CMake.exe"; +#else + m_PathToExecutable += "/cmake"; +#endif + std::cout << "Path to CMake executable = " << m_PathToExecutable << std::endl; +} + + + /** * Set the source path */ @@ -358,7 +383,7 @@ CMakeSetupGUIImplementation { cmCacheManager::GetInstance()->LoadCache( m_WhereBuild.c_str() ); this->FillCacheGUIFromCacheManager(); - } + } } diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.h b/Source/FLTKDialog/CMakeSetupGUIImplementation.h index 5133d9f3f..9720125d9 100644 --- a/Source/FLTKDialog/CMakeSetupGUIImplementation.h +++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.h @@ -32,6 +32,7 @@ public: virtual void LoadCacheFromDiskToGUI( void ); virtual void FillCacheGUIFromCacheManager( void ); virtual void FillCacheManagerFromCacheGUI( void ); + virtual void SetPathToExecutable( const char * path ); private: virtual bool VerifyBinaryPath( const std::string & path ) const; diff --git a/Source/FLTKDialog/FLTKDialog.cxx b/Source/FLTKDialog/FLTKDialog.cxx index 5933ef5b2..39a3c38f1 100644 --- a/Source/FLTKDialog/FLTKDialog.cxx +++ b/Source/FLTKDialog/FLTKDialog.cxx @@ -3,7 +3,7 @@ #include "FL/Fl.h" #include "FL/fl_ask.H" -int main() +int main(int argc, char * argv[] ) { fl_message_font(FL_HELVETICA,11); @@ -11,6 +11,7 @@ int main() CMakeSetupGUIImplementation * gui = new CMakeSetupGUIImplementation; + gui->SetPathToExecutable( argv[0] ); gui->Show(); gui->LoadCacheFromDiskToGUI(); diff --git a/Source/FLTKDialog/FLTKPropertyNameButtonWithHelp.cxx b/Source/FLTKDialog/FLTKPropertyNameButtonWithHelp.cxx index 1bc9372e6..b2715ac43 100644 --- a/Source/FLTKDialog/FLTKPropertyNameButtonWithHelp.cxx +++ b/Source/FLTKDialog/FLTKPropertyNameButtonWithHelp.cxx @@ -1,8 +1,9 @@ -#include "FLTKPropertyNameButtonWithHelp.h" -#include -#include -#include +// #include +#include +#include +#include #include "../cmCacheManager.h" +#include "FLTKPropertyNameButtonWithHelp.h" namespace fltk {