From 7a9ab85304015a576a39198a444dc9ad8525f6aa Mon Sep 17 00:00:00 2001
From: Luis Ibanez <luis.ibanez@kitware.com>
Date: Mon, 11 Jun 2001 01:20:22 -0400
Subject: ENH: CMake invokation is working.

---
 Source/FLTKDialog/CMakeSetupGUIImplementation.cxx | 53 ++++++++++++++++++++++-
 Source/FLTKDialog/CMakeSetupGUIImplementation.h   |  2 +
 2 files changed, 53 insertions(+), 2 deletions(-)

diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
index 64d2ce4..c07298a 100644
--- a/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
+++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.cxx
@@ -8,6 +8,8 @@
 #include "../cmMakefile.h"
 #include <iostream>
 #include "FLTKPropertyList.h"
+#include "Fl/fl_draw.H"
+#include "../cmake.h"
 
 
 
@@ -17,6 +19,12 @@
 CMakeSetupGUIImplementation
 ::CMakeSetupGUIImplementation()
 {
+  m_BuildPathChanged = false;
+  char fname[1024];
+  //::GetModuleFileName(NULL,fname,1023);
+  m_PathToExecutable = cmSystemTools::GetProgramPath(fname).c_str();
+  m_PathToExecutable += "/cmake.exe";
+  std::cout << "Path to executable = " << m_PathToExecutable << std::endl;
 }
 
 
@@ -139,7 +147,11 @@ CMakeSetupGUIImplementation
 
   if( VerifyBinaryPath( path ) )
   {
-    m_WhereBuild = path;
+    if( m_WhereBuild != path )
+    {
+      m_BuildPathChanged = true;
+      m_WhereBuild = path;
+    }
     binaryPathTextInput->value( path );
   }
 
@@ -224,7 +236,44 @@ CMakeSetupGUIImplementation
 
   SaveCacheFromGUI();
   
-  fl_message("Building project files ... please wait");
+  // set the wait cursor
+  fl_cursor(FL_CURSOR_WAIT,FL_WHITE,FL_BLACK);
+  // get all the info from the dialog
+  // this->UpdateData();
+  if(!m_BuildPathChanged)
+    {
+    // if the build path has not changed save the 
+    // current GUI values to the cache
+    this->SaveCacheFromGUI();
+    }
+  // Make sure we are working from the cache on disk
+  this->LoadCacheFromDiskToGUI();
+  // create a cmake object
+  cmake make;
+  // create the arguments for the cmake object
+  std::vector<std::string> args;
+  args.push_back( m_PathToExecutable.c_str() );
+  std::string arg;
+  arg = "-H";
+  arg += m_WhereSource;
+  args.push_back(arg);
+  arg = "-B";
+  arg += m_WhereBuild;
+  args.push_back(arg);
+  // run the generate process
+  if(make.Generate(args) != 0)
+    {
+    cmSystemTools::Error(
+      "Error in generation process, project files may be invalid");
+    }
+  // update the GUI with any new values in the caused by the
+  // generation process
+  this->LoadCacheFromDiskToGUI();
+  // path is up-to-date now
+  m_BuildPathChanged = false;
+  // put the cursor back
+  fl_cursor(FL_CURSOR_DEFAULT,FL_WHITE,FL_BLACK);
+  fl_message("Done !");
 
 }
 
diff --git a/Source/FLTKDialog/CMakeSetupGUIImplementation.h b/Source/FLTKDialog/CMakeSetupGUIImplementation.h
index 870f052..d0f8021 100644
--- a/Source/FLTKDialog/CMakeSetupGUIImplementation.h
+++ b/Source/FLTKDialog/CMakeSetupGUIImplementation.h
@@ -39,6 +39,8 @@ private:
   fltk::PropertyList   m_CacheEntriesList;
   std::string          m_WhereBuild;
   std::string          m_WhereSource;
+  std::string          m_PathToExecutable;
+  bool                 m_BuildPathChanged;
 };
 
 
-- 
cgit v0.12