[cmake-commits] alex committed cmCPackGenericGenerator.cxx 1.44 1.45 cmCPackGenericGenerator.h 1.17 1.18 cpack.cxx 1.30 1.31

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Jul 24 10:00:28 EDT 2007


Update of /cvsroot/CMake/CMake/Source/CPack
In directory public:/mounts/ram/cvs-serv10699/Source/CPack

Modified Files:
	cmCPackGenericGenerator.cxx cmCPackGenericGenerator.h 
	cpack.cxx 
Log Message:

ENH: determine the current system also in cpack, so the search paths are
loaded
Additionally the makefile in cmCPackGenericGenerator is now protected
instead of private, so with these two changes the cpack generators should
now be able to find their tools and how to call these tools from cmake
scripts, instead of hardcoding the search order and command line (as done
e.g. in cmCPackZIPGenerator.cxx)

Alex



Index: cmCPackGenericGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackGenericGenerator.cxx,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- cmCPackGenericGenerator.cxx	18 May 2007 18:41:09 -0000	1.44
+++ cmCPackGenericGenerator.cxx	24 Jul 2007 14:00:26 -0000	1.45
@@ -32,14 +32,14 @@
 cmCPackGenericGenerator::cmCPackGenericGenerator()
 {
   this->GeneratorVerbose = false;
-  this->MakefileMap = 0;
+  this->Makefile = 0;
   this->Logger = 0;
 }
 
 //----------------------------------------------------------------------
 cmCPackGenericGenerator::~cmCPackGenericGenerator()
 {
-  this->MakefileMap = 0;
+  this->Makefile = 0;
 }
 
 //----------------------------------------------------------------------
@@ -392,7 +392,7 @@
         tempInstallDirectory);
       this->SetOptionIfNotSet("CMAKE_CURRENT_SOURCE_DIR",
         tempInstallDirectory);
