From a28cbac96a1d5ee653874d4f9a1ae6b9b748cfb0 Mon Sep 17 00:00:00 2001 From: Jeff Date: Sun, 28 Aug 2022 11:04:40 -0400 Subject: [PATCH] when we are not using static builds and not forcing submodules for logging etc we want to use the system's libfmt --- external/CMakeLists.txt | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/external/CMakeLists.txt b/external/CMakeLists.txt index 5c9d48695..7e647f0a1 100644 --- a/external/CMakeLists.txt +++ b/external/CMakeLists.txt @@ -69,7 +69,22 @@ set(JSON_Install OFF CACHE INTERNAL "") system_or_submodule(NLOHMANN nlohmann_json nlohmann_json>=3.7.0 nlohmann) if (STATIC OR FORCE_SPDLOG_SUBMODULE OR FORCE_FMT_SUBMODULE) - set(OXEN_LOGGING_FORCE_SUBMODULES ON CACHE INTERNAL "") + set(OXEN_LOGGING_FORCE_SUBMODULES ON CACHE INTERNAL "") +else() + + pkg_check_modules(FMT fmt>=7.1 IMPORTED_TARGET REQUIRED) + + add_library(fmt INTERFACE) + if(NOT TARGET PkgConfig::FMT AND CMAKE_VERSION VERSION_LESS "3.21") + # Work around cmake bug 22180 (PkgConfig::THING not set if no flags needed) + else() + target_link_libraries(fmt INTERFACE PkgConfig::FMT) + endif() + message(STATUS "Found fmt ${FMT_VERSION}") + + if(NOT TARGET fmt::fmt) + add_library(fmt::fmt ALIAS fmt) + endif() endif() set(OXEN_LOGGING_SOURCE_ROOT "${PROJECT_SOURCE_DIR}" CACHE INTERNAL "")