Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPack NSIS fixes and feature #2

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions Modules/CPack.cmake
Expand Up @@ -257,6 +257,14 @@
# CPACK_NSIS_DELETE_ICONS_EXTRA -Additional NSIS commands to
# uninstall start menu shortcuts.
#
# CPACK_NSIS_EXECUTABLES_DIRECTORY - Creating NSIS start menu links
# assumes that they are in 'bin\' unless this variable is set.
# For example, you would set this to 'exec\' if your executables are
# in an exec directory.
#
# CPACK_NSIS_MUI_FINISHPAGE_RUN - Specify an executable to add an option
# to run on the finish page of the NSIS installer.
#
# The following variable is specific to installers build on Mac OS X
# using PackageMaker:
#
Expand Down
1 change: 1 addition & 0 deletions Modules/NSIS.template.in
Expand Up @@ -540,6 +540,7 @@ FunctionEnd
@CPACK_NSIS_INSTALLER_MUI_ICON_CODE@
@CPACK_NSIS_INSTALLER_ICON_CODE@
@CPACK_NSIS_INSTALLER_MUI_COMPONENTS_DESC@
@CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE@

;--------------------------------
;Pages
Expand Down
40 changes: 31 additions & 9 deletions Source/CPack/cmCPackNSISGenerator.cxx
Expand Up @@ -129,14 +129,21 @@ int cmCPackNSISGenerator::PackageFiles()
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Configure file: " << nsisInFileName
<< " to " << nsisFileName << std::endl);
if(this->IsSet("CPACK_NSIS_MUI_ICON")
&& this->IsSet("CPACK_NSIS_MUI_UNIICON"))
|| this->IsSet("CPACK_NSIS_MUI_UNIICON"))
{
std::string installerIconCode="!define MUI_ICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
installerIconCode += "\"\n";
installerIconCode += "!define MUI_UNICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON");
installerIconCode += "\"\n";
std::string installerIconCode;
if(this->IsSet("CPACK_NSIS_MUI_ICON"))
{
installerIconCode += "!define MUI_ICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_ICON");
installerIconCode += "\"\n";
}
if(this->IsSet("CPACK_NSIS_MUI_UNIICON"))
{
installerIconCode += "!define MUI_UNICON \"";
installerIconCode += this->GetOption("CPACK_NSIS_MUI_UNIICON");
installerIconCode += "\"\n";
}
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_ICON_CODE",
installerIconCode.c_str());
}
Expand All @@ -149,6 +156,16 @@ int cmCPackNSISGenerator::PackageFiles()
installerIconCode.c_str());
}

if(this->IsSet("CPACK_NSIS_MUI_FINISHPAGE_RUN"))
{
std::string installerRunCode = "!define MUI_FINISHPAGE_RUN \"$INSTDIR\\";
installerRunCode += this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
installerRunCode += this->GetOption("CPACK_NSIS_MUI_FINISHPAGE_RUN");
installerRunCode += "\"\n";
this->SetOptionIfNotSet("CPACK_NSIS_INSTALLER_MUI_FINISHPAGE_RUN_CODE",
installerRunCode.c_str());
}

// Setup all of the component sections
if (this->Components.empty())
{
Expand Down Expand Up @@ -418,6 +435,8 @@ int cmCPackNSISGenerator::InitializeInternal()
= this->GetOption("CPACK_PACKAGE_EXECUTABLES");
const char* cpackPackageDeskTopLinks
= this->GetOption("CPACK_CREATE_DESKTOP_LINKS");
const char* cpackNsisExecutablesDirectory
= this->GetOption("CPACK_NSIS_EXECUTABLES_DIRECTORY");
std::vector<std::string> cpackPackageDesktopLinksVector;
if(cpackPackageDeskTopLinks)
{
Expand Down Expand Up @@ -465,7 +484,8 @@ int cmCPackNSISGenerator::InitializeInternal()
++ it;
std::string linkName = *it;
str << " CreateShortCut \"$SMPROGRAMS\\$STARTMENU_FOLDER\\"
<< linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\""
<< linkName << ".lnk\" \"$INSTDIR\\"
<< cpackNsisExecutablesDirectory << execName << ".exe\""
<< std::endl;
deleteStr << " Delete \"$SMPROGRAMS\\$MUI_TEMP\\" << linkName
<< ".lnk\"" << std::endl;
Expand All @@ -479,7 +499,8 @@ int cmCPackNSISGenerator::InitializeInternal()
{
str << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
str << " CreateShortCut \"$DESKTOP\\"
<< linkName << ".lnk\" \"$INSTDIR\\bin\\" << execName << ".exe\""
<< linkName << ".lnk\" \"$INSTDIR\\"
<< cpackNsisExecutablesDirectory << execName << ".exe\""
<< std::endl;
deleteStr << " StrCmp \"$INSTALL_DESKTOP\" \"1\" 0 +2\n";
deleteStr << " Delete \"$DESKTOP\\" << linkName
Expand All @@ -492,6 +513,7 @@ int cmCPackNSISGenerator::InitializeInternal()
deleteStr.str().c_str());
}
this->SetOptionIfNotSet("CPACK_NSIS_COMPRESSOR", "lzma");
this->SetOptionIfNotSet("CPACK_NSIS_EXECUTABLES_DIRECTORY", "bin\\");

return this->Superclass::InitializeInternal();
}
Expand Down