From 90b4f8720eafb4d92806e49503e6178971243455 Mon Sep 17 00:00:00 2001 From: Eidolon Date: Sat, 5 Nov 2022 16:59:18 -0500 Subject: [PATCH] cmake: Remove asset hashing, CMAKE_ASSETS_DIR Simplifies build setup for cmake. --- CMakeLists.txt | 1 + assets/CMakeLists.txt | 85 ++++++++++++++++--------------------------- src/config.h.in | 12 +----- src/sdl/i_system.c | 7 ---- 4 files changed, 34 insertions(+), 71 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index c70c9f767..082093140 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,7 @@ cmake_dependent_option( ) option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON) option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF) +set(SRB2_CONFIG_ASSET_DIRECTORY "" CACHE PATH "Path to directory that contains all asset files for the installer. If set, assets will be part of installation and cpack.") # Enable CCache # (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options) diff --git a/assets/CMakeLists.txt b/assets/CMakeLists.txt index ef228759c..de164b23f 100644 --- a/assets/CMakeLists.txt +++ b/assets/CMakeLists.txt @@ -1,71 +1,50 @@ ## Assets Target Configuration ## -# For prepending the current source path, later -FUNCTION(PREPEND var prefix) - SET(listVar "") - FOREACH(f ${ARGN}) - LIST(APPEND listVar "${prefix}/${f}") - ENDFOREACH(f) - SET(${var} "${listVar}" PARENT_SCOPE) -ENDFUNCTION(PREPEND) +if(${CMAKE_SYSTEM} MATCHES Linux) + # Asset installation isn't part of the Linux target + return() +endif() -set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" - CACHE STRING "Path to directory that contains all asset files for the installer.") +if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "") + message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.") + return() +endif() -set(SRB2_ASSET_INSTALL ON - CACHE BOOL "Insert asset files into the install directory or package.") +get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE) + +set(SRB2_ASSETS_DOCS + "README.txt" + "README-SDL.txt" + "LICENSE.txt" + "LICENSE-3RD-PARTY.txt" +) +list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "/") +list(TRANSFORM SRB2_ASSETS_DOCS PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}") #################### # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list! #################### -set(SRB2_ASSET_HASHED -"srb2.pk3;\ -player.dta;\ -zones.pk3" - CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" +set(SRB2_ASSETS_GAME + "srb2.pk3" + "player.dta" + "zones.pk3" + "music.dta" + "models.dat" ) +list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/") +list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}") -set(SRB2_ASSET_DOCS -"README.txt;\ -LICENSE.txt;\ -LICENSE-3RD-PARTY.txt;\ -README-SDL.txt" - CACHE STRING "Documentation filenames. In OS X, these are packaged separately from other assets. No spaces between entries!" -) - -PREPEND(SRB2_ASSET_DOCS ${SRB2_ASSET_DIRECTORY} ${SRB2_ASSET_DOCS}) - -foreach(SRB2_ASSET ${SRB2_ASSET_HASHED}) - file(MD5 ${SRB2_ASSET_DIRECTORY}/${SRB2_ASSET} "SRB2_ASSET_${SRB2_ASSET}_HASH") - set(SRB2_ASSET_${SRB2_ASSET}_HASH ${SRB2_ASSET_${SRB2_ASSET}_HASH} PARENT_SCOPE) -endforeach() +set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME}) # Installation if(${CMAKE_SYSTEM} MATCHES Darwin) get_target_property(outname SRB2SDL2 OUTPUT_NAME) - if(${SRB2_ASSET_INSTALL}) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION "${outname}.app/Contents/Resources" - ) - endif() - # Always install the doc files, even in non-asset packages. - install(FILES ${SRB2_ASSET_DOCS} - DESTINATION . - OPTIONAL - ) + install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources") + install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources") + install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .) else() - if(${SRB2_ASSET_INSTALL}) - install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" - DESTINATION . - ) - # Docs are assumed to be located in SRB2_ASSET_DIRECTORY, so don't install them in their own call. - else() - # Always install the doc files, even in non-asset packages. - install(FILES ${SRB2_ASSET_DOCS} - DESTINATION . - OPTIONAL - ) - endif() + install(FILES ${SRB2_ASSETS} DESTINATION .) + install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .) endif() diff --git a/src/config.h.in b/src/config.h.in index 587a881c7..928705b30 100644 --- a/src/config.h.in +++ b/src/config.h.in @@ -11,19 +11,10 @@ #ifdef CMAKECONFIG -#define ASSET_HASH_SRB2_PK3 "${SRB2_ASSET_srb2.pk3_HASH}" -#define ASSET_HASH_PLAYER_DTA "${SRB2_ASSET_player.dta_HASH}" -#define ASSET_HASH_ZONES_PK3 "${SRB2_ASSET_zones.pk3_HASH}" -#ifdef USE_PATCH_DTA -#define ASSET_HASH_PATCH_PK3 "${SRB2_ASSET_patch.pk3_HASH}" -#endif - #define SRB2_COMP_REVISION "${SRB2_COMP_REVISION}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" -#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets" - -#else +#endif /* Manually defined asset hashes for non-CMake builds * Last updated 2020 / 02 / 15 - v2.2.1 - main assets @@ -45,4 +36,3 @@ #endif #endif -#endif diff --git a/src/sdl/i_system.c b/src/sdl/i_system.c index 22d6de831..3f16e8c6b 100644 --- a/src/sdl/i_system.c +++ b/src/sdl/i_system.c @@ -2854,13 +2854,6 @@ static const char *locateWad(void) CHECKWADPATH(NULL); #endif -#ifdef CMAKECONFIG -#ifndef NDEBUG - strcpy(returnWadPath, CMAKE_ASSETS_DIR); - CHECKWADPATH(returnWadPath); -#endif -#endif - #ifdef __APPLE__ OSX_GetResourcesPath(returnWadPath); CHECKWADPATH(returnWadPath);