cmake: Remove asset hashing, CMAKE_ASSETS_DIR

Simplifies build setup for cmake.

# Conflicts:
#	assets/CMakeLists.txt
#	src/config.h.in
#	src/sdl/i_system.c
This commit is contained in:
Eidolon 2022-11-06 10:34:23 -06:00 committed by James R
parent f0338d22d7
commit d31037abc9
4 changed files with 37 additions and 83 deletions

View file

@ -68,6 +68,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)

View file

@ -1,76 +1,53 @@
## 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"
"HISTORY.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
"main.kart;\
gfx.pk3;\
textures.pk3;\
chars.pk3;\
maps.pk3;\
followers.pk3;\
patch.pk3"
CACHE STRING "Asset filenames to apply MD5 checks. No spaces between entries!"
set(SRB2_ASSETS_GAME
"main.kart"
"gfx.pk3"
"textures.pk3"
"chars.pk3"
"maps.pk3"
"followers.pk3"
"patch.pk3"
)
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "/")
list(TRANSFORM SRB2_ASSETS_GAME PREPEND "${SRB2_ASSET_DIRECTORY_ABSOLUTE}")
set(SRB2_ASSET_DOCS
"README.txt;\
HISTORY.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()

View file

@ -11,15 +11,6 @@
#ifdef CMAKECONFIG
#define ASSET_HASH_MAIN_KART "${SRB2_ASSET_main.kart_HASH}"
#define ASSET_HASH_GFX_PK3 "${SRB2_ASSET_gfx.pk3_HASH}"
#define ASSET_HASH_TEXTURES_PK3 "${SRB2_ASSET_textures.pk3_HASH}"
#define ASSET_HASH_CHARS_PK3 "${SRB2_ASSET_chars.pk3_HASH}"
#define ASSET_HASH_MAPS_PK3 "${SRB2_ASSET_maps.pk3_HASH}"
#ifdef USE_PATCH_FILE
#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}"
// This is done with configure_file instead of defines in order to avoid
@ -29,9 +20,7 @@
#define COMPVERSION_UNCOMMITTED
#endif
#define CMAKE_ASSETS_DIR "${CMAKE_SOURCE_DIR}/assets"
#else
#endif
/* Manually defined asset hashes for non-CMake builds
* Last updated 2019 / 01 / 18 - Kart v1.0.2 - Main assets
@ -48,4 +37,3 @@
#endif
#endif
#endif

View file

@ -2273,18 +2273,6 @@ static const char *locateWad(void)
}
#endif
#ifdef CMAKECONFIG
#ifndef NDEBUG
I_OutputMsg(","CMAKE_ASSETS_DIR);
strcpy(returnWadPath, CMAKE_ASSETS_DIR);
if (isWadPathOk(returnWadPath))
{
return returnWadPath;
}
#endif
#endif
#ifdef __APPLE__
OSX_GetResourcesPath(returnWadPath);
I_OutputMsg(",%s", returnWadPath);