Always build static fmtlib version and fix fpic

This commit is contained in:
gabime 2023-12-23 14:03:02 +02:00
parent d0c30a6a5c
commit c6206a3191
2 changed files with 11 additions and 3 deletions

View File

@ -127,7 +127,7 @@ if(SPDLOG_TIDY)
message(STATUS "Enabled clang-tidy") message(STATUS "Enabled clang-tidy")
endif() endif()
if(SPDLOG_BUILD_PIC) if(SPDLOG_BUILD_PIC OR SPDLOG_BUILD_SHARED)
set(CMAKE_POSITION_INDEPENDENT_CODE ON) set(CMAKE_POSITION_INDEPENDENT_CODE ON)
endif() endif()

View File

@ -1,4 +1,9 @@
include(FetchContent) 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) Set(FETCHCONTENT_QUIET FALSE)
FetchContent_Declare( FetchContent_Declare(
fmt fmt
@ -10,7 +15,10 @@ FetchContent_Declare(
FetchContent_GetProperties(fmt) FetchContent_GetProperties(fmt)
if(NOT fmt_POPULATED) if(NOT fmt_POPULATED)
FetchContent_Populate(fmt) 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) set(FMT_OS OFF CACHE BOOL "Disable FMT_OS" FORCE)
add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR}) add_subdirectory(${fmt_SOURCE_DIR} ${fmt_BINARY_DIR})
endif () endif ()
# Restore BUILD_SHARED_LIBS
set(BUILD_SHARED_LIBS "${BUILD_SHARED_LIBS_ORIG}" CACHE BOOL "Restore BUILD_SHARED_LIBS" FORCE)