Skip to content

Commit fcf9b85

Browse files
committed
Last try
1 parent 2ccc8ce commit fcf9b85

File tree

2 files changed

+91
-82
lines changed

2 files changed

+91
-82
lines changed

CMakeLists.txt

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ set(CPPdefinitions)
1616

1717
option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL})
1818
option(FMT_USE_MODULES "Export a CXX_MODULE asio if possible" ${PROJECT_IS_TOP_LEVEL})
19-
option(FMT_IMPORT_STD "Import the CXX_MODULE std if possible" NO)
19+
option(FMT_IMPORT_STD "Import the all std header needed" YES)
2020

2121
if(FMT_IMPORT_STD)
2222
list(APPEND CPPdefinitions FMT_IMPORT_STD)
@@ -28,11 +28,14 @@ if(FMT_USE_MODULES)
2828
# FIXME: add_compile_options(-Wno-reserved-module-identifier -Wno-include-angled-in-module-purview)
2929

3030
if(FMT_IMPORT_STD) # FIXME: clang++ only! AND $ENV{LLVM_ROOT})
31-
set(CMAKE_CXX_COMPILER_IMPORT_STD 23)
32-
add_compile_options(-fexperimental-library)
33-
add_link_options(-lc++experimental)
34-
add_compile_options(-stdlib=libc++)
35-
add_link_options(-stdlib=libc++)
31+
32+
if(UNIX)
33+
set(CMAKE_CXX_COMPILER_IMPORT_STD 23)
34+
add_compile_options(-fexperimental-library)
35+
add_link_options(-lc++experimental)
36+
add_compile_options(-stdlib=libc++)
37+
add_link_options(-stdlib=libc++)
38+
endif()
3639

3740
message(STATUS "CMAKE_CXX_COMPILER_IMPORT_STD=${CMAKE_CXX_COMPILER_IMPORT_STD}")
3841
endif()

module/fmt.cppm

Lines changed: 82 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -2,95 +2,100 @@
22
module;
33
#endif
44

5+
#ifndef FMT_IMPORT_STD_MODULE
6+
57
// Put all implementation-provided headers into the global module fragment
68
// to prevent attachment to this module.
7-
#ifndef FMT_IMPORT_STD
8-
# include <algorithm>
9-
# include <bitset>
10-
# include <chrono>
11-
# include <cmath>
12-
# include <complex>
13-
# include <cstddef>
14-
# include <cstdint>
15-
# include <cstdio>
16-
# include <cstdlib>
17-
# include <cstring>
18-
# include <ctime>
19-
# include <exception>
20-
# include <expected>
21-
# include <filesystem>
22-
# include <fstream>
23-
# include <functional>
24-
# include <iterator>
25-
# include <limits>
26-
# include <locale>
27-
# include <memory>
28-
# include <optional>
29-
# include <ostream>
30-
# include <source_location>
31-
# include <stdexcept>
32-
# include <string>
33-
# include <string_view>
34-
# include <system_error>
35-
# include <thread>
36-
# include <type_traits>
37-
# include <typeinfo>
38-
# include <utility>
39-
# include <variant>
40-
# include <vector>
41-
#else
42-
# include <limits.h>
43-
# include <stdint.h>
44-
# include <stdio.h>
45-
# include <time.h>
46-
#endif
47-
#include <cerrno>
48-
#include <climits>
49-
#include <version>
9+
# ifndef FMT_IMPORT_STD
10+
# include <algorithm>
11+
# include <bitset>
12+
# include <chrono>
13+
# include <cmath>
14+
# include <complex>
15+
# include <cstddef>
16+
# include <cstdint>
17+
# include <cstdio>
18+
# include <cstdlib>
19+
# include <cstring>
20+
# include <ctime>
21+
# include <exception>
22+
# include <expected>
23+
# include <filesystem>
24+
# include <fstream>
25+
# include <functional>
26+
# include <iterator>
27+
# include <limits>
28+
# include <locale>
29+
# include <memory>
30+
# include <optional>
31+
# include <ostream>
32+
# include <source_location>
33+
# include <stdexcept>
34+
# include <string>
35+
# include <string_view>
36+
# include <system_error>
37+
# include <thread>
38+
# include <type_traits>
39+
# include <typeinfo>
40+
# include <utility>
41+
# include <variant>
42+
# include <vector>
43+
# else
44+
# include <limits.h>
45+
# include <stdint.h>
46+
# include <stdio.h>
47+
# include <time.h>
48+
# endif
49+
# include <cerrno>
50+
# include <climits>
51+
# include <version>
5052

