Changeset - r24245:1e4a8434fc12
[Not reviewed]
master
31 1 10
Patric Stout - 5 years ago 2019-04-07 10:00:36
truebrain@openttd.org
Add: create bundles via CPack

CPack works closely together with CMake to do the right thing in
terms of bundling (called 'package'). This generates all the
packaging we need, and some more.
42 files changed with 231 insertions and 2629 deletions:
0 comments (0 inline, 0 general)
CMakeLists.txt
Show inline comments
 
@@ -224,3 +224,5 @@ endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
 

	
 
include(CreateRegression)
 
create_regression()
 

	
 
include(InstallAndPackage)
CPackProperties.cmake.in
Show inline comments
 
new file 100644
 
# Make the current version available to CPack
 
set(CPACK_PACKAGE_VERSION "@REV_VERSION@")
 

	
 
# Name the output file with the correct version
 
string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_FILE_NAME}")
 

	
 
if (CPACK_BUNDLE_PLIST_SOURCE)
 
    # Rewrite the Info.plist.in to contain the correct version
 
    file(READ ${CPACK_BUNDLE_PLIST_SOURCE} INFO_PLIST_CONTENT)
 
    string(REPLACE "#CPACK_PACKAGE_VERSION#" "@REV_VERSION@" INFO_PLIST_CONTENT "${INFO_PLIST_CONTENT}")
 
    file(WRITE ${CPACK_BUNDLE_PLIST} "${INFO_PLIST_CONTENT}")
 
endif (CPACK_BUNDLE_PLIST_SOURCE)
cmake/InstallAndPackage.cmake
Show inline comments
 
new file 100644
 
# If requested, use FHS layout; otherwise fall back to a flat layout.
 
if (OPTION_INSTALL_FHS)
 
    set(BINARY_DESTINATION_DIR "bin")
 
    set(DATA_DESTINATION_DIR "share/games/openttd")
 
    set(DOCS_DESTINATION_DIR "share/doc/openttd")
 
    set(MAN_DESTINATION_DIR "share/man/openttd")
 
else (OPTION_INSTALL_FHS)
 
    set(BINARY_DESTINATION_DIR ".")
 
    set(DATA_DESTINATION_DIR ".")
 
    set(DOCS_DESTINATION_DIR ".")
 
    set(MAN_DESTINATION_DIR ".")
 
endif (OPTION_INSTALL_FHS)
 

	
 
install(TARGETS openttd
 
        RUNTIME
 
            DESTINATION ${BINARY_DESTINATION_DIR}
 
            COMPONENT Runtime
 
        )
 

	
 
install(DIRECTORY
 
                ${CMAKE_BINARY_DIR}/lang
 
                ${CMAKE_BINARY_DIR}/baseset
 
                ${CMAKE_SOURCE_DIR}/bin/ai
 
                ${CMAKE_SOURCE_DIR}/bin/game
 
                ${CMAKE_SOURCE_DIR}/bin/scripts
 
        DESTINATION ${DATA_DESTINATION_DIR}
 
        COMPONENT language_files)
 

	
 
install(FILES
 
                ${CMAKE_SOURCE_DIR}/COPYING.md
 
                ${CMAKE_SOURCE_DIR}/README.md
 
                ${CMAKE_SOURCE_DIR}/changelog.txt
 
                ${CMAKE_SOURCE_DIR}/docs/multiplayer.md
 
                ${CMAKE_SOURCE_DIR}/known-bugs.txt
 
        DESTINATION ${DOCS_DESTINATION_DIR}
 
        COMPONENT docs)
 

	
 
# A Linux manual only makes sense when using FHS. Otherwise it is a very odd
 
# file with little context to what it is.
 
if (OPTION_INSTALL_FHS)
 
    install(FILES
 
                    ${CMAKE_SOURCE_DIR}/docs/openttd.6
 
            DESTINATION ${MAN_DESTINATION_DIR}
 
            COMPONENT manual)
 
endif (OPTION_INSTALL_FHS)
 

	
 
# TODO -- Media files
 
# TODO -- Menu files
 

	
 
if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
 
    set(ARCHITECTURE "amd64")
 
