1
0
Fork 0
forked from fte/fteqw

Make some cmake deps more optional. Don't bail when zlib is unavailable.

This commit is contained in:
Shpoike 2023-08-16 05:15:36 +01:00
parent ed06967318
commit d5c711014f
2 changed files with 28 additions and 11 deletions

View file

@ -17,7 +17,7 @@ INCLUDE_DIRECTORIES(
engine
)
IF (EXISTS ${CMAKE_SOURCE_DIR}/.svn)
IF (EXISTS ${CMAKE_SOURCE_DIR}/.svn AND "${FTE_REVISON}" STREQUAL "")
EXECUTE_PROCESS(COMMAND
"svnversion"
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
@ -42,7 +42,7 @@ IF (EXISTS ${CMAKE_SOURCE_DIR}/.svn)
ENDIF()
ENDIF()
ENDIF()
IF (EXISTS ${CMAKE_SOURCE_DIR}/.git)
IF (EXISTS ${CMAKE_SOURCE_DIR}/.git AND "${FTE_REVISON}" STREQUAL "")
EXECUTE_PROCESS(COMMAND
git describe --always --long --dirty
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
@ -78,7 +78,7 @@ IF (EXISTS ${CMAKE_SOURCE_DIR}/.git)
ERROR_QUIET OUTPUT_STRIP_TRAILING_WHITESPACE
)
MATH(EXPR SVNREVISION "${SVNREVISION} + 29") #not all svn commits managed to appear im the git repo, so we have a small bias to keep things consistent.
IF (FTE_BRANCH STREQUAL "master")
IF (FTE_BRANCH STREQUAL "master" OR FTE_BRANCH STREQUAL "")
SET(SVNREVISION "${SVNREVISION}-git-${FTE_REVISON_GIT}")
ELSE()
SET(SVNREVISION "${FTE_BRANCH}-${SVNREVISION}-git-${FTE_REVISON_GIT}") #weird branches get a different form of revision, to reduce confusion.
@ -138,7 +138,10 @@ ELSE()
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_ZLIB)
ENDIF()
FIND_PACKAGE(BZip2)
SET(FTE_DEP_BZIP2 true CACHE BOOL "Link against libbzip2.")
IF(FTE_DEP_BZIP2)
FIND_PACKAGE(BZip2)
ENDIF()
IF(BZIP2_FOUND)
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};AVAIL_BZLIB;BZLIB_STATIC)
SET(FTE_LIBS ${FTE_LIBS} bz2)
@ -170,7 +173,10 @@ ELSE()
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_JPEG)
ENDIF()
FIND_PACKAGE(PNG)
SET(FTE_DEP_PNG true CACHE BOOL "Link against libpng.")
IF(FTE_DEP_PNG)
FIND_PACKAGE(PNG)
ENDIF()
IF(PNG_FOUND)
INCLUDE_DIRECTORIES( ${PNG_INCLUDE_DIRS} )
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};LIBPNG_STATIC)
@ -180,7 +186,10 @@ ELSE()
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_PNG)
ENDIF()
FIND_PACKAGE(Freetype)
SET(FTE_DEP_FREETYPE true CACHE BOOL "Link against libfreetype.")
IF(FTE_DEP_FREETYPE)
FIND_PACKAGE(Freetype)
ENDIF()
IF(FREETYPE_FOUND)
INCLUDE_DIRECTORIES( ${FREETYPE_INCLUDE_DIRS} )
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};LIBFREETYPE_STATIC)
@ -199,6 +208,7 @@ ELSE()
SET(FTE_LIB_DEFINES ${FTE_LIB_DEFINES};NO_FREETYPE)
ENDIF()
#this is just for headers.
FIND_PATH(VULKAN_INCLUDE_DIR vulkan/vulkan.h)
IF(VULKAN_INCLUDE_DIR)
INCLUDE_DIRECTORIES( ${VULKAN_INCLUDE_DIR} )
@ -207,7 +217,10 @@ ELSE()
MESSAGE(WARNING "Vulkan headers NOT available.")
ENDIF()
FIND_LIBRARY(VORBISFILE_LIBRARY NAMES vorbisfile)
SET(FTE_DEP_VORBISFILE true CACHE BOOL "Link against libvorbisfile.")
IF(FTE_DEP_VROBISFILE)
FIND_LIBRARY(VORBISFILE_LIBRARY NAMES vorbisfile)
ENDIF()
IF(NOT VORBISFILE_LIBRARY)
INCLUDE_DIRECTORIES( ${VORBISFILE_INCLUDE_DIRS} )
MESSAGE(WARNING "libvorbisfile library NOT available. Who listens to the bgm anyway?")
@ -921,7 +934,7 @@ ELSE()
ENDIF()
#ODE Physics library plugin
SET(FTE_PLUG_ODE true CACHE STRING "Compile ODE rigid body physics plugin.")
SET(FTE_PLUG_ODE true CACHE BOOL "Compile ODE rigid body physics plugin.")
SET_PROPERTY(CACHE FTE_PLUG_ODE PROPERTY STRINGS false true static)
IF(FTE_PLUG_ODE)
FIND_PATH(LIBODE_INCLUDE_DIR ode/ode.h)
@ -1372,7 +1385,7 @@ IF(FTE_PLUG_HL2)
plugins/hl2/mat_vmt.c
)
SET_TARGET_PROPERTIES(plug_hl2 PROPERTIES COMPILE_DEFINITIONS "FTEPLUGIN;MULTITHREAD;${FTE_LIB_DEFINES}")
TARGET_LINK_LIBRARIES(plug_hl2 ${SYS_LIBS} ${ZLIB_LIBRARIES})
TARGET_LINK_LIBRARIES(plug_hl2 ${SYS_LIBS})
EMBED_PLUGIN_META(hl2 "HalfLife2 Formats Plugin" "Adds support for reading various file formats used by HalfLife2. Requires mod support to be useful.")
ENDIF()
@ -1611,7 +1624,7 @@ IF(FTE_MENU_SYS)
VERBATIM
DEPENDS fteqcc
WORKING_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/quakec/menusys/"
COMMAND fteqcc -srcfile "menu.src" -o "${CMAKE_CURRENT_BINARY_DIR}/menu.dat"
COMMAND fteqcc -srcfile "menu.src" -o "${CMAKE_CURRENT_BINARY_DIR}/menu.dat" -DREVISION="${SVNREVISION}" -DDATE="${FTE_DATE}" -DBRANCH="${FTE_BRANCH}"
BYPRODUCTS "${CMAKE_CURRENT_BINARY_DIR}/menu.dat" "${CMAKE_CURRENT_BINARY_DIR}/menu.lno"
SOURCES
quakec/menusys/menu.src

View file

@ -4,7 +4,9 @@
#include "fs.h"
#include <assert.h>
#include "../../engine/libs/zlib.h"
#ifdef AVAIL_ZLIB
#include <zlib.h>
#endif
#include "blast.h"
//http://bazaar.launchpad.net/~jeanfrancois.roy/mpqkit/trunk/files
@ -598,6 +600,7 @@ static void MPQF_decompress(qboolean legacymethod, void *outdata, unsigned int o
struct blastdata_s args = {outdata, outlen, indata, inlen};
blast(mpqf_blastin, &args, mpqf_blastout, &args);
}
#ifdef AVAIL_ZLIB
else if (methods == 2)
{
z_stream strm =
@ -651,6 +654,7 @@ static void MPQF_decompress(qboolean legacymethod, void *outdata, unsigned int o
inflateEnd(&strm);
}
#endif
else
{
Con_Printf("mpq: unsupported decompression method - %x\n", methods);