51-
#if __has_include(<cxxabi.h>)
52-
# include <cxxabi.h>
53-
#endif
54-
#if defined(_MSC_VER) || defined(__MINGW32__)
55-
# include <intrin.h>
56-
#endif
57-
#if defined __APPLE__ || defined(__FreeBSD__)
58-
# include <xlocale.h>
59-
#endif
60-
#if __has_include(<winapifamily.h>)
61-
# include <winapifamily.h>
62-
#endif
63-
#if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
53+
# if __has_include(<cxxabi.h>)
54+
# include <cxxabi.h>
55+
# endif
56+
# if defined(_MSC_VER) || defined(__MINGW32__)
57+
# include <intrin.h>
58+
# endif
59+
# if defined __APPLE__ || defined(__FreeBSD__)
60+
# include <xlocale.h>
61+
# endif
62+
# if __has_include(<winapifamily.h>)
63+
# include <winapifamily.h>
64+
# endif
65+
# if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
6466
defined(__linux__)) && \
6567
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
66-
# include <fcntl.h>
67-
# include <sys/stat.h>
68-
# include <sys/types.h>
69-
# ifndef _WIN32
70-
# include <unistd.h>
71-
# else
72-
# include <io.h>
68+
# include <fcntl.h>
69+
# include <sys/stat.h>
70+
# include <sys/types.h>
71+
# ifndef _WIN32
72+
# include <unistd.h>
73+
# else
74+
# include <io.h>
75+
# endif
7376
# endif
74-
#endif
75-
#ifdef _WIN32
76-
# if defined(__GLIBCXX__)
77-
# include <ext/stdio_filebuf.h>
78-
# include <ext/stdio_sync_filebuf.h>
77+
# ifdef _WIN32
78+
# if defined(__GLIBCXX__)
79+
# include <ext/stdio_filebuf.h>
80+
# include <ext/stdio_sync_filebuf.h>
81+
# endif
82+
# define WIN32_LEAN_AND_MEAN
83+
# include <windows.h>
7984
# endif
80-
# define WIN32_LEAN_AND_MEAN
81-
# include <windows.h>
8285
#endif
8386

8487
#ifdef FMT_MODULE
8588
export module fmt;
8689

87-
#ifdef FMT_IMPORT_STD_MODULE
90+
# ifdef FMT_IMPORT_STD_MODULE
8891
import std;
89-
#endif
92+
# endif
9093
#endif
9194

9295
#define FMT_EXPORT export
93-
#define FMT_BEGIN_EXPORT export {
96+
#define FMT_BEGIN_EXPORT \
97+
export \
98+
{
9499
#define FMT_END_EXPORT }
95100

96101
// If you define FMT_ATTACH_TO_GLOBAL_MODULE
@@ -99,7 +104,8 @@ import std;
99104
// - all library symbols are mangled traditionally
100105
// - you can mix TUs with either importing or #including the {fmt} API
101106
#ifdef FMT_ATTACH_TO_GLOBAL_MODULE
102-
extern "C++" {
107+
extern "C++"
108+
{
103109
#endif
104110

105111
#ifndef FMT_OS
@@ -128,9 +134,9 @@ extern "C++" {
128134

129135
#ifdef FMT_MODULE
130136
// gcc doesn't yet implement private module fragments
131-
#if !FMT_GCC_VERSION
137+
# if !FMT_GCC_VERSION
132138
module :private;
133-
#endif
139+
# endif
134140
#endif
135141

136142
#if FMT_HAS_INCLUDE("format.cc")

0 commit comments

Comments
 (0)