summaryrefslogtreecommitdiffstats
path: root/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
diff options
context:
space:
mode:
authorLuis Ibanez <luis.ibanez@kitware.com>2001-06-12 12:34:29 (GMT)
committerLuis Ibanez <luis.ibanez@kitware.com>2001-06-12 12:34:29 (GMT)
commitd0614d75ea2fa259bed8e48226f85b0f5553cfb5 (patch)
tree55b6f78b2428f0640c82695476cf21266e6d17b6 /Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
parent522ff0204a48774d42f9a1de4d2ab9530f0f6994 (diff)
downloadCMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.zip
CMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.tar.gz
CMake-d0614d75ea2fa259bed8e48226f85b0f5553cfb5.tar.bz2
ENH: Paths are now expanded for environment variables and made absolute.
The binary directory is created if it doesn't exist.
Diffstat (limited to 'Source/FLTKDialog/CMakeSetupGUIImplementation.cxx')
-rw-r--r--Source/FLTKDialog/CMakeSetupGUIImplementation.cxx131
1 files changed, 92 insertions, 39 deletions
diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
index 4f5d0b4..2ade1eb 100644
--- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
+++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
@@ -21,10 +21,9 @@ CMakeSetupGUIImplementation
{
m_BuildPathChanged = false;
char fname[1024];
- //::GetModuleFileName(NULL,fname,1023);
+ //::GetModuleFileName(NULL,fname,1023); // Didn't found this method. (?)
m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
m_PathToExecutable += "/cmake.exe";
- std::cout << "Path to executable = " << m_PathToExecutable << std::endl;
}
@@ -122,89 +121,142 @@ CMakeSetupGUIImplementation
/**
* Set the source path
*/
-void
+bool
CMakeSetupGUIImplementation
::SetSourcePath( const char * path )
{
- if( VerifySourcePath( path ) )
+
+ if( !path || strlen(path)==0 )
+ {
+ fl_alert("Please select the path to the sources");
+ return false;
+ }
+
+ string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path );
+
+ sourcePathTextInput->value( expandedAbsolutePath.c_str() );
+
+ if( VerifySourcePath( expandedAbsolutePath ) )
{
- m_WhereSource = path;
- sourcePathTextInput->value( path );
+ m_WhereSource = expandedAbsolutePath;
+ return true;
}
+ return false;
+
}
/**
- * Set the binary path
+ * Expand environment variables in the path and make it absolute
*/
-void
+string
CMakeSetupGUIImplementation
-::SetBinaryPath( const char * path )
+::ExpandPathAndMakeItAbsolute( const string & inputPath ) const
{
- if( VerifyBinaryPath( path ) )
- {
- if( m_WhereBuild != path )
- {
- m_BuildPathChanged = true;
- m_WhereBuild = path;
- }
- binaryPathTextInput->value( path );
- }
+ char expandedPath[3000];
+ filename_expand( expandedPath, inputPath.c_str() );
- LoadCacheFromDiskToGUI();
+ char absolutePath[3000];
+ filename_absolute( absolutePath, expandedPath );
+
+ string expandedAbsolutePath = absolutePath;
+ return expandedAbsolutePath;
+
}
-
/**
- * Verify the path to binaries
+ * Set the binary path
*/
bool
CMakeSetupGUIImplementation
-::VerifyBinaryPath( const char * path )
+::SetBinaryPath( const char * path )
{
if( !path || strlen(path)==0 )
{
fl_alert("Please select the path to the binaries");
- return false;
+ return false;
}
+ string expandedAbsolutePath = ExpandPathAndMakeItAbsolute( path );
+
+ binaryPathTextInput->value( expandedAbsolutePath.c_str() );
+
+ if( !VerifyBinaryPath( expandedAbsolutePath.c_str() ) )
+ {
+ return false;
+ }
- if( !filename_isdir( path ) )
+ if( m_WhereBuild != expandedAbsolutePath )
{
- fl_alert("%s \n Doesn't exist or is not a directory",path);
- return false;
+ m_BuildPathChanged = true;
+ m_WhereBuild = expandedAbsolutePath;
}
+
+ LoadCacheFromDiskToGUI();
return true;
+
}
/**
- * Verify the path to sources
+ * Verify the path to binaries
*/
bool
CMakeSetupGUIImplementation
-::VerifySourcePath( const char * path )
+::VerifyBinaryPath( const string & path ) const
{
- if( !path || strlen(path)==0 )
+ bool pathIsOK = false;
+
+ if( filename_isdir( path.c_str() ) )
{
- fl_alert("Please select the path to the sources");
- return false;
+ pathIsOK = true;
+ }
+ else
+ {
+ int userWantsToCreateDirectory =
+ fl_ask("The directory \n %s \n Doesn't exist. Do you want to create it ?",
+ path.c_str() );
+
+ if( userWantsToCreateDirectory )
+ {
+ string command = "mkdir ";
+ command += path;
+ system( command.c_str() );
+ pathIsOK = true;
+ }
+ else
+ {
+ pathIsOK = false;
+ }
}
+ return pathIsOK;
- if( !filename_isdir( path ) )
+}
+
+
+
+/**
+ * Verify the path to sources
+ */
+bool
+CMakeSetupGUIImplementation
+::VerifySourcePath( const string & path ) const
+{
+
+ if( !filename_isdir( path.c_str() ) )
{
- fl_alert("%s \n Doesn't exist or is not a directory",path);
+ fl_alert("The Source directory \n %s \n Doesn't exist or is not a directory", path.c_str() );
return false;
}
@@ -222,17 +274,18 @@ CMakeSetupGUIImplementation
::BuildProjectFiles( void )
{
- // Verify that source path is a valid directory
- if( !VerifySourcePath( sourcePathTextInput->value() ) )
+ // Take and verify the source path from the GUI
+ if( !SetSourcePath( sourcePathTextInput->value() ) )
{
return;
}
-
- // Verify that binary path is a valid directory
- if( !VerifyBinaryPath( binaryPathTextInput->value() ) )
- {
+
+ // Take and verify the binary path from the GUI
+ if( !SetBinaryPath( binaryPathTextInput->value() ) )
+ {
return;
}
+
SaveCacheFromGUI();