Skip to content

Commit

Permalink
Update CPack to use tag in filename and update NSIS package
Browse files Browse the repository at this point in the history
Closes #1611
  • Loading branch information
jwrober committed Jan 1, 2023
1 parent da67a8b commit 8f7ddd2
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 18 deletions.
10 changes: 5 additions & 5 deletions cmake/AutoRevision.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -83,9 +83,9 @@ if (NOT ok)
endif()

# Manipulate the tag so we can turn it into a list for use later
string(STRIP "${FC21_REV_TAG}" FC21_REV_TAG)
string(REPLACE "v" "" FC21_REV_TAG "${FC21_REV_TAG}")
string(REPLACE "." " " FC21_REV_TAG "${FC21_REV_TAG}")
string(REPLACE "-" " " FC21_REV_TAG "${FC21_REV_TAG}")
set(FC21_REV_TAG_LIST ${FC21_REV_TAG})
string(STRIP "${FC21_REV_TAG}" FC21_REV_TAG2)
string(REPLACE "v" "" FC21_REV_TAG2 "${FC21_REV_TAG2}")
string(REPLACE "." " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
string(REPLACE "-" " " FC21_REV_TAG2 "${FC21_REV_TAG2}")
set(FC21_REV_TAG_LIST ${FC21_REV_TAG2})
separate_arguments(FC21_REV_TAG_LIST)
9 changes: 6 additions & 3 deletions cmake/CPackConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ set(CPACK_PACKAGE_CONTACT "longturn.net")
set(CPACK_PACKAGE_VERSION_MAJOR ${FC21_MAJOR_VERSION})
set(CPACK_PACKAGE_VERSION_MINOR ${FC21_MINOR_VERSION})
set(CPACK_PACKAGE_VERSION_PATCH ${FC21_PATCH_VERSION})
set(CPACK_PACKAGE_VERSION ${FREECIV21_VERSION})
set(CPACK_PACKAGE_VERSION ${FC21_REV_TAG})
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Freeciv21 - Freeciv for the 21st Century")
set(CPACK_PACKAGE_HOMEPAGE_URL "https://longturn.net")
set(CMAKE_PROJECT_HOMEPAGE_URL "https://longturn.net")
Expand All @@ -19,6 +19,7 @@ if(WIN32 OR MSYS OR MINGW)

# Use the NSIS Package for Windows
set(CPACK_GENERATOR "NSIS")
set(CPACK_BINARY_NSIS "ON")

# Establish some variables to place the package where we want it
if(NOT CPACK_SYSTEM_NAME)
Expand All @@ -33,7 +34,7 @@ if(WIN32 OR MSYS OR MINGW)
set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/${CPACK_SYSTEM_NAME}")
set(CPACK_OUTPUT_FILE_PREFIX ${CPACK_PACKAGE_DIRECTORY})
# The name of the package exe file
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-v${CPACK_PACKAGE_VERSION}-${CPACK_SYSTEM_NAME}")
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${FC21_REV_TAG}-${CPACK_SYSTEM_NAME}")

## Component definition
# - variable names are UPPER CASE, even if component names are lower case
Expand Down Expand Up @@ -75,7 +76,6 @@ if(WIN32 OR MSYS OR MINGW)
set(CPACK_NSIS_HELP_LINK "${CPACK_PACKAGE_HOMEPAGE_URL}")
set(CPACK_NSIS_URL_INFO_ABOUT "${CPACK_PACKAGE_HOMEPAGE_URL}")
set(CPACK_NSIS_MENU_LINKS "${CPACK_PACKAGE_HOMEPAGE_URL}" "Longturn Homepage")
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL "OFF")
set(CPACK_NSIS_MODIFY_PATH "OFF")
set(CPACK_NSIS_CONTACT "[email protected]")

Expand All @@ -99,9 +99,12 @@ if(UNIX AND NOT APPLE)

