From a0d66415ef1c5e3f939f973e1f95d2cbc076c8d5 Mon Sep 17 00:00:00 2001 From: Matthias Schoepfer Date: Tue, 8 Oct 2019 11:27:46 +0200 Subject: [PATCH] Some minor changes to compile bundled fmt propperly w. BUILD_SHARED_LIBS Basically, libfmt also lacks support for propper generate_export_headers, instead, some handwritten macros that only work on windows are used :-( Personally, I think including dependencies in the build is always a bad idea, but there might be good (Windows??) reasons for it. Anyhow, this is a rather ugly fix to include the generate_export_headers into libfmt. Signed-off-by: Matthias Schoepfer --- CMakeLists.txt | 3 ++- include/spdlog/fmt/bundled/format.h | 2 +- src/fmt.cpp | 1 + 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39a7e4df..2d55d62d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -7,6 +7,7 @@ cmake_minimum_required(VERSION 3.2) # Start spdlog project #--------------------------------------------------------------------------------------- include(GNUInstallDirs) +include(GenerateExportHeader) include(cmake/utils.cmake) include(cmake/ide.cmake) @@ -99,8 +100,8 @@ endif() add_library(spdlog ${SPDLOG_SRCS} ${SPDLOG_ALL_HEADERS}) add_library(spdlog::spdlog ALIAS spdlog) +generate_export_header(spdlog) if (BUILD_SHARED_LIBS) - generate_export_header(spdlog) target_compile_definitions(spdlog PRIVATE SPDLOG_USE_EXPORT_HEADER) set_target_properties(spdlog PROPERTIES CXX_VISIBILITY_PRESET hidden) set_target_properties(spdlog PROPERTIES VISIBILITY_INLINES_HIDDEN 1) diff --git a/include/spdlog/fmt/bundled/format.h b/include/spdlog/fmt/bundled/format.h index f27996d3..312f88a7 100644 --- a/include/spdlog/fmt/bundled/format.h +++ b/include/spdlog/fmt/bundled/format.h @@ -665,7 +665,7 @@ template struct FMT_EXTERN_TEMPLATE_API basic_data { static const wchar_t wreset_color[5]; }; -FMT_EXTERN template struct basic_data; +FMT_EXTERN template struct FMT_API basic_data; // This is a struct rather than an alias to avoid shadowing warnings in gcc. struct data : basic_data<> {}; diff --git a/src/fmt.cpp b/src/fmt.cpp index ed3a78bd..7865ca6d 100644 --- a/src/fmt.cpp +++ b/src/fmt.cpp @@ -7,6 +7,7 @@ // All rights reserved. #if !defined(SPDLOG_FMT_EXTERNAL) +#include "spdlog/fmt/bundled/core.h" #include "spdlog/fmt/bundled/format-inl.h" FMT_BEGIN_NAMESPACE