From 8918a72d9d11a5518139c9450bb28a4561b9672d Mon Sep 17 00:00:00 2001 From: David Olofson Date: Thu, 2 Feb 2017 00:16:27 +0100 Subject: [PATCH] Build Win32 ZIP archives Managed to coax CPack into building Win32 ZIP archives, but it's an ugly hack, and CMake is being a bit retarded, so the archives need a bit of post build cleaning (done by the script) - but it works! Just don't try to 'make install' on the mingw-* builds as set up by the cfg-all script; with -DWIN32_ZIP_BUILD=ON... :-) Closes #351. --- CMakeLists.txt | 50 ++++++++++++++++++++++++++++++++++++++-------- build-packages | 7 +++++++ src/CMakeLists.txt | 2 +- 3 files changed, 50 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ff30905..6b102cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,18 +8,27 @@ set(VERSION_PATCH 2) set(VERSION_BUILD 0) option(DEMO_BUILD "Build Kobo Redux demo." OFF) +option(WIN32_ZIP_BUILD "Build flat Win32 ZIP archive." OFF) if(DEMO_BUILD) # Demo build differcences: # - Append "-demo" to the package/install dir/... name. # - Exclude the mono and chip themes. # - Install the Kobo Redux Demo themes. - set(KOBO_PACKAGE_NAME "koboredux-demo") + if(WIN32) + set(KOBO_PACKAGE_NAME "KoboRedux-Demo") + else(WIN32) + set(KOBO_PACKAGE_NAME "koboredux-demo") + endif(WIN32) set(DEMO_EXCLUDE_GFX PATTERN mono EXCLUDE) set(DEMO_EXCLUDE_SFX PATTERN chip EXCLUDE) set(EXT_DATA_DIR "${KOBOREDUX_SOURCE_DIR}/demo-data") else(DEMO_BUILD) - set(KOBO_PACKAGE_NAME "koboredux") + if(WIN32) + set(KOBO_PACKAGE_NAME "KoboRedux") + else(WIN32) + set(KOBO_PACKAGE_NAME "koboredux") + endif(WIN32) set(DEMO_EXCLUDE_GFX "") set(DEMO_EXCLUDE_SFX "") set(EXT_DATA_DIR "${KOBOREDUX_SOURCE_DIR}/full-data") @@ -43,18 +52,30 @@ set(CMAKE_C_FLAGS_MAINTAINER "${f} -Werror") set(f "${f} -DDEBUG") set(CMAKE_C_FLAGS_DEBUG ${f}) +if(WIN32 AND WIN32_ZIP_BUILD) + # Of course, you're not supposed to use 'make install' when using this! + # This is a dirty hack to build Win32 ZIP archives. + set(KOBO_BIN_DIR "/") + set(KOBO_SHARE_DIR "/") + set(KOBO_DOC_DIR "/") +else(WIN32 AND WIN32_ZIP_BUILD) + set(KOBO_BIN_DIR "bin") + set(KOBO_SHARE_DIR "share/${KOBO_PACKAGE_NAME}") + set(KOBO_DOC_DIR "share/doc/${KOBO_PACKAGE_NAME}") +endif(WIN32 AND WIN32_ZIP_BUILD) + add_subdirectory(src) # Game data files install(DIRECTORY data/gfx "${EXT_DATA_DIR}/gfx" - DESTINATION "share/${KOBO_PACKAGE_NAME}" + DESTINATION "${KOBO_SHARE_DIR}" FILES_MATCHING ${DEMO_EXCLUDE_GFX} PATTERN "*.png" PATTERN "*.gpl" PATTERN "*.theme") install(DIRECTORY data/sfx "${EXT_DATA_DIR}/sfx" - DESTINATION "share/${KOBO_PACKAGE_NAME}" + DESTINATION "${KOBO_SHARE_DIR}" FILES_MATCHING ${DEMO_EXCLUDE_SFX} PATTERN "*.a2s") @@ -65,7 +86,7 @@ file(GLOB doc_files "${KOBOREDUX_SOURCE_DIR}/LICENSE*") list(REMOVE_ITEM doc_files "${KOBOREDUX_SOURCE_DIR}/INSTALL.md") install(FILES ${doc_files} - DESTINATION "share/doc/${KOBO_PACKAGE_NAME}") + DESTINATION "${KOBO_DOC_DIR}") # Desktop entry if(NOT WIN32) @@ -80,7 +101,7 @@ endif(NOT WIN32) # License agreement for proprietary data, if any if(WIN32) install(FILES "${EXT_DATA_DIR}/EULA.txt" - DESTINATION "share/doc/${KOBO_PACKAGE_NAME}" + DESTINATION "${KOBO_DOC_DIR}" OPTIONAL) else(WIN32) file(REMOVE "copyright") @@ -91,11 +112,24 @@ else(WIN32) endif() string(REPLACE "\r" "" cpr ${cpr}) file(WRITE "copyright" ${cpr}) - install(FILES "copyright" DESTINATION "share/doc/${KOBO_PACKAGE_NAME}") + install(FILES "copyright" + DESTINATION "${KOBO_DOC_DIR}") +endif(WIN32) + +# Win32 redistributables (SDL2, Audiality 2, libstdc++ etc) +if(WIN32) + install(FILES "${KOBOREDUX_SOURCE_DIR}/win32-redist/" + DESTINATION "${KOBO_BIN_DIR}") endif(WIN32) # CPack general -set(CPACK_GENERATOR "DEB" "RPM" "TBZ2") +if(WIN32) + # Windows ZIP archive + set(CPACK_GENERATOR "ZIP") +else(WIN32) + # Linux packages + set(CPACK_GENERATOR "DEB" "RPM" "TBZ2") +endif(WIN32) set(CPACK_SET_DESTDIR ON) set(CPACK_PACKAGE_RELOCATABLE false) set(CPACK_STRIP_FILES true) diff --git a/build-packages b/build-packages index 3b96251..ae00812 100755 --- a/build-packages +++ b/build-packages @@ -7,6 +7,7 @@ fi ./install-demo-data ./install-full-data +./install-win32-redist if [ $# -eq 0 ]; then FILTER=@(*release|*demo) @@ -35,3 +36,9 @@ for i in $BUILDDIR/$FILTER ; do echo "[ Leaving $(basename $i) ]" echo done + +# HAX: Can't get CPack to stop adding those bogus directories... +for a in ${PKGDIR}/KoboRedux-*-win32.zip ; do + echo $a + zip -d $a */home/* +done diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8cd7f64..8f35a99 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -160,4 +160,4 @@ set(KOBOREDUX_AUTO_MESSAGE configure_file(${CMAKE_SOURCE_DIR}/buildconfig.h.cmake ${CMAKE_BINARY_DIR}/include/buildconfig.h) -install(TARGETS kobord DESTINATION bin) +install(TARGETS kobord DESTINATION "${KOBO_BIN_DIR}")