summaryrefslogtreecommitdiff
path: root/Source/CPack
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2007-10-18 09:40:10 -0400
committerBill Hoffman <bill.hoffman@kitware.com>2007-10-18 09:40:10 -0400
commit3e03bca2cd532fe933a9f8d0dcecc1a9d22593e9 (patch)
treef0af081dbcce9b2be6c83a302400fc4a5e177e99 /Source/CPack
parentd88b30a7429564935a46a9041589ac25f84d60ec (diff)
downloadcmake-3e03bca2cd532fe933a9f8d0dcecc1a9d22593e9.tar.gz
ENH: add ability to create links on the start menu
Diffstat (limited to 'Source/CPack')
-rw-r--r--Source/CPack/cmCPackNSISGenerator.cxx55
-rw-r--r--Source/CPack/cmCPackNSISGenerator.h2
2 files changed, 57 insertions, 0 deletions
diff --git a/Source/CPack/cmCPackNSISGenerator.cxx b/Source/CPack/cmCPackNSISGenerator.cxx
index b9db822dd2..63d62bfaa7 100644
--- a/Source/CPack/cmCPackNSISGenerator.cxx
+++ b/Source/CPack/cmCPackNSISGenerator.cxx
@@ -256,6 +256,7 @@ int cmCPackNSISGenerator::InitializeInternal()
<< ".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 @@ int cmCPackNSISGenerator::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,
std::vector<std::string>& dirs)
{
diff --git a/Source/CPack/cmCPackNSISGenerator.h b/Source/CPack/cmCPackNSISGenerator.h
index ff075d6597..0bd776383a 100644
--- a/Source/CPack/cmCPackNSISGenerator.h
+++ b/Source/CPack/cmCPackNSISGenerator.h
@@ -39,6 +39,8 @@ public:
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"; }