cmake: Remove asset hashing, CMAKE_ASSETS_DIR

Simplifies build setup for cmake.
This commit is contained in:
Eidolon 2022-11-05 16:59:18 -05:00
parent 2e9260c83c
commit 90b4f8720e
4 changed files with 34 additions and 71 deletions

View file

@ -63,6 +63,7 @@ cmake_dependent_option(
) )
option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON) option(SRB2_CONFIG_HWRENDER "Enable hardware render (OpenGL) support" ON)
option(SRB2_CONFIG_STATIC_OPENGL "Enable static linking GL (do not do this)" OFF) 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 # Enable CCache
# (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options) # (Set USE_CCACHE=ON to use, CCACHE_OPTIONS for options)

View file

@ -1,71 +1,50 @@
## Assets Target Configuration ## ## Assets Target Configuration ##
# For prepending the current source path, later if(${CMAKE_SYSTEM} MATCHES Linux)
FUNCTION(PREPEND var prefix) # Asset installation isn't part of the Linux target
SET(listVar "") return()
FOREACH(f ${ARGN}) endif()
LIST(APPEND listVar "${prefix}/${f}")
ENDFOREACH(f)
SET(${var} "${listVar}" PARENT_SCOPE)
ENDFUNCTION(PREPEND)
set(SRB2_ASSET_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/installer" if("${SRB2_CONFIG_ASSET_DIRECTORY}" STREQUAL "")
CACHE STRING "Path to directory that contains all asset files for the installer.") message(WARNING "SRB2_CONFIG_ASSET_DIRECTORY is not set, so installation will not contain data files.")
return()
endif()
set(SRB2_ASSET_INSTALL ON get_filename_component(SRB2_ASSET_DIRECTORY_ABSOLUTE "${SRB2_CONFIG_ASSET_DIRECTORY}" ABSOLUTE)
CACHE BOOL "Insert asset files into the install directory or package.")
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! # POST-V2.2 NOTE: Do not forget to add patch.pk3 to the end of this list!
#################### ####################
set(SRB2_ASSET_HASHED set(SRB2_ASSETS_GAME
"srb2.pk3;\ "srb2.pk3"
player.dta;\ "player.dta"
zones.pk3" "zones.pk3"
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!" "music.dta"
"models.dat"
) )
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
set(SRB2_ASSET_DOCS set(SRB2_ASSETS ${SRB2_ASSET_DOCS} ${SRB2_ASSETS_GAME})
"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()
# Installation # Installation
if(${CMAKE_SYSTEM} MATCHES Darwin) if(${CMAKE_SYSTEM} MATCHES Darwin)
get_target_property(outname SRB2SDL2 OUTPUT_NAME) get_target_property(outname SRB2SDL2 OUTPUT_NAME)
if(${SRB2_ASSET_INSTALL}) install(FILES ${SRB2_ASSETS} DESTINATION "${outname}.app/Contents/Resources")
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION "${outname}.app/Contents/Resources")
DESTINATION "${outname}.app/Contents/Resources" install(FILES ${SRB2_ASSETS_DOCS} DESTINATION .)
)
endif()
# Always install the doc files, even in non-asset packages.
install(FILES ${SRB2_ASSET_DOCS}
DESTINATION .
OPTIONAL
)
else() else()
if(${SRB2_ASSET_INSTALL}) install(FILES ${SRB2_ASSETS} DESTINATION .)
install(DIRECTORY "${SRB2_ASSET_DIRECTORY}/" install(DIRECTORY "${SRB2_ASSET_DIRECTORY_ABSOLUTE}/models" DESTINATION .)
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()
endif() endif()

View file

@ -11,19 +11,10 @@
#ifdef CMAKECONFIG #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_REVISION "${SRB2_COMP_REVISION}"
#define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}" #define SRB2_COMP_BRANCH "${SRB2_COMP_BRANCH}"
#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets" #endif
#else
/* Manually defined asset hashes for non-CMake builds /* Manually defined asset hashes for non-CMake builds
* Last updated 2020 / 02 / 15 - v2.2.1 - main assets * Last updated 2020 / 02 / 15 - v2.2.1 - main assets
@ -45,4 +36,3 @@
#endif #endif
#endif #endif
#endif

View file

@ -2854,13 +2854,6 @@ static const char *locateWad(void)
CHECKWADPATH(NULL); CHECKWADPATH(NULL);
#endif #endif
#ifdef CMAKECONFIG
#ifndef NDEBUG
strcpy(returnWadPath, CMAKE_ASSETS_DIR);
CHECKWADPATH(returnWadPath);
#endif
#endif
#ifdef __APPLE__ #ifdef __APPLE__
OSX_GetResourcesPath(returnWadPath); OSX_GetResourcesPath(returnWadPath);
CHECKWADPATH(returnWadPath); CHECKWADPATH(returnWadPath);