[cmake-commits] hoffman committed cmCPackNSISGenerator.cxx 1.22 1.23 cmCPackNSISGenerator.h 1.9 1.10

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Oct 18 09:40:12 EDT 2007


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

Modified Files:
	cmCPackNSISGenerator.cxx cmCPackNSISGenerator.h 
Log Message:
ENH: add ability to create links on the start menu


Index: cmCPackNSISGenerator.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackNSISGenerator.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- cmCPackNSISGenerator.h	2 Feb 2007 19:40:26 -0000	1.9
+++ cmCPackNSISGenerator.h	18 Oct 2007 13:40:10 -0000	1.10
@@ -39,6 +39,8 @@
 
 protected:
   virtual int InitializeInternal();
+  void CreateMenuLinks( cmOStringStream& str,
+                        cmOStringStream& deleteStr);
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
   virtual const char* GetOutputExtension() { return ".exe"; }

Index: cmCPackNSISGenerator.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CPack/cmCPackNSISGenerator.cxx,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- cmCPackNSISGenerator.cxx	18 Sep 2007 19:16:21 -0000	1.22
+++ cmCPackNSISGenerator.cxx	18 Oct 2007 13:40:10 -0000	1.23
@@ -256,6 +256,7 @@
                   << ".lnk\"" << std::endl;
         }
       }
+    this->CreateMenuLinks(str, deleteStr);
     this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
     this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", 
                             deleteStr.str().c_str());
@@ -266,6 +267,60 @@
 }
 
 //----------------------------------------------------------------------
+void cmCPackNSISGenerator::CreateMenuLinks( cmOStringStream& str,
+                                            cmOStringStream& deleteStr)
+{
+  const char* cpackMenuLinks
+    = this->GetOption("CPACK_NSIS_MENU_LINKS");
+  if(!cpackMenuLinks)
+    {
+    return;
+    }
+  cmCPackLogger(cmCPackLog::LOG_DEBUG, "The cpackMenuLinks: "
+                << cpackMenuLinks << "." << std::endl);
+  std::vector<std::string> cpackMenuLinksVector;
+  cmSystemTools::ExpandListArgument(cpackMenuLinks,
+                                    cpackMenuLinksVector);
+  if ( cpackMenuLinksVector.size() % 2 != 0 )
+    {
+    cmCPackLogger(cmCPackLog::LOG_ERROR,
+                  "CPACK_PACKAGE_EXECUTABLES should contain pairs of <executable> and "
+                  "<icon name>." << std::endl);
+    return;
+    }
+  std::vector<std::string>::iterator it;
+  for ( it = cpackMenuLinksVector.begin();
+        it != cpackMenuLinksVector.end();
+        ++it )
+    {
+    std::string sourceName = *it;
+    /* convert / to \\ */
+    cmSystemTools::ReplaceString(sourceName, "/", "\\");
+    ++ it;
+    std::string linkName = *it;
+    str << "  CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
+        << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
+        << std::endl;
+    deleteStr << "  Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
+              << ".lnk\"" << std::endl;
+    // see if CPACK_CREATE_DESKTOP_LINK_ExeName is on
+    // if so add a desktop link
+    std::string desktop = "CPACK_CREATE_DESKTOP_LINK_";
+    desktop += linkName;
+    if(this->IsSet(desktop.c_str()))
+      {
+      str << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
+      str << "    CreateShortCut \"$DESKTOP\\"
+          << linkName << ".lnk\" \"$INSTDIR\\" << sourceName << "\""
+          << std::endl;
+      deleteStr << "  StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
+      deleteStr << "    Delete \"$DESKTOP\\" << linkName
+                << ".lnk\"" << std::endl;
+      }
+    }
+}
+
+//----------------------------------------------------------------------
 bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
   std::vector<std::string>& dirs)
 {



More information about the Cmake-commits mailing list