diff --git a/docs/usage.rst b/docs/usage.rst index ae6dd830..ca3c2ae3 100644 --- a/docs/usage.rst +++ b/docs/usage.rst @@ -151,16 +151,6 @@ Additionally, enables project documentation generation when the project is being CMake Options ^^^^^^^^^^^^^ -UNITS_DOWNCAST_MODE -+++++++++++++++++++ - -**Values**: ``OFF``/``ON``/``AUTO`` - -**Defaulted to**: ``ON`` - -Equivalent to `downcast_mode`_. - - UNITS_AS_SYSTEM_HEADERS +++++++++++++++++++++++ @@ -171,6 +161,26 @@ UNITS_AS_SYSTEM_HEADERS Exports library as system headers. +UNITS_BUILD_DOCS +++++++++++++++++ + +**Values**: ``ON``/``OFF`` + +**Defaulted to**: ``ON`` + +Enables project documentation generation. + + +UNITS_DOWNCAST_MODE ++++++++++++++++++++ + +**Values**: ``OFF``/``ON``/``AUTO`` + +**Defaulted to**: ``ON`` + +Equivalent to `downcast_mode`_. + + UNITS_IWYU ++++++++++ @@ -182,14 +192,14 @@ Enables include-what-you-use when compiling with a clang compiler. Additionally turns on `UNITS_AS_SYSTEM_HEADERS`_. -UNITS_BUILD_DOCS +UNITS_USE_LIBFMT ++++++++++++++++ **Values**: ``ON``/``OFF`` **Defaulted to**: ``ON`` -Enables project documentation generation. +Enables usage of `{fmt} `_ library instead of the C++20 Standard Library feature. Installation and Reuse diff --git a/src/core-fmt/CMakeLists.txt b/src/core-fmt/CMakeLists.txt index 51f8544b..157495d1 100644 --- a/src/core-fmt/CMakeLists.txt +++ b/src/core-fmt/CMakeLists.txt @@ -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=$) + 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() diff --git a/src/core-fmt/include/units/bits/fmt_hacks.h b/src/core-fmt/include/units/bits/fmt_hacks.h index a9c22b9b..814a0cb3 100644 --- a/src/core-fmt/include/units/bits/fmt_hacks.h +++ b/src/core-fmt/include/units/bits/fmt_hacks.h @@ -29,6 +29,10 @@ #include +#ifndef UNITS_USE_LIBFMT +#define UNITS_USE_LIBFMT 1 +#endif + #if UNITS_USE_LIBFMT UNITS_DIAGNOSTIC_PUSH