-      int res = this->MakefileMap->ReadListFile(0, installScript.c_str());
+      int res = this->Makefile->ReadListFile(0, installScript.c_str());
       if ( cmSystemTools::GetErrorOccuredFlag() || !res )
         {
         return 0;
@@ -454,7 +454,7 @@
 
       const char* buildConfig = this->GetOption("CPACK_BUILD_CONFIG");
       cmGlobalGenerator* globalGenerator
-        = this->MakefileMap->GetCMakeInstance()->CreateGlobalGenerator(
+        = this->Makefile->GetCMakeInstance()->CreateGlobalGenerator(
           cmakeGenerator);
       // set the global flag for unix style paths on cmSystemTools as
       // soon as the generator is set.  This allows gmake to be used
@@ -464,9 +464,9 @@
       // Does this generator require pre-install?
       if ( globalGenerator->GetPreinstallTargetName() )
         {
-        globalGenerator->FindMakeProgram(this->MakefileMap);
+        globalGenerator->FindMakeProgram(this->Makefile);
         const char* cmakeMakeProgram
-          = this->MakefileMap->GetDefinition("CMAKE_MAKE_PROGRAM");
+          = this->Makefile->GetDefinition("CMAKE_MAKE_PROGRAM");
         std::string buildCommand
           = globalGenerator->GenerateBuildCommand(cmakeMakeProgram,
             installProjectName.c_str(), 0,
@@ -554,7 +554,7 @@
 void cmCPackGenericGenerator::SetOptionIfNotSet(const char* op,
   const char* value)
 {
-  const char* def = this->MakefileMap->GetDefinition(op);
+  const char* def = this->Makefile->GetDefinition(op);
   if ( def && *def )
     {
     return;
@@ -571,12 +571,12 @@
     }
   if ( !value )
     {
-    this->MakefileMap->RemoveDefinition(op);
+    this->Makefile->RemoveDefinition(op);
     return;
     }
   cmCPackLogger(cmCPackLog::LOG_DEBUG, this->GetNameOfClass()
     << "::SetOption(" << op << ", " << value << ")" << std::endl);
-  this->MakefileMap->AddDefinition(op, value);
+  this->Makefile->AddDefinition(op, value);
 }
 
 //----------------------------------------------------------------------
@@ -680,7 +680,7 @@
 int cmCPackGenericGenerator::Initialize(const char* name, cmMakefile* mf,
  const char* argv0)
 {
-  this->MakefileMap = mf;
+  this->Makefile = mf;
   this->Name = name;
   if ( !this->FindRunningCMake(argv0) )
     {
@@ -700,7 +700,7 @@
 //----------------------------------------------------------------------
 const char* cmCPackGenericGenerator::GetOption(const char* op)
 {
-  return this->MakefileMap->GetDefinition(op);
+  return this->Makefile->GetDefinition(op);
 }
 
 //----------------------------------------------------------------------
@@ -913,7 +913,7 @@
 {
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Look for template: "
     << (name ? name : "(NULL)") << std::endl);
-  std::string ffile = this->MakefileMap->GetModulesFile(name);
+  std::string ffile = this->Makefile->GetModulesFile(name);
   cmCPackLogger(cmCPackLog::LOG_DEBUG, "Found template: "
     << ffile.c_str() << std::endl);
   return ffile;
@@ -923,7 +923,7 @@
 bool cmCPackGenericGenerator::ConfigureString(const std::string& inString,
   std::string& outString)
 {
-  this->MakefileMap->ConfigureString(inString,
+  this->Makefile->ConfigureString(inString,
     outString, true, false);
   return true;
 }
@@ -932,7 +932,7 @@
 bool cmCPackGenericGenerator::ConfigureFile(const char* inName,
   const char* outName, bool copyOnly /* = false */)
 {
-  return this->MakefileMap->ConfigureFile(inName, outName,
+  return this->Makefile->ConfigureFile(inName, outName,
     copyOnly, true, false) == 1;
 }
 

Index: cpack.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cpack.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- cpack.cxx	19 Jul 2007 15:13:01 -0000	1.30
+++ cpack.cxx	24 Jul 2007 14:00:26 -0000	1.31
@@ -243,6 +243,25 @@
 
   if ( parsed && !help )
     {
+    // find out which system cpack is running on, so it can setup the search
+    // paths, so FIND_XXX() commands can be used in scripts
+    cminst.AddCMakePaths(argv[0]);
+    std::string systemFile = globalMF->GetModulesFile("CMakeDetermineSystem.cmake");
+    if (!globalMF->ReadListFile(0, systemFile.c_str()))
+      {
+      cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+        "Error reading CMakeDetermineSystem.cmake" << std::endl);
+      return 1;
+      }
+
+    systemFile = globalMF->GetModulesFile("CMakeSystemSpecificInformation.cmake");
+    if (!globalMF->ReadListFile(0, systemFile.c_str()))
+      {
+      cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+        "Error reading CMakeSystemSpecificInformation.cmake" << std::endl);
+      return 1;
+      }
+
     if ( cmSystemTools::FileExists(cpackConfigFile.c_str()) )
       {
       cpackConfigFile = 
@@ -327,94 +346,92 @@
         const char* gen = it->c_str();
         cmMakefile newMF(*globalMF);
         cmMakefile* mf = &newMF;
+        cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
+          "Specified generator: " << gen << std::endl);
+        if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
           {
-          cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE,
-            "Specified generator: " << gen << std::endl);
-          if ( parsed && !mf->GetDefinition("CPACK_PACKAGE_NAME") )
+          cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+            "CPack project name not specified" << std::endl);
+          parsed = 0;
+          }
+        if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION")
+            || mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
+            mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
+            && mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) )
+          {
+          cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+            "CPack project version not specified" << std::endl
+            << "Specify CPACK_PACKAGE_VERSION, or "
+            "CPACK_PACKAGE_VERSION_MAJOR, "
+            "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
+            << std::endl);
+          parsed = 0;
+          }
+        if ( parsed )
+          {
+          cpackGenerator = generators.NewGenerator(gen);
+          if ( !cpackGenerator )
             {
             cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-              "CPack project name not specified" << std::endl);
+              "Cannot initialize CPack generator: "
+              << generator.c_str() << std::endl);
             parsed = 0;
             }
-          if ( parsed && !(mf->GetDefinition("CPACK_PACKAGE_VERSION")
-              || mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR") &&
-              mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR")
-              && mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH")) )
+          if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
             {
             cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-              "CPack project version not specified" << std::endl
-              << "Specify CPACK_PACKAGE_VERSION, or "
-              "CPACK_PACKAGE_VERSION_MAJOR, "
-              "CPACK_PACKAGE_VERSION_MINOR, and CPACK_PACKAGE_VERSION_PATCH."
+              "Cannot initialize the generator" << std::endl);
+            parsed = 0;
+            }
+
+          if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
+            !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
+            !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
+            {
+            cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
+              "Please specify build tree of the project that uses CMake "
+              "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
+              "CPACK_INSTALL_COMMANDS, or specify "
+              "CPACK_INSTALLED_DIRECTORIES."
               << std::endl);
             parsed = 0;
             }
           if ( parsed )
             {
-            cpackGenerator = generators.NewGenerator(gen);
-            if ( !cpackGenerator )
-              {
-              cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-                "Cannot initialize CPack generator: "
-                << generator.c_str() << std::endl);
-              parsed = 0;
-              }
-            if ( parsed && !cpackGenerator->Initialize(gen, mf, argv[0]) )
+#ifdef _WIN32
+            std::string comspec = "cmw9xcom.exe";
+            cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
+#endif
+
+            const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
+            cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
+              << cpackGenerator->GetNameOfClass() << std::endl);
+            cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
+              << projName << std::endl);
+
+            const char* projVersion = 
+              mf->GetDefinition("CPACK_PACKAGE_VERSION");
+            if ( !projVersion )
               {
-              cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-                "Cannot initialize the generator" << std::endl);
-              parsed = 0;
+              const char* projVersionMajor
+                = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
+              const char* projVersionMinor
+                = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
+              const char* projVersionPatch
+                = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
+              cmOStringStream ostr;
+              ostr << projVersionMajor << "." << projVersionMinor << "."
+                << projVersionPatch;
+              mf->AddDefinition("CPACK_PACKAGE_VERSION", 
+                                ostr.str().c_str());
               }
 
