# The release: a folder the player unpacks anywhere and runs dgen from. `cmake --install
# <build> --prefix <folder>` makes it; `cpack` in the build folder packs it (a .tar.gz on Linux,
# a .zip on Windows). build-release.sh does both for either system.
#
#   dgen (dgen.exe)          the game
#   libSDL3.so.0 (SDL3.dll)  SDL, which dgen finds beside it
#   GameData/README.txt      where the player's copy of the original goes
#   README.md, LICENSE       the port and its licence (GPL-3.0-or-later)
#   licenses/                the licences of what it is built with
#
# dgen.ini and Saves/ are written beside dgen as the game runs (platform/host.hpp).

option(DGEN_BUNDLE_SDL "Put the SDL3 library dgen was built with into the release folder" ON)

install(TARGETS dgen RUNTIME DESTINATION .)
if(DGEN_BUNDLE_SDL)
    install(IMPORTED_RUNTIME_ARTIFACTS SDL3::SDL3-shared DESTINATION .)
endif()
install(FILES GameData/README.txt DESTINATION GameData)
install(FILES ${PROJECT_SOURCE_DIR}/README.md ${PROJECT_SOURCE_DIR}/LICENSE DESTINATION .)
install(FILES licenses/SDL3.txt DESTINATION licenses)
install(FILES ${PROJECT_SOURCE_DIR}/third_party/nuked-opl3/LICENSE
        DESTINATION licenses RENAME Nuked-OPL3.txt)
install(FILES ${PROJECT_SOURCE_DIR}/third_party/modern-dos/README.md
        DESTINATION licenses RENAME ModernDOS8x8.txt)

if(WIN32)
    set(DGEN_SYSTEM windows)
    set(CPACK_GENERATOR ZIP)
else()
    set(DGEN_SYSTEM linux)
    set(CPACK_GENERATOR TGZ)
endif()
string(TOLOWER "${CMAKE_SYSTEM_PROCESSOR}" DGEN_PROCESSOR)
if(DGEN_PROCESSOR STREQUAL "amd64")
    set(DGEN_PROCESSOR x86_64)
endif()
set(CPACK_PACKAGE_NAME dgen)
set(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
set(CPACK_PACKAGE_FILE_NAME "dgen-${PROJECT_VERSION}-${DGEN_SYSTEM}-${DGEN_PROCESSOR}")
set(CPACK_INCLUDE_TOPLEVEL_DIRECTORY ON)
set(CPACK_STRIP_FILES ON)
set(CPACK_SOURCE_GENERATOR "")
include(CPack)
