ENH: Several NSIS features
This commit is contained in:
parent
69ca764212
commit
1d96f839d7
|
@ -16,6 +16,8 @@ cpack_set_if_not_set(CPACK_PACKAGE_NAME "${PROJECT_NAME}")
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MAJOR "0")
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_MINOR "1")
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION_PATCH "1")
|
||||||
|
cpack_set_if_not_set(CPACK_PACKAGE_VERSION
|
||||||
|
"${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
|
cpack_set_if_not_set(CPACK_PACKAGE_VENDOR "Humanity")
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_SUMMARY
|
||||||
"${PROJECT_NAME} built using CMake")
|
"${PROJECT_NAME} built using CMake")
|
||||||
|
@ -25,6 +27,10 @@ cpack_set_if_not_set(CPACK_PACKAGE_DESCRIPTION_FILE
|
||||||
# <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
|
# <project>-<major>.<minor>.<patch>-<release>-<platform>.<pkgtype>
|
||||||
cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
|
cpack_set_if_not_set(CPACK_PACKAGE_FILE_NAME
|
||||||
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}")
|
"${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}-${CMAKE_SYSTEM_NAME}")
|
||||||
|
cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_DIRECTORY
|
||||||
|
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
|
||||||
|
cpack_set_if_not_set(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
|
||||||
|
"${CPACK_PACKAGE_NAME} ${CPACK_PACKAGE_VERSION}")
|
||||||
|
|
||||||
IF(NOT EXISTS "${CPACK_PACKAGE_DESCRIPTION_FILE}")
|
IF(NOT EXISTS "${CPACK_PACKAGE_DESCRIPTION_FILE}")
|
||||||
MESSAGE(SEND_ERROR "CPack package description file: \"${CPACK_PACKAGE_DESCRIPTION_FILE}\" could not be found.")
|
MESSAGE(SEND_ERROR "CPack package description file: \"${CPACK_PACKAGE_DESCRIPTION_FILE}\" could not be found.")
|
||||||
|
@ -36,7 +42,7 @@ IF(NOT CPACK_GENERATOR)
|
||||||
IF(APPLE)
|
IF(APPLE)
|
||||||
SET(CPACK_GENERATOR "PackageMaker")
|
SET(CPACK_GENERATOR "PackageMaker")
|
||||||
ELSE(APPLE)
|
ELSE(APPLE)
|
||||||
SET(CPACK_GENERATOR "TGZ")
|
SET(CPACK_GENERATOR "STGZ")
|
||||||
ENDIF(APPLE)
|
ENDIF(APPLE)
|
||||||
ELSE(UNIX)
|
ELSE(UNIX)
|
||||||
SET(CPACK_GENERATOR "NSIS")
|
SET(CPACK_GENERATOR "NSIS")
|
||||||
|
@ -50,6 +56,7 @@ SET(CPACK_BINARY_DIR "${CMAKE_BINARY_DIR}")
|
||||||
# Search for system runtime libraries based on the platform. This is
|
# Search for system runtime libraries based on the platform. This is
|
||||||
# not complete because it is used only for the release process by the
|
# not complete because it is used only for the release process by the
|
||||||
# developers.
|
# developers.
|
||||||
|
IF(NOT CPACK_DISABLE_EXTRA_MSVC_LIBRARIES)
|
||||||
IF(MSVC)
|
IF(MSVC)
|
||||||
STRING(REGEX REPLACE "\\\\" "/" SYSTEMROOT "$ENV{SYSTEMROOT}")
|
STRING(REGEX REPLACE "\\\\" "/" SYSTEMROOT "$ENV{SYSTEMROOT}")
|
||||||
FOREACH(lib
|
FOREACH(lib
|
||||||
|
@ -63,6 +70,7 @@ IF(MSVC)
|
||||||
ENDIF(EXISTS ${lib})
|
ENDIF(EXISTS ${lib})
|
||||||
ENDFOREACH(lib)
|
ENDFOREACH(lib)
|
||||||
ENDIF(MSVC)
|
ENDIF(MSVC)
|
||||||
|
ENDIF(NOT CPACK_DISABLE_EXTRA_MSVC_LIBRARIES)
|
||||||
|
|
||||||
# Include system runtime libraries in the installation if any are
|
# Include system runtime libraries in the installation if any are
|
||||||
# specified by CMake_INSTALL_SYSTEM_RUNTIME_LIBS.
|
# specified by CMake_INSTALL_SYSTEM_RUNTIME_LIBS.
|
||||||
|
|
|
@ -19,7 +19,7 @@
|
||||||
!include "MUI.nsh"
|
!include "MUI.nsh"
|
||||||
|
|
||||||
;Default installation folder
|
;Default installation folder
|
||||||
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_NAME@ ${VERSION}"
|
InstallDir "$PROGRAMFILES\@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
; determine admin versus local install
|
; determine admin versus local install
|
||||||
|
@ -51,7 +51,7 @@ FunctionEnd
|
||||||
;General
|
;General
|
||||||
|
|
||||||
;Name and file
|
;Name and file
|
||||||
Name "@CPACK_PACKAGE_NAME@ ${VERSION}"
|
Name "@CPACK_PACKAGE_INSTALL_DIRECTORY@"
|
||||||
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
|
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
|
||||||
|
|
||||||
;--------------------------------
|
;--------------------------------
|
||||||
|
@ -312,7 +312,7 @@ FunctionEnd
|
||||||
|
|
||||||
;Start Menu Folder Page Configuration
|
;Start Menu Folder Page Configuration
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
|
!define MUI_STARTMENUPAGE_REGISTRY_ROOT "SHCTX"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_NAME@ ${VERSION}"
|
!define MUI_STARTMENUPAGE_REGISTRY_KEY "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||||
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
!define MUI_STARTMENUPAGE_REGISTRY_VALUENAME "Start Menu Folder"
|
||||||
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
!insertmacro MUI_PAGE_STARTMENU Application $STARTMENU_FOLDER
|
||||||
|
|
||||||
|
@ -344,10 +344,8 @@ Section "Dummy Section" SecDummy
|
||||||
SetOutPath "$INSTDIR"
|
SetOutPath "$INSTDIR"
|
||||||
File /r "${INST_DIR}\*.*"
|
File /r "${INST_DIR}\*.*"
|
||||||
|
|
||||||
@CPACK_NSIS_EXTRA_COMMANDS@
|
|
||||||
|
|
||||||
;Store installation folder
|
;Store installation folder
|
||||||
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_NAME@ ${VERSION}" "" $INSTDIR
|
WriteRegStr SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@" "" $INSTDIR
|
||||||
|
|
||||||
;Create uninstaller
|
;Create uninstaller
|
||||||
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
WriteUninstaller "$INSTDIR\Uninstall.exe"
|
||||||
|
@ -360,6 +358,8 @@ Section "Dummy Section" SecDummy
|
||||||
@CPACK_NSIS_CREATE_EXTRA_ICONS@
|
@CPACK_NSIS_CREATE_EXTRA_ICONS@
|
||||||
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
CreateShortCut "$SMPROGRAMS\$STARTMENU_FOLDER\Uninstall.lnk" "$INSTDIR\Uninstall.exe"
|
||||||
|
|
||||||
|
@CPACK_NSIS_EXTRA_INSTALL_COMMANDS@
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_WRITE_END
|
!insertmacro MUI_STARTMENU_WRITE_END
|
||||||
|
|
||||||
SectionEnd
|
SectionEnd
|
||||||
|
@ -395,6 +395,8 @@ FunctionEnd
|
||||||
|
|
||||||
Section "Uninstall"
|
Section "Uninstall"
|
||||||
|
|
||||||
|
@CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS@
|
||||||
|
|
||||||
;Remove files we installed.
|
;Remove files we installed.
|
||||||
;Keep the list of directories here in sync with the File commands above.
|
;Keep the list of directories here in sync with the File commands above.
|
||||||
@CPACK_NSIS_DELETE_FILES@
|
@CPACK_NSIS_DELETE_FILES@
|
||||||
|
@ -407,7 +409,7 @@ Section "Uninstall"
|
||||||
RMDir "$INSTDIR"
|
RMDir "$INSTDIR"
|
||||||
|
|
||||||
; Remove the registry entries.
|
; Remove the registry entries.
|
||||||
DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_NAME@ ${VERSION}"
|
DeleteRegKey SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||||
|
|
||||||
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
|
!insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
|
||||||
|
|
||||||
|
@ -428,7 +430,7 @@ Section "Uninstall"
|
||||||
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
|
StrCmp $MUI_TEMP $SMPROGRAMS startMenuDeleteLoopDone startMenuDeleteLoop
|
||||||
startMenuDeleteLoopDone:
|
startMenuDeleteLoopDone:
|
||||||
|
|
||||||
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_NAME@ ${VERSION}"
|
DeleteRegKey /ifempty SHCTX "Software\@CPACK_PACKAGE_VENDOR@\@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@"
|
||||||
|
|
||||||
Push $INSTDIR\bin
|
Push $INSTDIR\bin
|
||||||
Call un.RemoveFromPath
|
Call un.RemoveFromPath
|
||||||
|
|
|
@ -27,6 +27,7 @@
|
||||||
#include <cmsys/SystemTools.hxx>
|
#include <cmsys/SystemTools.hxx>
|
||||||
#include <cmsys/Glob.hxx>
|
#include <cmsys/Glob.hxx>
|
||||||
#include <cmsys/Directory.hxx>
|
#include <cmsys/Directory.hxx>
|
||||||
|
#include <cmsys/RegularExpression.hxx>
|
||||||
|
|
||||||
//----------------------------------------------------------------------
|
//----------------------------------------------------------------------
|
||||||
cmCPackNSISGenerator::cmCPackNSISGenerator()
|
cmCPackNSISGenerator::cmCPackNSISGenerator()
|
||||||
|
@ -129,8 +130,37 @@ int cmCPackNSISGenerator::Initialize(const char* name, cmMakefile* mf)
|
||||||
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS compiler" << std::endl);
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find NSIS compiler" << std::endl);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
this->SetOption("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
|
std::string nsisCmd = "\"" + nsisPath + "\" /VERSION";
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Test NSIS version: " << nsisCmd.c_str() << std::endl);
|
||||||
|
std::string output;
|
||||||
|
int retVal = 1;
|
||||||
|
bool resS = cmSystemTools::RunSingleCommand(nsisCmd.c_str(), &output, &retVal, 0, m_GeneratorVerbose, 0);
|
||||||
|
|
||||||
|
cmsys::RegularExpression versionRex("v([0-9]+.[0-9]+)");
|
||||||
|
if ( !resS || retVal || !versionRex.find(output))
|
||||||
|
{
|
||||||
|
std::string tmpFile = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
||||||
|
tmpFile += "/NSISOutput.log";
|
||||||
|
cmGeneratedFileStream ofs(tmpFile.c_str());
|
||||||
|
ofs << "# Run command: " << nsisCmd.c_str() << std::endl
|
||||||
|
<< "# Output:" << std::endl
|
||||||
|
<< output.c_str() << std::endl;
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem checking NSIS version with command: " << nsisCmd.c_str() << std::endl
|
||||||
|
<< "Please check " << tmpFile.c_str() << " for errors" << std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
float nsisVersion = atof(versionRex.match(1).c_str());
|
||||||
|
float minNSISVersion = 2.09;
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_DEBUG, "NSIS Version: "
|
||||||
|
<< nsisVersion << std::endl);
|
||||||
|
if ( nsisVersion < minNSISVersion )
|
||||||
|
{
|
||||||
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "CPack requires NSIS Version 2.09 or greater. NSIS found on the system was: "
|
||||||
|
<< nsisVersion << std::endl);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
this->SetOption("CPACK_INSTALLER_PROGRAM", nsisPath.c_str());
|
||||||
const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
|
const char* cpackPackageExecutables = this->GetOption("CPACK_PACKAGE_EXECUTABLES");
|
||||||
if ( cpackPackageExecutables )
|
if ( cpackPackageExecutables )
|
||||||
{
|
{
|
||||||
|
|
|
@ -1,7 +1,8 @@
|
||||||
SET(CPACK_GENERATOR "@CPACK_GENERATOR@")
|
SET(CPACK_GENERATOR "@CPACK_GENERATOR@")
|
||||||
|
|
||||||
SET(CPACK_PACKAGE_NAME "@CPACK_PACKAGE_NAME@")
|
SET(CPACK_PACKAGE_NAME "@CPACK_PACKAGE_NAME@")
|
||||||
|
SET(CPACK_PACKAGE_INSTALL_DIRECTORY "@CPACK_PACKAGE_INSTALL_DIRECTORY@")
|
||||||
|
SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY "@CPACK_PACKAGE_INSTALL_REGISTRY_KEY@")
|
||||||
SET(CPACK_PACKAGE_VERSION_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@")
|
SET(CPACK_PACKAGE_VERSION_MAJOR "@CPACK_PACKAGE_VERSION_MAJOR@")
|
||||||
SET(CPACK_PACKAGE_VERSION_MINOR "@CPACK_PACKAGE_VERSION_MINOR@")
|
SET(CPACK_PACKAGE_VERSION_MINOR "@CPACK_PACKAGE_VERSION_MINOR@")
|
||||||
SET(CPACK_PACKAGE_VERSION_PATCH "@CPACK_PACKAGE_VERSION_PATCH@")
|
SET(CPACK_PACKAGE_VERSION_PATCH "@CPACK_PACKAGE_VERSION_PATCH@")
|
||||||
|
|
Loading…
Reference in New Issue