Skip to content

Commit 7fab3d5

Browse files
committed
Prevent build errors
Be less pedantic
1 parent 5ec55c2 commit 7fab3d5

File tree

6 files changed

+115
-118
lines changed

6 files changed

+115
-118
lines changed

.cmakefiles.txt

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,22 @@
1-
./CMakeLists.txt
2-
./CMakePresets.json
3-
./cmake/AddUninstallTarget.cmake
4-
./cmake/CPM.cmake
5-
./cmake/coverage.cmake
6-
./cmake/dev-mode.cmake
7-
./cmake/docs-ci.cmake
8-
./cmake/docs.cmake
9-
./cmake/folders.cmake
10-
./cmake/install-config.cmake
11-
./cmake/install-rules.cmake
12-
./cmake/lint-targets.cmake
13-
./cmake/lint.cmake
14-
./cmake/prelude.cmake
15-
./cmake/spell-targets.cmake
16-
./cmake/spell.cmake
17-
./cmake/variables.cmake
18-
./cmake/windows-set-path.cmake
19-
./module/tests/CMakeLists.txt
20-
./tests/CMakeLists.txt
1+
.CMakeUserPresets.json
2+
.github/workflows/cmake.yml
3+
CMakeLists.txt
4+
CMakePresets.json
5+
cmake/AddUninstallTarget.cmake
6+
cmake/CPM.cmake
7+
cmake/coverage.cmake
8+
cmake/dev-mode.cmake
9+
cmake/docs-ci.cmake
10+
cmake/docs.cmake
11+
cmake/folders.cmake
12+
cmake/install-config.cmake
13+
cmake/install-rules.cmake
14+
cmake/lint-targets.cmake
15+
cmake/lint.cmake
16+
cmake/prelude.cmake
17+
cmake/spell-targets.cmake
18+
cmake/spell.cmake
19+
cmake/variables.cmake
20+
cmake/windows-set-path.cmake
21+
module/tests/CMakeLists.txt
22+
tests/CMakeLists.txt

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,3 +38,5 @@ CMakeUserPresets.json
3838
tags
3939
*.swp
4040
*.bak
41+
module/format.cc
42+
module/os.cc

