From c6206a31912d2779cbd2a754b750c91b3d23b302 Mon Sep 17 00:00:00 2001 From: gabime Date: Sat, 23 Dec 2023 14:03:02 +0200 Subject: [PATCH] Always build static fmtlib version and fix fpic --- CMakeLists.txt | 2 +- cmake/fmtlib.cmake | 12 ++++++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 81dc314b..1e5f33a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,7 +127,7 @@ if(SPDLOG_TIDY) message(STATUS "Enabled clang-tidy") endif() -if(SPDLOG_BUILD_PIC) +if(SPDLOG_BUILD_PIC OR SPDLOG_BUILD_SHARED) set(CMAKE_POSITION_INDEPENDENT_CODE ON) endif() diff --git a/cmake/fmtlib.cmake b/cmake/fmtlib.cmake index cc359f47..d2b8eb1f 100644 --- a/cmake/fmtlib.cmake +++ b/cmake/fmtlib.cmake @@ -1,4 +1,9 @@ include(FetchContent) + +# Always build static fmtlib version +set(BUILD_SHARED_LIBS_ORIG "${BUILD_SHARED_LIBS}") +set(BUILD_SHARED_LIBS OFF CACHE BOOL "Disable BUILD_SHARED_LIBS for fmtlib" FORCE) + Set(FETCHCONTENT_QUIET FALSE) FetchContent_Declare( fmt @@ -10,7 +15,10 @@ FetchContent_Declare( FetchContent_GetProperties(fmt) if(NOT fmt_POPULATED) FetchContent_Populate(fmt) - # we do not require os features of fmt + # We do not require os features of fmt set(FMT_OS OFF CACHE BOOL "Disable FMT_OS" FORCE) add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR}) -endif () \ No newline at end of file +endif () + +# Restore BUILD_SHARED_LIBS +set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_ORIG}" CACHE BOOL "Restore BUILD_SHARED_LIBS" FORCE) \ No newline at end of file