build: UNITS_USE_LIBFMT support improved

This commit is contained in:
Mateusz Pusz
2021-10-15 17:43:58 +02:00
parent ee70c48b13
commit 5bd7852ae5
3 changed files with 30 additions and 17 deletions
+4 -5
View File
@@ -22,14 +22,13 @@
cmake_minimum_required(VERSION 3.15)
option(UNITS_USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" OFF)
option(UNITS_USE_LIBFMT "Enables usage of libfmt instead of the one from 'std'" ON)
message(STATUS "UNITS_USE_LIBFMT: ${UNITS_USE_LIBFMT}")
# find dependencies
find_package(fmt CONFIG REQUIRED)
add_units_module(core-fmt mp-units::core)
target_compile_definitions(mp-units-core-fmt INTERFACE UNITS_USE_LIBFMT=$<BOOL:${UNITS_USE_LIBFMT}>)
if(UNITS_USE_LIBFMT)
find_package(fmt CONFIG REQUIRED)
target_link_libraries(mp-units-core-fmt INTERFACE fmt::fmt)
target_compile_definitions(mp-units-core-fmt INTERFACE UNITS_USE_LIBFMT)
endif()
@@ -29,6 +29,10 @@
#include <units/bits/external/hacks.h>
#ifndef UNITS_USE_LIBFMT
#define UNITS_USE_LIBFMT 1
#endif
#if UNITS_USE_LIBFMT
UNITS_DIAGNOSTIC_PUSH