From 611ffb99b920b703f76c7f7d6eaf770c96968b78 Mon Sep 17 00:00:00 2001 From: Biswapriyo Nath Date: Fri, 9 Aug 2024 14:32:09 +0000 Subject: [PATCH] CMake: Add option to use system fmt library fmt library was added in vendor in 21061c1dfb006c22304053c1f6f9e48ae4cbe25a commit for systems with older fmt versions. Now, distributions can choose to link with their own fmt shared library or use the bundled one. --- CMakeLists.txt | 1 + vendor/CMakeLists.txt | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3fc0e7d..689b922 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ include(GNUInstallDirs) # This helps to build vendor projects with or without any patching. Also if any # files are changed in vendor projects those can be retained with this option. option(ANDROID_TOOLS_PATCH_VENDOR "Patch vendor projects using patches directory" ON) +option(ANDROID_TOOLS_USE_SYSTEM_FMT "Use system provided fmt library instead of bundled one" OFF) # Install bash/zsh completion files. set(COMPLETION_COMMON_DIR "${CMAKE_INSTALL_FULL_DATADIR}/android-tools/completions") diff --git a/vendor/CMakeLists.txt b/vendor/CMakeLists.txt index 2348845..864cfe9 100644 --- a/vendor/CMakeLists.txt +++ b/vendor/CMakeLists.txt @@ -75,7 +75,13 @@ if(ANDROID_TOOLS_PATCH_VENDOR AND EXISTS "${ANDROID_PATCH_DIR}/") endif() add_subdirectory(boringssl EXCLUDE_FROM_ALL) -add_subdirectory(fmtlib EXCLUDE_FROM_ALL) + +if(ANDROID_TOOLS_USE_SYSTEM_FMT) + find_package(fmt CONFIG REQUIRED) + message(STATUS "Found fmt: ${fmt_DIR} (version ${fmt_VERSION})") +else() + add_subdirectory(fmtlib EXCLUDE_FROM_ALL) +endif() find_package(PkgConfig REQUIRED) pkg_check_modules(libbrotlicommon REQUIRED IMPORTED_TARGET libbrotlicommon)