From ee8b14bafd3e949b644ab568a928365c624f79da Mon Sep 17 00:00:00 2001 From: Bernhard Manfred Gruber Date: Fri, 24 Sep 2021 22:09:41 +0200 Subject: [PATCH] make fmt optional for the llama target Fixes #382. --- CMakeLists.txt | 9 +++++++-- include/llama/DumpMapping.hpp | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3625d3ee94..76ec01c8a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,11 +3,16 @@ project (llama CXX) # llama find_package(Boost 1.70.0 REQUIRED) -find_package(fmt CONFIG REQUIRED) +find_package(fmt CONFIG QUIET) add_library(${PROJECT_NAME} INTERFACE) target_include_directories(${PROJECT_NAME} INTERFACE $ $) target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17) -target_link_libraries(${PROJECT_NAME} INTERFACE Boost::headers fmt::fmt) +target_link_libraries(${PROJECT_NAME} INTERFACE Boost::headers) +if (fmt_FOUND) + target_link_libraries(${PROJECT_NAME} INTERFACE fmt::fmt) +else() + message("The fmt library was not found. You cannot use llama/DumpMapping.hpp") +endif() # llama::llama to make subdirectory projects work add_library(${PROJECT_NAME}::${PROJECT_NAME} ALIAS ${PROJECT_NAME}) diff --git a/include/llama/DumpMapping.hpp b/include/llama/DumpMapping.hpp index 98fea597e9..126aafaf5c 100644 --- a/include/llama/DumpMapping.hpp +++ b/include/llama/DumpMapping.hpp @@ -2,6 +2,10 @@ #pragma once +#if !__has_include() +# error DumpMapping.hpp requires the fmt library +#endif + #include "ArrayDimsIndexRange.hpp" #include "Core.hpp"