Skip to content

Commit

Permalink
Refactor dependencies: (#1014)
Browse files Browse the repository at this point in the history
- Replace libpng with libspng
- Replace zlib with miniz
- Add library for zip file support, in preparation for custom campaign handling
  • Loading branch information
crudelios authored Jan 10, 2024
1 parent f2d3fa7 commit 8a13624
Show file tree
Hide file tree
Showing 61 changed files with 20,570 additions and 46,389 deletions.
66 changes: 12 additions & 54 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -171,42 +171,21 @@ if (EXISTS ${PROJECT_SOURCE_DIR}/res/packed_assets)
endif()

set(EXPAT_FILES
ext/expat/xmlparse.c
ext/expat/xmlrole.c
ext/expat/xmltok.c
${PROJECT_SOURCE_DIR}/ext/expat/xmlparse.c
${PROJECT_SOURCE_DIR}/ext/expat/xmlrole.c
${PROJECT_SOURCE_DIR}/ext/expat/xmltok.c
)

set(TINYFD_FILES
ext/tinyfiledialogs/tinyfiledialogs.c
${PROJECT_SOURCE_DIR}/ext/tinyfiledialogs/tinyfiledialogs.c
)

set(PNG_FILES
ext/png/png.c
ext/png/pngerror.c
ext/png/pngget.c
ext/png/pngmem.c
ext/png/pngpread.c
ext/png/pngread.c
ext/png/pngrio.c
ext/png/pngrtran.c
ext/png/pngrutil.c
ext/png/pngset.c
ext/png/pngtrans.c
ext/png/pngwio.c
ext/png/pngwrite.c
ext/png/pngwtran.c
ext/png/pngwutil.c
set(SPNG_FILES
${PROJECT_SOURCE_DIR}/ext/spng/spng.c
)

set(ZLIB_FILES
ext/zlib/adler32.c
ext/zlib/crc32.c
ext/zlib/deflate.c
ext/zlib/inffast.c
ext/zlib/inflate.c
ext/zlib/inftrees.c
ext/zlib/trees.c
ext/zlib/zutil.c
set(ZIP_FILES
${PROJECT_SOURCE_DIR}/ext/zip/zip.c
)

set(PLATFORM_FILES
Expand Down Expand Up @@ -745,6 +724,8 @@ set(SOURCE_FILES
${EDITOR_FILES}
${TRANSLATION_FILES}
${TINYFD_FILES}
${SPNG_FILES}
${ZIP_FILES}
${PROJECT_SOURCE_DIR}/res/augustus.rc
${MACOSX_FILES}
)
Expand Down Expand Up @@ -799,8 +780,6 @@ if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_WARNINGS)
string(REGEX REPLACE "/W3" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
set_source_files_properties(${EXPAT_FILES} PROPERTIES COMPILE_FLAGS "/W3")
set_source_files_properties(${PNG_FILES} PROPERTIES COMPILE_FLAGS "/W3")
set_source_files_properties(${ZLIB_FILES} PROPERTIES COMPILE_FLAGS "/W3")
set_source_files_properties(${SOURCE_FILES} PROPERTIES COMPILE_FLAGS "/W4")
set_source_files_properties(${PROJECT_SOURCE_DIR}/res/augustus.rc PROPERTIES COMPILE_FLAGS "")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /utf-8 /wd4100 /wd4244")
Expand Down Expand Up @@ -890,30 +869,9 @@ if(SDL2_MIXER_INCLUDE_DIR)
endif()

if(SYSTEM_LIBS)
find_package(ZLIB)
find_package(PNG)
find_package(EXPAT)
endif()

if(ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(${SHORT_NAME} ${ZLIB_LIBRARIES})
else()
include_directories("ext/zlib")
target_sources(${SHORT_NAME} PRIVATE "${ZLIB_FILES}")
endif()

if(PNG_FOUND)
include_directories(SYSTEM ${PNG_INCLUDE_DIRS})
target_link_libraries(${SHORT_NAME} ${PNG_LIBRARIES})
else()
if(SYSTEM_LIBS)
message(STATUS "PNG was not found but that's ok: falling back to internal version")
endif()
include_directories("ext/png")
target_sources(${SHORT_NAME} PRIVATE "${PNG_FILES}")
endif()

if(EXPAT_FOUND)
include_directories(${EXPAT_INCLUDE_DIRS})
target_link_libraries(${SHORT_NAME} ${EXPAT_LIBRARIES})
Expand Down Expand Up @@ -971,7 +929,7 @@ if(${TARGET_PLATFORM} STREQUAL "vita")
ScePgf_stub
SceAppMgr_stub
)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__vita__ -DPNG_ARM_NEON_OPT=0")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D__vita__")
# this setting enables larger heap memory sizes on Vita, up to ~330 MB
# useful for pre-loading videos into memory
set(VITA_MKSFOEX_FLAGS "${VITA_MKSFOEX_FLAGS} -d ATTRIBUTE2=12")
Expand Down Expand Up @@ -1007,7 +965,7 @@ else()
target_link_libraries(${SHORT_NAME} m)
endif()
if(${TARGET_PLATFORM} STREQUAL "android")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -DPNG_ARM_NEON_OPT=0 -D_BSD_SOURCE")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -D_BSD_SOURCE")
find_library(log-lib log)
find_library(android-lib android)
target_link_libraries(${SHORT_NAME} ${log-lib} ${android-lib})
Expand Down
22 changes: 22 additions & 0 deletions ext/miniz/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright 2013-2014 RAD Game Tools and Valve Software
Copyright 2010-2014 Rich Geldreich and Tenacious Software LLC

All Rights Reserved.

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.
Loading

0 comments on commit 8a13624

Please sign in to comment.