diff --git a/CMakeLists.txt b/CMakeLists.txt index c55318aa2c..de21dfab9e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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 diff --git a/Core/RetroAchievements.cpp b/Core/RetroAchievements.cpp index 1f30c0cb8c..72e6c6866c 100644 --- a/Core/RetroAchievements.cpp +++ b/Core/RetroAchievements.cpp @@ -25,7 +25,11 @@ #include "ext/rcheevos/include/rc_api_request.h" #include "ext/rcheevos/include/rc_api_runtime.h" +#ifdef SYSTEM_RAPIDJSON +#include +#else #include "ext/rapidjson/include/rapidjson/document.h" +#endif #include "Common/Crypto/md5.h" #include "Common/Log.h" diff --git a/ext/CMakeLists.txt b/ext/CMakeLists.txt index 32e5c4ce92..fd52b72fb9 100644 --- a/ext/CMakeLists.txt +++ b/ext/CMakeLists.txt @@ -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) diff --git a/ext/native/tools/atlastool.cpp b/ext/native/tools/atlastool.cpp index bf5f0546ce..bbc0396668 100644 --- a/ext/native/tools/atlastool.cpp +++ b/ext/native/tools/atlastool.cpp @@ -25,8 +25,13 @@ #include #include #include +#ifdef SYSTEM_FREETYPE +#include +#include +#else #include "ft2build.h" #include "freetype/ftbitmap.h" +#endif #include "zstd.h" #include "Common/Render/AtlasGen.h"