From d03d514bad2af4a8bfa9214567a08d7a8332c6fd Mon Sep 17 00:00:00 2001 From: gabime Date: Fri, 22 Dec 2023 18:01:05 +0200 Subject: [PATCH] Use fmt git hash and disable FMT_OS --- CMakeLists.txt | 23 +++++++---------------- cmake/fmtlib.cmake | 16 ++++++++++++++++ 2 files changed, 23 insertions(+), 16 deletions(-) create mode 100644 cmake/fmtlib.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index d4f39ed8..13cf276b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,6 +85,8 @@ option(SPDLOG_BUILD_WARNINGS "Enable compiler warnings" OFF) option(SPDLOG_SYSTEM_INCLUDES "Include as system headers (skip for clang-tidy)." OFF) option(SPDLOG_INSTALL "Generate the install target" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_USE_STD_FORMAT "Use std::format instead of fmt library." OFF) +option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of of fetching from gitub." OFF) + option(SPDLOG_NO_EXCEPTIONS "Compile with -fno-exceptions. Call abort() on any spdlog exceptions" OFF) if(SPDLOG_USE_STD_FORMAT AND CMAKE_CXX_STANDARD LESS 20) @@ -126,20 +128,11 @@ if(SPDLOG_BUILD_PIC) endif() -include(FetchContent) - -Set(FETCHCONTENT_QUIET FALSE) -FetchContent_Declare( - fmt - GIT_REPOSITORY https://github.com/fmtlib/fmt.git - GIT_TAG 10.1.1 - GIT_PROGRESS TRUE -) - - -FetchContent_MakeAvailable(fmt) -# Get and print the version of fmt -#find_package(fmt REQUIRED) +if (SPDLOG_FMT_EXTERNAL) + find_package(fmt REQUIRED) +else() + include(cmake/fmtlib.cmake) +endif() find_package(Threads REQUIRED) message(STATUS "Build type: " ${CMAKE_BUILD_TYPE}) @@ -264,9 +257,7 @@ target_include_directories(spdlog ${SPDLOG_INCLUDES_LEVEL} PUBLIC "$") target_link_libraries(spdlog PUBLIC Threads::Threads) target_link_libraries(spdlog PUBLIC fmt::fmt) - spdlog_enable_warnings(spdlog) - set_target_properties(spdlog PROPERTIES VERSION ${SPDLOG_VERSION} SOVERSION ${SPDLOG_VERSION_MAJOR}.${SPDLOG_VERSION_MINOR}) set_target_properties(spdlog PROPERTIES DEBUG_POSTFIX d) diff --git a/cmake/fmtlib.cmake b/cmake/fmtlib.cmake new file mode 100644 index 00000000..cc359f47 --- /dev/null +++ b/cmake/fmtlib.cmake @@ -0,0 +1,16 @@ +include(FetchContent) +Set(FETCHCONTENT_QUIET FALSE) +FetchContent_Declare( + fmt + GIT_REPOSITORY https://github.com/fmtlib/fmt.git + GIT_TAG f5e54359df4c26b6230fc61d38aa294581393084 # 10.1.1 + GIT_PROGRESS TRUE +) + +FetchContent_GetProperties(fmt) +if(NOT fmt_POPULATED) + FetchContent_Populate(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