set(CPACK_PACKAGE_DIRECTORY "${CMAKE_BINARY_DIR}/${CPACK_SYSTEM_NAME}")
set(CPACK_OUTPUT_FILE_PREFIX ${CPACK_PACKAGE_DIRECTORY})
# The name of the package file
set(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${FC21_REV_TAG}-${CPACK_SYSTEM_NAME}")

# Debian "deb" file generator settings
set(CPACK_GENERATOR "DEB")
set(CPACK_BINARY_DEB "ON")
set(CPACK_DEBIAN_FILE_NAME DEB-DEFAULT)
set(CPACK_DEBIAN_PACKAGE_SECTION "Games")
set(CPACK_COMPONENTS_GROUPING ALL_COMPONENTS_IN_ONE)
Expand Down
33 changes: 23 additions & 10 deletions cmake/NSIS.template.in
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
!define MUI_ICON "@CPACK_NSIS_MUI_ICON@"
!define MUI_UNICON "@CPACK_NSIS_MUI_UNIICON@"
!define MUI_UI_COMPONENTSPAGE_SMALLDESC
!define MUI_LICENSEPAGE_CHECKBOX
!define MUI_LICENSEPAGE_CHECKBOX_TEXT "I agree to the license terms."

;Multi-User Variables
!define MULTIUSER_EXECUTIONLEVEL Highest
Expand All @@ -55,7 +53,7 @@
; General
;#########################################################

Name "${APPNAME} v${VERSION}"
Name "${APPNAME} ${VERSION}"
OutFile "@CPACK_TOPLEVEL_DIRECTORY@/@CPACK_OUTPUT_FILE_NAME@"
ShowInstDetails show
ShowUninstDetails show
Expand Down Expand Up @@ -134,7 +132,6 @@

; Installer Pages
!insertmacro MUI_PAGE_WELCOME
;!insertmacro MUI_PAGE_LICENSE "@CPACK_RESOURCE_FILE_LICENSE@"
!insertmacro MUI_PAGE_COMPONENTS
!insertmacro MULTIUSER_PAGE_INSTALLMODE
!insertmacro MUI_PAGE_DIRECTORY
Expand Down Expand Up @@ -168,19 +165,30 @@
${EndIf}
!macroend

!macro UninstallExisting
Call UninstallExisting
!macroend

;#########################################################
; Funtions
;#########################################################

Function .onInit
SetShellVarContext All
!insertmacro MULTIUSER_INIT
;!insertmacro CheckAdminRights
!insertmacro MULTIUSER_INIT
!insertmacro CheckAdminRights

; We lookup to see if there is a previous installation and prompt to remove.
ReadRegStr $0 "SHCTX" "${REGPATH_UNINSTSUBKEY}" "UninstallString"
${If} $0 != ""
${AndIf} ${Cmd} `MessageBox MB_YESNO|MB_ICONQUESTION "Previous ${APPNAME} installation found. Do you wish to uninstall the previous version?" /SD IDYES IDYES`
!insertmacro UninstallExisting
${EndIf}
FunctionEnd

Function un.onInit
SetShellVarContext All
!insertmacro MULTIUSER_UNINIT
!insertmacro MULTIUSER_UNINIT
FunctionEnd

Function ConditionalAddToRegisty
Expand All @@ -195,6 +203,12 @@
ExecShell "" "$SMPROGRAMS\${APPNAME}\${APPNAME} Client.lnk"
FunctionEnd

Function UninstallExisting
ReadRegStr $0 "SHCTX" "${REGPATH_UNINSTSUBKEY}" "UninstallString"
; Call silent uninstall
ExecWait '"$0" /S'
FunctionEnd

;#########################################################
; Installer Section
;#########################################################
Expand Down Expand Up @@ -249,7 +263,7 @@
Push "Contact"
Push "@CPACK_NSIS_CONTACT@"
Call ConditionalAddToRegisty

; Add fc21:// protocol handler
WriteRegStr HKEY_CLASSES_ROOT "fc21" "URL Protocol" ""
WriteRegStr HKEY_CLASSES_ROOT "fc21\shell\open\command" "" "$INSTDIR\freeciv21-client.exe %1"
Expand Down Expand Up @@ -281,11 +295,10 @@
; Remove entry from Windows "Add/Remove programs" panel.
DeleteRegKey "SHCTX" "${REGPATH_UNINSTSUBKEY}"
DeleteRegKey "SHCTX" "Software\${APPNAME}"
DeleteRegKey HKEY_LOCAL_MACHINE "Software\${APPNAME}"
DeleteRegKey HKEY_CLASSES_ROOT "fc21"

SectionEnd

;#########################################################
; END NSIS.template.in
;#########################################################
;#########################################################

0 comments on commit 8f7ddd2

Please sign in to comment.