From 9796da3c40b80c65e89120d518ad90ba0037f290 Mon Sep 17 00:00:00 2001 From: klei1984 <53688147+klei1984@users.noreply.github.com> Date: Fri, 26 Jan 2024 00:06:37 +0100 Subject: [PATCH] Changes to build scripts - Copy dependencies for test executable on Windows - Add cmake file to assets - Prepare for gnu install directories support on linux - Add custom built library dependencies to linux deb packages - Add license file for binary distributions - Increase download timeout for non github libraries --- CMakeLists.txt | 57 +++++++++---- assets/CMakeLists.txt | 10 +++ assets/LICENSE | 129 ++++++++++++++++++++++++++++++ cmake/freetype.cmake | 2 +- cmake/lib-iconv/CMakeLists.txt.in | 2 +- test/CMakeLists.txt | 7 ++ 6 files changed, 189 insertions(+), 18 deletions(-) create mode 100644 assets/CMakeLists.txt create mode 100644 assets/LICENSE diff --git a/CMakeLists.txt b/CMakeLists.txt index 379bd5ca..26b468db 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ -cmake_minimum_required (VERSION 3.24) +cmake_minimum_required (VERSION 3.5..3.24) project(max LANGUAGES C CXX) -set(CMAKE_POLICY_DEFAULT_CMP0077 NEW) +cmake_policy(SET CMP0077 NEW) option(MAX_BUILD_TESTS "Build unit tests by default" ON) option(MAX_ENABLE_UPNP "Use miniupnpc library" ON) @@ -83,22 +83,16 @@ set(CPACK_PACKAGE_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION set(CPACK_PACKAGE_NAME "max-port") set(CPACK_PACKAGE_CONTACT "M.A.X. Port Team") set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") -set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "M.A.X. Port v${GAME_VERSION}") +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "M.A.X. Port v${GAME_VERSION_STRING}") set(CPACK_PACKAGE_DESCRIPTION "M.A.X. Port is an SDL library based runtime executable for the 1996 MS-DOS game M.A.X.: Mechanized Assault & Exploration developed and published by Interplay Productions.") set(CPACK_SOURCE_IGNORE_FILES "/\.git/;/\.github/;/\.settings/;\.gitignore;.\.launch;\.project;\.cproject;\.clang-format;\.gdbinit;README.md;/doc/;${CMAKE_BINARY_DIR};Debug;Release;RelWithDebInfo;MinSizeRel;/dependencies/.*\.tar\.gz") -install(FILES "LICENSE" DESTINATION .) -install(FILES "assets/PATCHES.RES" DESTINATION .) -install(FILES "assets/settings.ini" DESTINATION .) -install(FILES "assets/lang_english.ini" DESTINATION .) -install(FILES "assets/lang_french.ini" DESTINATION .) -install(FILES "assets/lang_german.ini" DESTINATION .) -install(FILES "assets/lang_italian.ini" DESTINATION .) -install(FILES "assets/lang_spanish.ini" DESTINATION .) - if(UNIX) + include(GNUInstallDirs) set(CPACK_GENERATOR "DEB") set(CPACK_SOURCE_GENERATOR "TGZ") + set(CPACK_DEBIAN_PACKAGE_DEPENDS "") + set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON) set(CPACK_DEBIAN_PACKAGE_SECTION "games") set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://klei1984.github.io/max/") @@ -117,23 +111,52 @@ if(UNIX) set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS ${DEP_BIN_DIRS}) + install(CODE "set(PROJECT_NAME \"${PROJECT_NAME}\")") + install(CODE "set(CMAKE_INSTALL_BINDIR \"${CMAKE_INSTALL_BINDIR}\")") + install(CODE "set(CMAKE_INSTALL_PREFIX \"${CMAKE_INSTALL_PREFIX}\")") + install(CODE "set(CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS \"${DEP_BIN_DIRS}\")") + install(CODE [[ + file(GET_RUNTIME_DEPENDENCIES + EXECUTABLES max + RESOLVED_DEPENDENCIES_VAR DEPS_RESOLVED + UNRESOLVED_DEPENDENCIES_VAR DEPS_UNRESOLVED + CONFLICTING_DEPENDENCIES_PREFIX DEPS_CONFLICTING + DIRECTORIES ${CPACK_DEBIAN_PACKAGE_SHLIBDEPS_PRIVATE_DIRS} + ) + + if(DEPS_CONFLICTING_FILENAMES) + message(WARNING "Conflicting dependencies for library: \"${DEPS_CONFLICTING}\"!") + endif() + + foreach(DEP_FILE ${DEPS_RESOLVED}) + file(INSTALL + FILES "${DEP_FILE}" + FOLLOW_SYMLINK_CHAIN + DESTINATION ${CMAKE_INSTALL_PREFIX} + ) + endforeach() + ]]) + install(TARGETS ${PROJECT_NAME} CONFIGURATIONS ${CMAKE_BUILD_TYPE} - RUNTIME DESTINATION . + RUNTIME DESTINATION ${CMAKE_INSTALL_PREFIX} ) endif() if(MINGW) + set(CMAKE_INSTALL_BINDIR "." CACHE PATH "User executables directory" FORCE) + set(CMAKE_INSTALL_DATADIR "." CACHE PATH "Read-only architecture-independent data directory" FORCE) + include(GNUInstallDirs) set(CPACK_GENERATOR "7Z") set(CPACK_SOURCE_GENERATOR "7Z") find_program(MAKENSIS_EXECUTABLE NAMES makensis${CMAKE_EXECUTABLE_SUFFIX} DOC "The NSIS package maker command") - if (MAKENSIS_EXECUTABLE) + if(MAKENSIS_EXECUTABLE) list(APPEND CPACK_GENERATOR "NSIS") set(CPACK_NSIS_EXECUTABLES_DIRECTORY ".") set(CPACK_NSIS_MUI_FINISHPAGE_RUN "${PROJECT_NAME}") set(CPACK_NSIS_DISPLAY_NAME "M.A.X. Port") - set(CPACK_NSIS_PACKAGE_NAME "M.A.X. Port v${GAME_VERSION}") + set(CPACK_NSIS_PACKAGE_NAME "M.A.X. Port v${GAME_VERSION_STRING}") set(CPACK_NSIS_URL_INFO_ABOUT "https://klei1984.github.io/max/") endif() @@ -142,7 +165,7 @@ if(MINGW) RUNTIME DESTINATION . ) - if (BUILD_SHARED_LIBS) + if(BUILD_SHARED_LIBS) set(DEP_BIN_DIRS) foreach(TARGET_NAME ${${PROJECT_NAME}_deps}) get_target_property(BIN_DIR ${TARGET_NAME} BINARY_DIR) @@ -157,4 +180,6 @@ if(MINGW) endif() endif() +add_subdirectory(assets) + INCLUDE(CPack) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt new file mode 100644 index 00000000..ef16e6b5 --- /dev/null +++ b/assets/CMakeLists.txt @@ -0,0 +1,10 @@ +include(GNUInstallDirs) + +install(FILES "LICENSE" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "PATCHES.RES" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "settings.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "lang_english.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "lang_french.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "lang_german.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "lang_italian.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) +install(FILES "lang_spanish.ini" DESTINATION ${CMAKE_INSTALL_DATADIR}) diff --git a/assets/LICENSE b/assets/LICENSE new file mode 100644 index 00000000..85f338b9 --- /dev/null +++ b/assets/LICENSE @@ -0,0 +1,129 @@ +Files: M.A.X. Port +Copyright: 2020-2024 M.A.X. Port Team +License: MIT + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + . + The above copyright notice and this permission notice shall be included in all + copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +Files: FreeType library +Copyright: 2006-2023 by David Turner, Robert Wilhelm, and Werner Lemberg +License: FreeType License (FTL) + See license file at https://gitlab.freedesktop.org/freetype/freetype/-/blob/ + 920c5502cc3ddda88f6c7d85ee834ac611bb11cc/docs/FTL.TXT + +Files: miniaudio library +Copyright: 2023 David Reid +License: MIT No Attribution + Permission is hereby granted, free of charge, to any person obtaining a copy of + this software and associated documentation files (the "Software"), to deal in + the Software without restriction, including without limitation the rights to + use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies + of the Software, and to permit persons to whom the Software is furnished to do + so. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + SOFTWARE. + +Files: SDL2 library +Copyright: 1997-2023 Sam Lantinga +License: Zlib + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + . + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + . + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + +Files: ENET library +Copyright: 2002-2020 Lee Salzman +License: MIT + Permission is hereby granted, free of charge, to any person obtaining + a copy of this software and associated documentation files (the + "Software"), to deal in the Software without restriction, including + without limitation the rights to use, copy, modify, merge, publish, + distribute, sublicense, and/or sell copies of the Software, and to + permit persons to whom the Software is furnished to do so, subject to + the following conditions: + . + The above copyright notice and this permission notice shall be + included in all copies or substantial portions of the Software. + . + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, + EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND + NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE + LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION + OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION + WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + +Files: libiconv library +Copyright: 1992-2022 Free Software Foundation, Inc. +License: LGPL-2.1+ + This file is free software: you can redistribute it and/or modify + it under the terms of the GNU Lesser General Public License as + published by the Free Software Foundation; either version 2.1 of the + License, or (at your option) any later version. + . + This file is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Lesser General Public License for more details. + . + You should have received a copy of the GNU Lesser General Public License + along with this program. If not, see . + +Files: miniupnpc library +Copyright: 2005-2023, Thomas BERNARD +License: BSD-3-clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are met: + . + 1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + . + 2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + . + 3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" + AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE + DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE + FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/cmake/freetype.cmake b/cmake/freetype.cmake index 2b67e5e0..a47b4a6e 100644 --- a/cmake/freetype.cmake +++ b/cmake/freetype.cmake @@ -11,7 +11,7 @@ endif() FetchContent_Declare( FREETYPE - TIMEOUT 60 + TIMEOUT 120 URL ${FREETYPE_URI} URL_HASH ${FREETYPE_HASH_TYPE}=${FREETYPE_HASH} DOWNLOAD_EXTRACT_TIMESTAMP FALSE diff --git a/cmake/lib-iconv/CMakeLists.txt.in b/cmake/lib-iconv/CMakeLists.txt.in index e357116c..01db0b90 100644 --- a/cmake/lib-iconv/CMakeLists.txt.in +++ b/cmake/lib-iconv/CMakeLists.txt.in @@ -35,7 +35,7 @@ include(ExternalProject) ExternalProject_Add(${ICONV_NAME} PREFIX ${ICONV_ROOT_DIR} - TIMEOUT 60 + TIMEOUT 120 URL ${ICONV_URI} URL_HASH ${ICONV_HASH_TYPE}=${ICONV_HASH} DOWNLOAD_EXTRACT_TIMESTAMP FALSE diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 6ab9bef5..41c14c40 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -59,6 +59,13 @@ target_link_libraries(max_tests PRIVATE gtest) include(GoogleTest) +if(MINGW AND BUILD_SHARED_LIBS) + add_custom_command(TARGET max_tests POST_BUILD + COMMAND "${CMAKE_COMMAND}" -E copy_if_different "$" "$" + COMMAND_EXPAND_LISTS + ) +endif() + gtest_discover_tests(max_tests PROPERTIES LABELS "unit tests" DISCOVERY_TIMEOUT 240