Browse Source

ENH: add ability to create links on the start menu

Bill Hoffman 18 years ago
parent
commit
3e03bca2cd

+ 13 - 3
CMakeCPack.cmake

@@ -41,8 +41,18 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
     # There is a bug in NSI that does not handle full unix paths properly. Make
     # There is a bug in NSI that does not handle full unix paths properly. Make
     # sure there is at least one set of four (4) backlasshes.
     # sure there is at least one set of four (4) backlasshes.
     SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\CMakeInstall.bmp")
     SET(CPACK_PACKAGE_ICON "${CMake_SOURCE_DIR}/Utilities/Release\\\\CMakeInstall.bmp")
-    SET(CPACK_PACKAGE_EXECUTABLES "CMakeSetup" "CMake")
-    SET(CPACK_CREATE_DESKTOP_LINK_CMakeSetup 1)
+    # tell cpack the executables you want in the start menu as links
+    SET(CPACK_PACKAGE_EXECUTABLES "CMakeSetup" "CMake" )
+    # tell cpack to create links to the doc files
+    SET(CPACK_NSIS_MENU_LINKS
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/CMakeSetup.html" "CMakeSetup Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake.html" "CMake Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-properties.html"
+      "CMake Properties and Variables Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/ctest.html" "CTest Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-modules.html" "CMake Modules Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cmake-commands.html" "CMake Commands Help"
+      "doc/cmake-${CMake_VERSION_MAJOR}.${CMake_VERSION_MINOR}/cpack.html" "CPack Help")
     SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\CMakeSetup.exe")
     SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\CMakeSetup.exe")
     SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} a cross-platform, open-source build system")
     SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} a cross-platform, open-source build system")
     SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cmake.org")
     SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\www.cmake.org")
@@ -82,7 +92,7 @@ IF(EXISTS "${CMAKE_ROOT}/Modules/CPack.cmake")
     SET(CPACK_CYGWIN_PATCH_FILE 
     SET(CPACK_CYGWIN_PATCH_FILE 
       "${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@[email protected]")
       "${CMake_BINARY_DIR}/@CPACK_PACKAGE_FILE_NAME@-@[email protected]")
     # include the sub directory for cygwin releases
     # include the sub directory for cygwin releases
-    SUBDIRS(Utilities/Release/Cygwin)
+    INCLUDE(Utilities/Release/Cygwin)
     # when packaging source make sure the .build directory is not included
     # when packaging source make sure the .build directory is not included
     SET(CPACK_SOURCE_IGNORE_FILES
     SET(CPACK_SOURCE_IGNORE_FILES
       "/CVS/" "/\\\\.build/" "/\\\\.svn/" "\\\\.swp$" "\\\\.#" "/#" "~$")
       "/CVS/" "/\\\\.build/" "/\\\\.svn/" "\\\\.swp$" "\\\\.#" "/#" "~$")

+ 2 - 2
Modules/NSIS.template.in

@@ -409,8 +409,8 @@ FunctionEnd
 ;--------------------------------
 ;--------------------------------
 ; Define some macro setting for the gui
 ; Define some macro setting for the gui
 
 
-  !define CPACK_PACKAGE_ICON@CPACK_PACKAGE_ICON@
-  !ifndef CPACK_PACKAGE_ICON
+  !define CPACK_PACKAGE_ICON "@CPACK_PACKAGE_ICON@"
+  !ifdef CPACK_PACKAGE_ICON
     !define MUI_HEADERIMAGE_BITMAP "@CPACK_PACKAGE_ICON@"
     !define MUI_HEADERIMAGE_BITMAP "@CPACK_PACKAGE_ICON@"
   !endif
   !endif
 
 

+ 55 - 0
Source/CPack/cmCPackNSISGenerator.cxx

@@ -256,6 +256,7 @@ int cmCPackNSISGenerator::InitializeInternal()
                   << ".lnk\"" << std::endl;
                   << ".lnk\"" << std::endl;
         }
         }
       }
       }
+    this->CreateMenuLinks(str, deleteStr);
     this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
     this->SetOptionIfNotSet("CPACK_NSIS_CREATE_ICONS", str.str().c_str());
     this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", 
     this->SetOptionIfNotSet("CPACK_NSIS_DELETE_ICONS", 
                             deleteStr.str().c_str());
                             deleteStr.str().c_str());
@@ -265,6 +266,60 @@ int cmCPackNSISGenerator::InitializeInternal()
   return this->Superclass::InitializeInternal();
   return this->Superclass::InitializeInternal();
 }
 }
 
 
+//----------------------------------------------------------------------
+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,
 bool cmCPackNSISGenerator::GetListOfSubdirectories(const char* topdir,
   std::vector<std::string>& dirs)
   std::vector<std::string>& dirs)

+ 2 - 0
Source/CPack/cmCPackNSISGenerator.h

@@ -39,6 +39,8 @@ public:
 
 
 protected:
 protected:
   virtual int InitializeInternal();
   virtual int InitializeInternal();
+  void CreateMenuLinks( cmOStringStream& str,
+                        cmOStringStream& deleteStr);
   int CompressFiles(const char* outFileName, const char* toplevel,
   int CompressFiles(const char* outFileName, const char* toplevel,
     const std::vector<std::string>& files);
     const std::vector<std::string>& files);
   virtual const char* GetOutputExtension() { return ".exe"; }
   virtual const char* GetOutputExtension() { return ".exe"; }