From c54c2c5f7cb0b4ef39b6c8db8e267360af3d8607 Mon Sep 17 00:00:00 2001 From: Victor Zverovich Date: Mon, 1 Jan 2024 12:14:14 -0800 Subject: [PATCH] Don't include fmt/os.h in the module if it is disabled via FMT_OS --- CMakeLists.txt | 3 ++- src/fmt.cc | 4 +++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4b928ae35c3e4..dbe6daf55736c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -150,7 +150,7 @@ option(FMT_INSTALL "Generate the install target." ON) option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT}) option(FMT_FUZZ "Generate the fuzz target." OFF) option(FMT_CUDA_TEST "Generate the cuda-test target." OFF) -option(FMT_OS "Include core requiring OS (Windows/Posix) " ON) +option(FMT_OS "Include OS-specific APIs." ON) option(FMT_MODULE "Build a module instead of a traditional library." OFF) option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF) @@ -280,6 +280,7 @@ add_headers(FMT_HEADERS args.h chrono.h color.h compile.h core.h format.h set(FMT_SOURCES src/format.cc) if (FMT_OS) set(FMT_SOURCES ${FMT_SOURCES} src/os.cc) + target_compile_definitions(fmt PRIVATE FMT_OS=0) endif () add_module_library(fmt src/fmt.cc FALLBACK diff --git a/src/fmt.cc b/src/fmt.cc index 5330463a932cf..aa971103e0b06 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -90,7 +90,9 @@ extern "C++" { #include "fmt/color.h" #include "fmt/compile.h" #include "fmt/format.h" -#include "fmt/os.h" +#if !defined(FMT_OS) || FMT_OS +# include "fmt/os.h" +#endif #include "fmt/printf.h" #include "fmt/std.h" #include "fmt/xchar.h"