diff --git a/CMakeLists.txt b/CMakeLists.txt index 45d5afc..ba565a8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -306,6 +306,10 @@ target_compile_features( target_compile_definitions(${target_name} PRIVATE NOMINMAX) +if(NOT CPPTRACE_STD_FORMAT) + target_compile_definitions(${target_name} PUBLIC CPPTRACE_NO_STD_FORMAT) +endif() + if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang") SET(CMAKE_C_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") SET(CMAKE_CXX_ARCHIVE_FINISH " -no_warning_for_no_symbols -c ") diff --git a/README.md b/README.md index 2cf9aca..47ded24 100644 --- a/README.md +++ b/README.md @@ -952,6 +952,8 @@ Other useful configurations: - `CPPTRACE_INSTALL_CMAKEDIR`: Override for the installation path for the cmake configs. - `CPPTRACE_USE_EXTERNAL_LIBDWARF=On/Off`: Get libdwarf from `find_package` rather than `FetchContent`. - `CPPTRACE_POSITION_INDEPENDENT_CODE=On/Off`: Compile the library as a position independent code (PIE). Defaults to On. +- `CPPTRACE_STD_FORMAT=On/Off`: Control inclusion of `` and provision of `std::formatter` specializations by + cpptrace.hpp. This can also be controlled with the macro `CPPTRACE_NO_STD_FORMAT`. Testing: - `CPPTRACE_BUILD_TESTING` Build small demo and test program diff --git a/cmake/OptionVariables.cmake b/cmake/OptionVariables.cmake index 8fd5206..f199f5f 100644 --- a/cmake/OptionVariables.cmake +++ b/cmake/OptionVariables.cmake @@ -171,6 +171,7 @@ option(CPPTRACE_SANITIZER_BUILD "" OFF) option(CPPTRACE_WERROR_BUILD "" OFF) option(CPPTRACE_POSITION_INDEPENDENT_CODE "" ON) option(CPPTRACE_SKIP_UNIT "" OFF) +option(CPPTRACE_STD_FORMAT "" ON) option(CPPTRACE_USE_EXTERNAL_GTEST "" OFF) set(CPPTRACE_ZSTD_REPO "https://github.com/facebook/zstd.git" CACHE STRING "") set(CPPTRACE_ZSTD_TAG "63779c798237346c2b245c546c40b72a5a5913fe" CACHE STRING "") # v1.5.5 diff --git a/include/cpptrace/cpptrace.hpp b/include/cpptrace/cpptrace.hpp index 44e5b48..200b2e4 100644 --- a/include/cpptrace/cpptrace.hpp +++ b/include/cpptrace/cpptrace.hpp @@ -34,11 +34,13 @@ # endif #endif -#if __cplusplus >= 202002L - #ifdef __has_include - #if __has_include() - #define CPPTRACE_STD_FORMAT - #include +#ifndef CPPTRACE_NO_STD_FORMAT + #if __cplusplus >= 202002L + #ifdef __has_include + #if __has_include() + #define CPPTRACE_STD_FORMAT + #include + #endif #endif #endif #endif