Create option to build with system freetype, libchdr, and rapidjson instead of bundled modules. Add a couple of FreeBSD-specific tweaks to CMakeLists.txt while at it

This commit is contained in:
Kevin Reinholz
2026-03-10 18:03:06 -07:00
parent afbc66a318
commit f020bcdd75
4 changed files with 36 additions and 5 deletions

View File

@@ -202,9 +202,12 @@ option(USE_DISCORD "Build with Discord support" ON)
option(USE_MINIUPNPC "Build with miniUPnPc support" ON)
option(USE_SYSTEM_SNAPPY "Dynamically link against system snappy" ${USE_SYSTEM_SNAPPY})
option(USE_SYSTEM_FFMPEG "Dynamically link against system FFMPEG" ${USE_SYSTEM_FFMPEG})
option(USE_SYSTEM_FREETYPE "Dynamically link against system freetype" ${USE_SYSTEM_FREETYPE})
option(USE_SYSTEM_LIBCHDR "Dynamically link against system libchdr" ${USE_SYSTEM_LIBCHDR})
option(USE_SYSTEM_LIBZIP "Dynamically link against system libzip" ${USE_SYSTEM_LIBZIP})
option(USE_SYSTEM_LIBSDL2 "Dynamically link against system SDL2" ${DEFAULT_USE_SYSTEM_LIBSDL2})
option(USE_SYSTEM_LIBPNG "Dynamically link against system libpng" ON)
option(USE_SYSTEM_RAPIDJSON "Build using system rapidjson" ${USE_SYSTEM_RAPIDJSON})
option(USE_SYSTEM_ZSTD "Dynamically link against system zstd" ${USE_SYSTEM_ZSTD})
option(USE_SYSTEM_MINIUPNPC "Dynamically link against system miniUPnPc" ${USE_SYSTEM_MINIUPNPC})
option(USE_ASAN "Use address sanitizer" OFF)
@@ -218,6 +221,10 @@ if(USE_CCACHE)
include(ccache)
endif()
if(USE_SYSTEM_RAPIDJSON)
add_compile_definitions(SYSTEM_RAPIDJSON)
endif()
if(WEBOS)
set(ARMV7 ON)
set(USING_X11_VULKAN OFF)
@@ -2077,7 +2084,7 @@ if(WIN32)
)
endif()
if(LINUX OR ANDROID OR MACOSX OR IOS)
if(LINUX OR ANDROID OR MACOSX OR IOS OR BSD)
list(APPEND aemu_postoffice
ext/aemu_postoffice/client/sock_impl_linux.c
)
@@ -2577,7 +2584,14 @@ else()
include_directories(ext/zstd/lib)
endif()
include_directories(ext/libchdr/include)
if(USE_SYSTEM_LIBCHDR)
find_package(PkgConfig)
if(PkgConfig_FOUND)
pkg_check_modules(libchdr_PKGCONFIG IMPORTED_TARGET libchdr)
endif()
else()
include_directories(ext/libchdr/include)
endif()
target_link_libraries(${CoreLibName} Common native chdr kirk cityhash sfmt19937 xbrz xxhash rcheevos minimp3 at3_standalone lua ${GlslangLibs}
${CoreExtraLibs} ${OPENGL_LIBRARIES} ${X11_LIBRARIES} ${CMAKE_DL_LIBS})
@@ -2952,7 +2966,13 @@ if(UNITTEST)
endif()
if(ATLAS_TOOL)
include_directories(ext/freetype/include)
if(USE_SYSTEM_FREETYPE)
find_package(Freetype REQUIRED)
include_directories(${FREETYPE_INCLUDE_DIRS})
add_compile_definitions(SYSTEM_FREETYPE)
else()
include_directories(ext/freetype/include)
endif()
set(AtlasToolSource
ext/native/tools/atlastool.cpp

View File

@@ -25,7 +25,11 @@
#include "ext/rcheevos/include/rc_api_request.h"
#include "ext/rcheevos/include/rc_api_runtime.h"
#ifdef SYSTEM_RAPIDJSON
#include <rapidjson/document.h>
#else
#include "ext/rapidjson/include/rapidjson/document.h"
#endif
#include "Common/Crypto/md5.h"
#include "Common/Log.h"

View File

@@ -42,7 +42,7 @@ set(FT_REQUIRE_BZIP2 OFF CACHE BOOL "" FORCE)
set(FT_REQUIRE_PNG OFF CACHE BOOL "" FORCE)
set(FT_REQUIRE_HARFBUZZ OFF CACHE BOOL "" FORCE)
set(FT_REQUIRE_BROTLI OFF CACHE BOOL "" FORCE)
if(NOT LIBRETRO)
if(NOT LIBRETRO AND NOT USE_SYSTEM_FREETYPE)
add_subdirectory(freetype)
endif()
@@ -56,7 +56,9 @@ if(USE_DISCORD AND NOT IOS AND NOT LIBRETRO)
add_subdirectory(discord-rpc-build)
endif()
add_subdirectory(libchdr-build)
if(NOT USE_SYSTEM_LIBCHDR)
add_subdirectory(libchdr-build)
endif()
if(ANDROID)
if (ARM64)

View File

@@ -25,8 +25,13 @@
#include <vector>
#include <map>
#include <string>
#ifdef SYSTEM_FREETYPE
#include <freetype2/ft2build.h>
#include <freetype2/freetype/ftbitmap.h>
#else
#include "ft2build.h"
#include "freetype/ftbitmap.h"
#endif
#include "zstd.h"
#include "Common/Render/AtlasGen.h"