diff --git a/CMakeLists.txt b/CMakeLists.txt index 0898e5bddd04..f14a49c41f16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,6 +63,8 @@ function(add_module_library name) target_compile_options(${name} PUBLIC -fmodules-ts) endif () + target_compile_definitions(${name} PRIVATE FMT_MODULE) + if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND CMAKE_GENERATOR STREQUAL "Ninja") target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES FILES ${sources}) else() diff --git a/include/fmt/base.h b/include/fmt/base.h index 6b1d8140c29b..2e10a4c3b423 100644 --- a/include/fmt/base.h +++ b/include/fmt/base.h @@ -8,9 +8,12 @@ #ifndef FMT_BASE_H_ #define FMT_BASE_H_ -#include // CHAR_BIT -#include // FILE -#include // strlen +// c headers are preferable for performance reasons +#ifndef FMT_MODULE +# include // CHAR_BIT +# include // FILE +# include // strlen +#endif #ifndef FMT_IMPORT_STD // is also included transitively from . diff --git a/src/fmt.cc b/src/fmt.cc index bb3845f2f964..b7e5ccd4c813 100644 --- a/src/fmt.cc +++ b/src/fmt.cc @@ -6,6 +6,7 @@ module; # include # include # include +# include # include # include # include @@ -13,6 +14,7 @@ module; # include # include # include +# include # include # include # include @@ -22,6 +24,7 @@ module; # include # include # include +# include # include # include # include @@ -104,7 +107,9 @@ extern "C++" { #if FMT_OS # include "fmt/os.h" #endif +#include "fmt/ostream.h" #include "fmt/printf.h" +#include "fmt/ranges.h" #include "fmt/std.h" #include "fmt/xchar.h"