CMakeLists.txt

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,23 @@ project(fmt
1111

1212
include(cmake/variables.cmake)
1313

14+
set(CMAKE_CXX_STANDARD 23)
15+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
1416
set(CMAKE_DEBUG_POSTFIX D)
1517
set(CPPdefinitions)
1618

1719
option(FMT_SEPARATE_COMPILATION "build fmt lib too" ${PROJECT_IS_TOP_LEVEL})
1820
option(FMT_USE_MODULES "Export a CXX_MODULE fmt if possible" ${PROJECT_IS_TOP_LEVEL})
1921
option(FMT_IMPORT_STD "Import the all std header needed" NO)
2022

21-
if(FMT_IMPORT_STD)
23+
if(FMT_IMPORT_STD AND NOT FMT_USE_MODULES)
2224
list(APPEND CPPdefinitions FMT_IMPORT_STD)
2325
endif()
2426

2527
if(FMT_USE_MODULES)
2628
list(APPEND CPPdefinitions FMT_MODULE)
2729
# XXX NO! list(APPEND CPPdefinitions FMT_ATTACH_TO_GLOBAL_MODULE)
28-
# FIXME: add_compile_options(-Wno-reserved-module-identifier -Wno-include-angled-in-module-purview)
30+
# TODO: add_compile_options(-Wno-reserved-module-identifier -Wno-include-angled-in-module-purview)
2931

3032
if(FMT_IMPORT_STD) # FIXME: clang++ only! AND $ENV{LLVM_ROOT})
3133
if(UNIX)
@@ -61,12 +63,12 @@ cpmaddpackage(
6163
# ---- Declare library ----
6264

6365
# TODO: only if needed (compare) and possible!
64-
if(EXISTS ${fmt_SOURCE_DIR}/src/fmt.cc AND NOT EXISTS ${PROJECT_SOURCE_DIR}/module/fmt.cppm)
65-
configure_file(${fmt_SOURCE_DIR}/src/fmt.cc ${PROJECT_SOURCE_DIR}/module/fmt.cppm COPYONLY)
66+
if(EXISTS ${fmt_SOURCE_DIR}/src/fmt.cc AND NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm)
67+
configure_file(${fmt_SOURCE_DIR}/src/fmt.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm COPYONLY)
6668
endif()
6769

68-
configure_file(${fmt_SOURCE_DIR}/src/format.cc ${PROJECT_SOURCE_DIR}/module/format.cc COPYONLY)
69-
configure_file(${fmt_SOURCE_DIR}/src/os.cc ${PROJECT_SOURCE_DIR}/module/os.cc COPYONLY)
70+
configure_file(${fmt_SOURCE_DIR}/src/format.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/format.cc COPYONLY)
71+
configure_file(${fmt_SOURCE_DIR}/src/os.cc ${CMAKE_CURRENT_SOURCE_DIR}/module/os.cc COPYONLY)
7072
file(GLOB_RECURSE _fmt_all_sources "module/*.cc")
7173

7274
# fmt interface library
@@ -109,9 +111,9 @@ if(FMT_SEPARATE_COMPILATION)
109111
FILE_SET public_modules
110112
TYPE CXX_MODULES
111113
BASE_DIRS
112-
${PROJECT_SOURCE_DIR}/module
114+
${CMAKE_CURRENT_SOURCE_DIR}/module
113115
FILES
114-
${PROJECT_SOURCE_DIR}/module/fmt.cppm
116+
${CMAKE_CURRENT_SOURCE_DIR}/module/fmt.cppm
115117
)
116118
# cmake-format: on
117119
else()

CMakePresets.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
"hidden": true,
6060
"cacheVariables": {
6161
"CMAKE_CXX_FLAGS":
62-
"-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Werror=float-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast",
62+
"-U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=3 -fstack-protector-strong -fcf-protection=full -fstack-clash-protection -Wall -Wextra -Wpedantic -Wno-conversion -Wno-sign-conversion -Wcast-qual -Wformat=2 -Wundef -Wfloat-equal -Wshadow -Wcast-align -Wunused -Wnull-dereference -Wdouble-promotion -Wno-implicit-fallthrough -Wextra-semi -Woverloaded-virtual -Wnon-virtual-dtor -Wno-old-style-cast",
6363
"CMAKE_EXE_LINKER_FLAGS":
6464
"-Wl,--allow-shlib-undefined,--as-needed,-z,noexecstack,-z,relro,-z,now",
6565
"CMAKE_SHARED_LINKER_FLAGS":

cmake/CPM.cmake

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#
33
# SPDX-FileCopyrightText: Copyright (c) 2019-2023 Lars Melchior and contributors
44

5-
set(CPM_DOWNLOAD_VERSION 0.40.2)
6-
set(CPM_HASH_SUM "c8cdc32c03816538ce22781ed72964dc864b2a34a310d3b7104812a5ca2d835d")
5+
set(CPM_DOWNLOAD_VERSION 0.40.4)
6+
set(CPM_HASH_SUM "67dcc1deb6e12a2f0705647ccc5f7023e3d15746b944e14352b82373e09b8a0a")
77

88
if(CPM_SOURCE_CACHE)
99
set(CPM_DOWNLOAD_LOCATION "${CPM_SOURCE_CACHE}/cpm/CPM_${CPM_DOWNLOAD_VERSION}.cmake")
@@ -16,7 +16,8 @@ endif()
1616
# Expand relative path. This is important if the provided path contains a tilde (~)
1717
get_filename_component(CPM_DOWNLOAD_LOCATION ${CPM_DOWNLOAD_LOCATION} ABSOLUTE)
1818

19-
file(DOWNLOAD https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
19+
file(DOWNLOAD
20+
https://github.com/cpm-cmake/CPM.cmake/releases/download/v${CPM_DOWNLOAD_VERSION}/CPM.cmake
2021
${CPM_DOWNLOAD_LOCATION} EXPECTED_HASH SHA256=${CPM_HASH_SUM}
2122
)
2223

module/fmt.cppm

Lines changed: 76 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -1,105 +1,97 @@
1-
#ifdef FMT_MODULE
21
module;
3-
#endif
42

53
#ifdef _MSVC_LANG
64
# define FMT_CPLUSPLUS _MSVC_LANG
75
#else
86
# define FMT_CPLUSPLUS __cplusplus
97
#endif
108

11-
#ifndef FMT_IMPORT_STD_MODULE
12-
139
// Put all implementation-provided headers into the global module fragment
1410
// to prevent attachment to this module.
15-
# ifndef FMT_IMPORT_STD
16-
# include <algorithm>
17-
# include <bitset>
18-
# include <chrono>
19-
# include <cmath>
20-
# include <complex>
21-
# include <cstddef>
22-
# include <cstdint>
23-
# include <cstdio>
24-
# include <cstdlib>
25-
# include <cstring>
26-
# include <ctime>
27-
# include <exception>
28-
# if FMT_CPLUSPLUS > 202002L
29-
# include <expected>
30-
# endif
31-
# include <filesystem>
32-
# include <fstream>
33-
# include <functional>
34-
# include <iterator>
35-
# include <limits>
36-
# include <locale>
37-
# include <memory>
38-
# include <optional>
39-
# include <ostream>
40-
# include <source_location>
41-
# include <stdexcept>
42-
# include <string>
43-
# include <string_view>
44-
# include <system_error>
45-
# include <thread>
46-
# include <type_traits>
47-
# include <typeinfo>
48-
# include <utility>
49-
# include <variant>
50-
# include <vector>
51-
# else
52-
# include <limits.h>
53-
# include <stdint.h>
54-
# include <stdio.h>
55-
# include <time.h>
56-
# endif // FMT_IMPORT_STD
57-
58-
# include <cerrno>
59-
# include <climits>
60-
# include <version>
61-
62-
# if __has_include(<cxxabi.h>)
63-
# include <cxxabi.h>
64-
# endif
65-
# if defined(_MSC_VER) || defined(__MINGW32__)
66-
# include <intrin.h>
11+
#ifndef FMT_IMPORT_STD
12+
# include <algorithm>
13+
# include <bitset>
14+
# include <chrono>
15+
# include <cmath>
16+
# include <complex>
17+
# include <cstddef>
18+
# include <cstdint>
19+
# include <cstdio>
20+
# include <cstdlib>
21+
# include <cstring>
22+
# include <ctime>
23+
# include <exception>
24+
# if FMT_CPLUSPLUS > 202002L
25+
# include <expected>
6726
# endif
68-
# if defined __APPLE__ || defined(__FreeBSD__)
69-
# include <xlocale.h>
70-
# endif
71-
# if __has_include(<winapifamily.h>)
72-
# include <winapifamily.h>
73-
# endif
74-
# if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
27+
# include <filesystem>
28+
# include <fstream>
29+
# include <functional>
30+
# include <iterator>
31+
# include <limits>
32+
# include <locale>
33+
# include <memory>
34+
# include <optional>
35+
# include <ostream>
36+
# include <source_location>
37+
# include <stdexcept>
38+
# include <string>
39+
# include <string_view>
40+
# include <system_error>
41+
# include <thread>
42+
# include <type_traits>
43+
# include <typeinfo>
44+
# include <utility>
45+
# include <variant>
46+
# include <vector>
47+
#else
48+
# include <limits.h>
49+
# include <stdint.h>
50+
# include <stdio.h>
51+
# include <time.h>
52+
#endif
53+
#include <cerrno>
54+
#include <climits>
55+
#include <version>
56+
57+
#if __has_include(<cxxabi.h>)
58+
# include <cxxabi.h>
59+
#endif
60+
#if defined(_MSC_VER) || defined(__MINGW32__)
61+
# include <intrin.h>
62+
#endif
63+
#if defined __APPLE__ || defined(__FreeBSD__)
64+
# include <xlocale.h>
65+
#endif
66+
#if __has_include(<winapifamily.h>)
67+
# include <winapifamily.h>
68+
#endif
69+
#if (__has_include(<fcntl.h>) || defined(__APPLE__) || \
7570
defined(__linux__)) && \
7671
(!defined(WINAPI_FAMILY) || (WINAPI_FAMILY == WINAPI_FAMILY_DESKTOP_APP))
77-
# include <fcntl.h>
78-
# include <sys/stat.h>
79-
# include <sys/types.h>
80-
# ifndef _WIN32
81-
# include <unistd.h>
82-
# else
83-
# include <io.h>
84-
# endif
72+
# include <fcntl.h>
73+
# include <sys/stat.h>
74+
# include <sys/types.h>
75+
# ifndef _WIN32
76+
# include <unistd.h>
77+
# else
78+
# include <io.h>
8579
# endif
86-
# ifdef _WIN32
87-
# if defined(__GLIBCXX__)
88-
# include <ext/stdio_filebuf.h>
89-
# include <ext/stdio_sync_filebuf.h>
90-
# endif
91-
# define WIN32_LEAN_AND_MEAN
92-
# include <windows.h>
80+
#endif
81+
#ifdef _WIN32
82+
# if defined(__GLIBCXX__)
83+
# include <ext/stdio_filebuf.h>
84+
# include <ext/stdio_sync_filebuf.h>
9385
# endif
94-
#endif // FMT_IMPORT_STD_MODULE
86+
# define WIN32_LEAN_AND_MEAN
87+
# include <windows.h>
88+
#endif
9589

96-
#ifdef FMT_MODULE
9790
export module fmt;
9891

99-
# ifdef FMT_IMPORT_STD_MODULE
92+
#ifdef FMT_IMPORT_STD
10093
import std;
101-
# endif
102-
#endif // FMT_MODULE
94+
#endif
10395

10496
#define FMT_EXPORT export
10597
#define FMT_BEGIN_EXPORT export {
@@ -138,11 +130,9 @@ extern "C++" {
138130
}
139131
#endif
140132

141-
#ifdef FMT_MODULE
142133
// gcc doesn't yet implement private module fragments
143-
# if !FMT_GCC_VERSION
134+
#if !FMT_GCC_VERSION
144135
module :private;
145-
# endif
146136
#endif
147137

148138
#ifdef FMT_ATTACH_TO_GLOBAL_MODULE

0 commit comments

Comments
 (0)