-            if ( !mf->GetDefinition("CPACK_INSTALL_COMMANDS") &&
-              !mf->GetDefinition("CPACK_INSTALLED_DIRECTORIES") &&
-              !mf->GetDefinition("CPACK_INSTALL_CMAKE_PROJECTS") )
+            int res = cpackGenerator->ProcessGenerator();
+            if ( !res )
               {
               cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-                "Please specify build tree of the project that uses CMake "
-                "using CPACK_INSTALL_CMAKE_PROJECTS, specify "
-                "CPACK_INSTALL_COMMANDS, or specify "
-                "CPACK_INSTALLED_DIRECTORIES."
-                << std::endl);
-              parsed = 0;
-              }
-            if ( parsed )
-              {
-#ifdef _WIN32
-              std::string comspec = "cmw9xcom.exe";
-              cmSystemTools::SetWindows9xComspecSubstitute(comspec.c_str());
-#endif
-
-              const char* projName = mf->GetDefinition("CPACK_PACKAGE_NAME");
-              cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "Use generator: "
-                << cpackGenerator->GetNameOfClass() << std::endl);
-              cmCPack_Log(&log, cmCPackLog::LOG_VERBOSE, "For project: "
-                << projName << std::endl);
-  
-              const char* projVersion = 
-                mf->GetDefinition("CPACK_PACKAGE_VERSION");
-              if ( !projVersion )
-                {
-                const char* projVersionMajor
-                  = mf->GetDefinition("CPACK_PACKAGE_VERSION_MAJOR");
-                const char* projVersionMinor
-                  = mf->GetDefinition("CPACK_PACKAGE_VERSION_MINOR");
-                const char* projVersionPatch
-                  = mf->GetDefinition("CPACK_PACKAGE_VERSION_PATCH");
-                cmOStringStream ostr;
-                ostr << projVersionMajor << "." << projVersionMinor << "."
-                  << projVersionPatch;
-                mf->AddDefinition("CPACK_PACKAGE_VERSION", 
-                                  ostr.str().c_str());
-                }
-  
-              int res = cpackGenerator->ProcessGenerator();
-              if ( !res )
-                {
-                cmCPack_Log(&log, cmCPackLog::LOG_ERROR,
-                  "Error when generating package: " << projName << std::endl);
-                return 1;
-                }
+                "Error when generating package: " << projName << std::endl);
+              return 1;
               }
             }
           }

Index: cmCPackGenericGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackGenericGenerator.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- cmCPackGenericGenerator.h	2 Feb 2007 19:40:26 -0000	1.17
+++ cmCPackGenericGenerator.h	24 Jul 2007 14:00:26 -0000	1.18
@@ -130,8 +130,7 @@
 
   cmCPackLog* Logger;
 
-private:
-  cmMakefile* MakefileMap;
+  cmMakefile* Makefile;
 };
 
 #endif



More information about the Cmake-commits mailing list