From a984b1b073564e0d29b5ec540b127319ddb5752c Mon Sep 17 00:00:00 2001 From: Martin Green Date: Sun, 7 Apr 2019 17:12:41 +0300 Subject: [PATCH 1/2] Add a CMake option to use a header-only external fmt --- CMakeLists.txt | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f0951fc..3dd13060 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,12 +53,9 @@ option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF) option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF) +option(SPDLOG_FMT_HEADER_ONLY "Use header-only variant of external fmt library" OFF) option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT}) -if(SPDLOG_FMT_EXTERNAL AND NOT TARGET fmt::fmt) - find_package(fmt REQUIRED CONFIG) -endif() - target_include_directories( spdlog INTERFACE @@ -68,7 +65,16 @@ target_include_directories( if(SPDLOG_FMT_EXTERNAL) target_compile_definitions(spdlog INTERFACE SPDLOG_FMT_EXTERNAL) - target_link_libraries(spdlog INTERFACE fmt::fmt) + + if(NOT TARGET fmt::fmt) + find_package(fmt REQUIRED CONFIG) + endif() + + if(SPDLOG_FMT_HEADER_ONLY) + target_link_libraries(spdlog INTERFACE fmt::fmt-header-only) + else() + target_link_libraries(spdlog INTERFACE fmt::fmt) + endif() endif() set(HEADER_BASE "${CMAKE_CURRENT_SOURCE_DIR}/include") From 7e63d773ef85a3864094e505afdd505118c4f99d Mon Sep 17 00:00:00 2001 From: Martin Green Date: Wed, 10 Apr 2019 06:49:57 +0300 Subject: [PATCH 2/2] Make header-only external fmt the default --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3dd13060..12fe8bb5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,7 @@ option(SPDLOG_BUILD_EXAMPLES "Build examples" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_BUILD_BENCH "Build benchmarks (Requires https://github.com/google/benchmark.git to be installed)" OFF) option(SPDLOG_BUILD_TESTS "Build tests" ${SPDLOG_MASTER_PROJECT}) option(SPDLOG_FMT_EXTERNAL "Use external fmt library instead of bundled" OFF) -option(SPDLOG_FMT_HEADER_ONLY "Use header-only variant of external fmt library" OFF) +option(SPDLOG_FMT_HEADER_ONLY "Use header-only variant of external fmt library" ON) option(SPDLOG_INSTALL "Generate the install target." ${SPDLOG_MASTER_PROJECT}) target_include_directories(