diff options
author | Chris Robinson <[email protected]> | 2023-05-27 09:38:12 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2023-05-27 09:49:17 -0700 |
commit | 118c729680d6664f793f8d88ff0b7548137847d3 (patch) | |
tree | 0dd01367856bde70e5dd906c1358c58a7027f2b4 /CMakeLists.txt | |
parent | 6cd3d2414ac40a94713c84a0703d3e021bf9a570 (diff) |
Define __STDC_FORMAT_MACROS on systems that need it
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index eeef181f..0bc8f2e2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -186,6 +186,20 @@ set(LIB_VERSION_NUM ${LIB_MAJOR_VERSION},${LIB_MINOR_VERSION},${LIB_REVISION},0) set(EXPORT_DECL "") +# Some systems erroneously require the __STDC_FORMAT_MACROS macro to be defined +# to get the fixed-width integer type formatter macros. +check_cxx_source_compiles("#include <cinttypes> +#include <cstdio> +int main() +{ + int64_t i64{}; + std::printf(\"%\" PRId64, i64); +}" +HAVE_STDC_FORMAT_MACROS) +if(NOT HAVE_STDC_FORMAT_MACROS) + set(CPP_DEFS ${CPP_DEFS} __STDC_FORMAT_MACROS) +endif() + if(NOT WIN32) # Check if _POSIX_C_SOURCE and _XOPEN_SOURCE needs to be set for POSIX functions check_symbol_exists(posix_memalign stdlib.h HAVE_POSIX_MEMALIGN_DEFAULT) |