else (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
 
    string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" ARCHITECTURE)
 
endif (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64")
 

	
 
# Windows is a bit more annoying to detect; using the size of void pointer
 
# seems to be the most robust.
 
if (WIN32)
 
    if (CMAKE_SIZEOF_VOID_P EQUAL 8)
 
        set(ARCHITECTURE "win64")
 
    else (CMAKE_SIZEOF_VOID_P EQUAL 8)
 
        set(ARCHITECTURE "win32")
 
    endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
 
endif (WIN32)
 

	
 
set(CPACK_SYSTEM_NAME "${ARCHITECTURE}")
 

	
 
set(CPACK_PACKAGE_NAME "openttd")
 
set(CPACK_PACKAGE_VENDOR "OpenTTD")
 
set(CPACK_PACKAGE_DESCRIPTION "OpenTTD")
 
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenTTD")
 
set(CPACK_PACKAGE_HOMEPAGE_URL "https://www.openttd.org/")
 
set(CPACK_PACKAGE_CONTACT "OpenTTD <info@openttd.org>")
 
set(CPACK_PACKAGE_INSTALL_DIRECTORY "OpenTTD")
 
set(CPACK_PACKAGE_CHECKSUM "SHA256")
 
set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/COPYING.md")
 
set(CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README.md")
 
set(CPACK_MONOLITHIC_INSTALL YES)
 
set(CPACK_PACKAGE_EXECUTABLES "openttd;OpenTTD")
 
set(CPACK_STRIP_FILES YES)
 
set(CPACK_OUTPUT_FILE_PREFIX "bundles")
 

	
 
if (APPLE)
 
    set(CPACK_GENERATOR "Bundle")
 
    include(PackageBundle)
 

	
 
    set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-macosx")
 
elseif (WIN32)
 
    set(CPACK_GENERATOR "ZIP;NSIS")
 
    include(PackageNSIS)
 

	
 
    set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-windows-${CPACK_SYSTEM_NAME}")
 
elseif (UNIX)
 
    # With FHS, we can create deb/rpm/... Without it, they would be horribly broken
 
    # and not work. The other way around is also true; with FHS they are not
 
    # usable, and only flat formats work.
 
    if (OPTION_INSTALL_FHS)
 
        set(CPACK_GENERATOR "DEB")
 
        include(PackageDeb)
 
    else (OPTION_INSTALL_FHS)
 
        set(CPACK_GENERATOR "TXZ")
 
    endif (OPTION_INSTALL_FHS)
 

	
 
    set(CPACK_PACKAGE_FILE_NAME "openttd-#CPACK_PACKAGE_VERSION#-linux-${CPACK_SYSTEM_NAME}")
 
else ()
 
    message(FATAL_ERROR "Unknown OS found for packaging; please consider creating a Pull Request to add support for this OS.")
 
endif ()
 

	
 
include(CPack)
cmake/PackageBundle.cmake
Show inline comments
 
new file 100644
 
string(TIMESTAMP CURRENT_YEAR "%Y")
 

	
 
set(CPACK_BUNDLE_NAME "OpenTTD")
 
set(CPACK_BUNDLE_ICON "${CMAKE_SOURCE_DIR}/os/macosx/openttd.icns")
 
set(CPACK_BUNDLE_PLIST "${CMAKE_CURRENT_BINARY_DIR}/Info.plist")
 
set(CPACK_BUNDLE_STARTUP_COMMAND "${CMAKE_SOURCE_DIR}/os/macosx/launch.sh")
 
set(CPACK_DMG_BACKGROUND_IMAGE "${CMAKE_SOURCE_DIR}/os/macosx/splash.png")
 

	
 
# Create a temporary Info.plist.in, where we will fill in the version via
 
# CPackProperties.cmake.in. This because at this point in time the version
 
# is not yet known.
 
configure_file("${CMAKE_SOURCE_DIR}/os/macosx/Info.plist.in" "${CMAKE_CURRENT_BINARY_DIR}/Info.plist.in")
 
set(CPACK_BUNDLE_PLIST_SOURCE "${CMAKE_CURRENT_BINARY_DIR}/Info.plist.in")
 

	
 
# Delay fixup_bundle() till the install step; this makes sure all executables
 
# exists and it can do its job.
 
install(
 
    CODE
 
    "
 
        include(BundleUtilities)
 
        fixup_bundle(\"\${CMAKE_INSTALL_PREFIX}/openttd\"  \"\" \"\")
 
    "
 
    DESTINATION .
 
    COMPONENT Runtime)
cmake/PackageDeb.cmake
Show inline comments
 
new file 100644
 
set(CPACK_DEBIAN_PACKAGE_ARCHITECTURE "${ARCHITECTURE}")
 
set(CPACK_DEBIAN_PACKAGE_SECTION "games")
 
# TODO -- Fix depends
 
set(CPACK_DEBIAN_PACKAGE_DEPENDS "libc6 (>= 2.15)")
cmake/PackageNSIS.cmake
Show inline comments
 
new file 100644
 
set(CPACK_NSIS_ENABLE_UNINSTALL_BEFORE_INSTALL ON)
 
set(CPACK_NSIS_HELP_LINK "${CPACK_PACKAGE_HOMEPAGE_URL}")
 
set(CPACK_NSIS_URL_INFO_ABOUT "${CPACK_PACKAGE_HOMEPAGE_URL}")
 
set(CPACK_NSIS_CONTACT "${CPACK_PACKAGE_CONTACT}")
 

	
 
# NSIS uses this for the icon in the top left of the installer
 
set(CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-top.bmp")
 

	
 
# Set other icons and bitmaps for NSIS
 
set(CPACK_NSIS_MUI_ICON "${CMAKE_SOURCE_DIR}/os/windows\\\\openttd.ico")
 
set(CPACK_NSIS_MUI_UNIICON "${CMAKE_SOURCE_DIR}/os/windows\\\\openttd.ico")
 
set(CPACK_NSIS_MUI_WELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-welcome.bmp")
 
set(CPACK_NSIS_MUI_UNWELCOMEFINISHPAGE_BITMAP "${CMAKE_SOURCE_DIR}/os/windows\\\\nsis-welcome.bmp")
 

	
 
# Use the icon of the application
 
set(CPACK_NSIS_INSTALLED_ICON_NAME "openttd.exe")
 
# Tell NSIS the binary will be in the root
 
set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".")
 

	
 
# Add detail information on the NSIS installer executable. CPack doesn't
 
# support this out of the box, so we use CPACK_NSIS_DEFINES for this.
 

	
 
# \\\ are needed, because this value is generated in another CPack file,
 
# which is used. So one \ is to escape here, the second to escape in the
 
# CPack file, which we have to escape here (hence: 3 \).
 
set(CPACK_NSIS_DEFINES "
 
; Version Info
 
Var AddWinPrePopulate
 
VIProductVersion \\\"0.0.0.0\\\"
 
VIAddVersionKey \\\"ProductName\\\" \\\"OpenTTD Installer for Windows\\\"
 
VIAddVersionKey \\\"Comments\\\" \\\"Installs OpenTTD \\\${VERSION}\\\"
 
VIAddVersionKey \\\"CompanyName\\\" \\\"OpenTTD Developers\\\"
 
VIAddVersionKey \\\"FileDescription\\\" \\\"Installs OpenTTD \\\${VERSION}\\\"
 
VIAddVersionKey \\\"ProductVersion\\\" \\\"\\\${VERSION}\\\"
 
VIAddVersionKey \\\"InternalName\\\" \\\"InstOpenTTD\\\"
 
VIAddVersionKey \\\"FileVersion\\\" \\\"0.0.0.0\\\"
 
VIAddVersionKey \\\"LegalCopyright\\\" \\\" \\\"
 
"
 
)
media/openttd.ico
Show inline comments
 
deleted file
 
binary diff not shown
os/debian/NEWS
Show inline comments
 
deleted file
os/debian/README.Debian
Show inline comments
 
deleted file
os/debian/changelog
Show inline comments
 
deleted file
os/debian/compat
Show inline comments
 
deleted file
os/debian/control
Show inline comments
 
deleted file
os/debian/copyright
Show inline comments
 
deleted file
os/debian/gbp.conf
Show inline comments
 
deleted file
os/debian/menu
Show inline comments
 
deleted file
os/debian/openttd-wrapper
Show inline comments
 
deleted file
os/debian/patches/run-openttd-wrapper.patch
Show inline comments
 
deleted file
os/debian/patches/series
Show inline comments
 
deleted file
os/debian/rules
Show inline comments
 
deleted file
os/debian/source/format
Show inline comments
 
deleted file
os/debian/watch
Show inline comments
 
deleted file
os/macosx/Info.plist.in
Show inline comments
 
new file 100644
 
<?xml version="1.0" encoding="UTF-8"?>
 
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN"
 
          "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
 
<plist version="1.0">
 
<dict>
 
        <key>CFBundleDevelopmentRegion</key>
 
        <string>English</string>
 
        <key>CFBundleDisplayName</key>
 
        <string>${CPACK_BUNDLE_NAME}</string>
 
        <key>CFBundleExecutable</key>
 
        <string>${CPACK_BUNDLE_NAME}</string>
 
        <key>CFBundleGetInfoString</key>
 
        <string>#CPACK_PACKAGE_VERSION#, Copyright 2004-${CURRENT_YEAR} The OpenTTD team</string>
 
        <key>CFBundleIconFile</key>
 
        <string>${CPACK_BUNDLE_NAME}.icns</string>
 
        <key>CFBundleIdentifier</key>
 
        <string>org.openttd.openttd</string>
 
        <key>CFBundleInfoDictionaryVersion</key>
 
        <string>6.0</string>
 
        <key>CFBundleName</key>
 
        <string>${CPACK_BUNDLE_NAME}</string>
 
        <key>CFBundlePackageType</key>
 
        <string>APPL</string>
 
        <key>CFBundleShortVersionString</key>
 
        <string>#CPACK_PACKAGE_VERSION#</string>
 
        <key>CFBundleVersion</key>
 
        <string>#CPACK_PACKAGE_VERSION#</string>
 
        <key>NSHumanReadableCopyright</key>
 
        <string>Copyright 2004-${CURRENT_YEAR} The OpenTTD team</string>
 
        <key>NSPrincipalClass</key>
 
        <string>NSApplication</string>
 
</dict>
 
</plist>
os/macosx/launch.sh
Show inline comments
 
new file 100644
 
#!/bin/sh
 

	
 
ROOT_DIR=$(dirname "$0")/..
 

	
 
export DYLD_LIBRARY_PATH=${ROOT_DIR}/Frameworks
 

	
 
cd ${ROOT_DIR}/Resources
 
exec ./openttd "$@"
os/macosx/plistgen.sh
Show inline comments
 
deleted file
os/morphos/icons/OpenTTD.info
Show inline comments
 
deleted file
 
binary diff not shown
os/morphos/icons/docs.info
Show inline comments
 
deleted file
 
binary diff not shown
os/morphos/icons/document.info
Show inline comments
 
deleted file
 
binary diff not shown
os/morphos/icons/drawer.info
Show inline comments
 
deleted file
 
binary diff not shown
os/rpm/openttd-rpmlintrc
Show inline comments
 
deleted file
os/rpm/openttd.changes
Show inline comments
 
deleted file
os/rpm/openttd.spec
Show inline comments
 
deleted file
os/windows/installer/build_installers.bat
Show inline comments
 
deleted file
os/windows/installer/cdfinder.ini
Show inline comments
 
deleted file
os/windows/installer/install.nsi
Show inline comments
 
deleted file
os/windows/installer/top.bmp
Show inline comments
 
deleted file
 
binary diff not shown
Show images
os/windows/installer/version_win32.txt
Show inline comments
 
deleted file
os/windows/installer/version_win64.txt
Show inline comments
 
deleted file
os/windows/installer/version_win9x.txt
Show inline comments
 
deleted file
os/windows/installer/welcome.bmp
Show inline comments
 
deleted file
 
binary diff not shown
Show images
os/windows/nsis-top.bmp
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
os/windows/nsis-welcome.bmp
Show inline comments
 
new file 100644
 
binary diff not shown
Show images
os/windows/openttd.ico
Show inline comments
 
new file 100644
 
binary diff not shown
0 comments (0 inline, 0 general)