From f5b888868651643370187d5706ab24c9406d6f9d Mon Sep 17 00:00:00 2001 From: Castor215 <132155746+Castor215@users.noreply.github.com> Date: Sun, 8 Oct 2023 00:00:02 +0100 Subject: [PATCH] externals: allow user to use system fmt (#7052) --- CMakeLists.txt | 1 + externals/CMakeLists.txt | 11 +++++++++-- src/common/CMakeLists.txt | 2 +- src/core/CMakeLists.txt | 2 +- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cfc5e22b2..bf1fdb1b8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -98,6 +98,7 @@ option(USE_SYSTEM_SOUNDTOUCH "Use the system SoundTouch (instead of the bundled option(USE_SYSTEM_CPP_HTTPLIB "Use the system cpp-httplib (instead of the bundled one)" OFF) option(USE_SYSTEM_JSON "Use the system JSON (nlohmann-json3) package (instead of the bundled one)" OFF) option(USE_SYSTEM_DYNARMIC "Use the system dynarmic (instead of the bundled one)" OFF) +option(USE_SYSTEM_FMT "Use the system fmt (instead of the bundled one)" OFF) if (CITRA_USE_PRECOMPILED_HEADERS) message(STATUS "Using Precompiled Headers.") diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 37684654b..53fb777ea 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -68,8 +68,15 @@ target_include_directories(dds-ktx INTERFACE ./dds-ktx) # fmt and Xbyak need to be added before dynarmic # libfmt -option(FMT_INSTALL "" ON) -add_subdirectory(fmt EXCLUDE_FROM_ALL) +if(USE_SYSTEM_FMT) + add_library(fmt INTERFACE) + find_package(fmt REQUIRED) + target_link_libraries(fmt INTERFACE fmt::fmt) +else() + option(FMT_INSTALL "" ON) + add_subdirectory(fmt EXCLUDE_FROM_ALL) +endif() + # Xbyak if ("x86_64" IN_LIST ARCHITECTURE) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 73270972a..e2ee67835 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -173,7 +173,7 @@ endif() create_target_directory_groups(citra_common) -target_link_libraries(citra_common PUBLIC fmt::fmt library-headers microprofile Boost::boost Boost::serialization Boost::iostreams) +target_link_libraries(citra_common PUBLIC fmt library-headers microprofile Boost::boost Boost::serialization Boost::iostreams) target_link_libraries(citra_common PRIVATE libzstd_static) if ("x86_64" IN_LIST ARCHITECTURE) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 8c7acd8cb..15c532c87 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -479,7 +479,7 @@ create_target_directory_groups(citra_core) target_link_libraries(citra_core PUBLIC citra_common PRIVATE audio_core network video_core) target_link_libraries(citra_core PRIVATE Boost::boost Boost::serialization Boost::iostreams httplib) -target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt::fmt lodepng open_source_archives) +target_link_libraries(citra_core PUBLIC dds-ktx PRIVATE cryptopp fmt lodepng open_source_archives) if (ENABLE_WEB_SERVICE) target_link_libraries(citra_core PRIVATE web_service)