Use separate fmt dependency

Instead of the library that may be bundled with spdlog, because spdlog may be distributed without a bundled fmt (e.g. in Arch Linux's repositories).

This also changes both fmt and spdlog to be built as static libraries instead of used as header-only libraries, as that's the recommended approach.
This commit is contained in:
Oliver Hamlet
2024-09-15 12:46:45 +01:00
parent cfa2835c2f
commit 183255240f
7 changed files with 23 additions and 12 deletions
+17 -2
View File
@@ -154,6 +154,12 @@ else()
set(LCI_LIBRARIES ${LCI_LIBRARIES} dl)
endif()
FetchContent_Declare(
fmt
URL "https://github.com/fmtlib/fmt/archive/refs/tags/11.0.2.tar.gz"
FIND_PACKAGE_ARGS)
set(SPDLOG_FMT_EXTERNAL ON)
FetchContent_Declare(
spdlog
URL "https://github.com/gabime/spdlog/archive/v1.14.1.tar.gz"
@@ -173,7 +179,15 @@ FetchContent_Declare(
URL_HASH "SHA256=e91779044cd4025ec10ed31986031031ef22ebce90a64cc8f85e7c7e95a1abc6"
FIND_PACKAGE_ARGS)
FetchContent_MakeAvailable(spdlog yaml-cpp)
# Set BUILD_SHARED_LIBS=OFF to prevent fmt and spdlog from being built as shared
# libraries.
set(LIBLOOT_BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS})
set(BUILD_SHARED_LIBS OFF)
FetchContent_MakeAvailable(fmt spdlog yaml-cpp)
# Restore the original value of BUILD_SHARED_LIBS.
set(BUILD_SHARED_LIBS ${LIBLOOT_BUILD_SHARED_LIBS})
##############################
# General Settings
@@ -301,7 +315,8 @@ target_link_libraries(loot PRIVATE
${ESPLUGIN_LIBRARIES}
${LIBLOADORDER_LIBRARIES}
${LCI_LIBRARIES}
spdlog::spdlog_header_only
fmt::fmt
spdlog::spdlog
yaml-cpp::yaml-cpp)
##############################
+2 -1
View File
@@ -117,7 +117,8 @@ target_link_libraries(libloot_internals_tests PRIVATE
${ESPLUGIN_LIBRARIES}
${LIBLOADORDER_LIBRARIES}
${LCI_LIBRARIES}
spdlog::spdlog_header_only
fmt::fmt
spdlog::spdlog
yaml-cpp::yaml-cpp
GTest::gtest_main)
+1
View File
@@ -24,6 +24,7 @@
#include "api/bsa.h"
#include <array>
#include <boost/algorithm/string.hpp>
#include <fstream>
+2 -1
View File
@@ -24,8 +24,9 @@
#include "api/helpers/crc.h"
#include <spdlog/fmt/fmt.h>
#include <fmt/base.h>
#include <array>
#include <boost/crc.hpp>
#include <fstream>
-2
View File
@@ -24,8 +24,6 @@
#include "api/helpers/logging.h"
#define FMT_USE_STD_STRING_VIEW
#include <spdlog/sinks/base_sink.h>
namespace {
+1 -2
View File
@@ -26,8 +26,7 @@
#define YAML_CPP_SUPPORT_MERGE_KEYS
#include <spdlog/fmt/bundled/args.h>
#include <spdlog/fmt/fmt.h>
#include <fmt/args.h>
#include <yaml-cpp/yaml.h>
#include <string>
-4
View File
@@ -25,10 +25,6 @@
#ifndef LOOT_API_SORTING_PLUGIN_SORTER
#define LOOT_API_SORTING_PLUGIN_SORTER
#define FMT_NO_FMT_STRING_ALIAS
#include <spdlog/spdlog.h>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/graph_traits.hpp>
#include <map>