Skip to content

Commit c81e974

Browse files
committed
Update fmtlib to 11.0.0
1 parent aacebee commit c81e974

File tree

20 files changed

+8013
-10260
lines changed

20 files changed

+8013
-10260
lines changed

3rdparty/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
## {fmt}
6464
- [![Upstream](https://img.shields.io/github/v/release/fmtlib/fmt?label=Upstream)](https://github.com/fmtlib/fmt)
65-
- Version: 10.2.1
65+
- Version: 11.0.0
6666
- License: MIT
6767

6868
## FreeType

3rdparty/fmt/CMakeLists.txt

Lines changed: 120 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.8...3.26)
1+
cmake_minimum_required(VERSION 3.8...3.28)
22

33
# Fallback for using newer policies on CMake <3.12.
44
if (${CMAKE_VERSION} VERSION_LESS 3.12)
@@ -36,6 +36,12 @@ function(enable_module target)
3636
endif ()
3737
endfunction()
3838

39+
set(FMT_USE_CMAKE_MODULES FALSE)
40+
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.28 AND
41+
CMAKE_GENERATOR STREQUAL "Ninja")
42+
set(FMT_USE_CMAKE_MODULES TRUE)
43+
endif ()
44+
3945
# Adds a library compiled with C++20 module support.
4046
# `enabled` is a CMake variables that specifies if modules are enabled.
4147
# If modules are disabled `add_module_library` falls back to creating a
@@ -53,6 +59,7 @@ function(add_module_library name)
5359
if (NOT ${${AML_IF}})
5460
# Create a non-modular library.
5561
target_sources(${name} PRIVATE ${AML_FALLBACK})
62+
set_target_properties(${name} PROPERTIES CXX_SCAN_FOR_MODULES OFF)
5663
return()
5764
endif ()
5865

@@ -62,48 +69,55 @@ function(add_module_library name)
6269
target_compile_options(${name} PUBLIC -fmodules-ts)
6370
endif ()
6471

65-
# `std` is affected by CMake options and may be higher than C++20.
66-
get_target_property(std ${name} CXX_STANDARD)
67-
68-
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
69-
set(pcms)
70-
foreach (src ${sources})
71-
get_filename_component(pcm ${src} NAME_WE)
72-
set(pcm ${pcm}.pcm)
73-
74-
# Propagate -fmodule-file=*.pcm to targets that link with this library.
75-
target_compile_options(
76-
${name} PUBLIC -fmodule-file=${CMAKE_CURRENT_BINARY_DIR}/${pcm})
77-
78-
# Use an absolute path to prevent target_link_libraries prepending -l
79-
# to it.
80-
set(pcms ${pcms} ${CMAKE_CURRENT_BINARY_DIR}/${pcm})
81-
add_custom_command(
82-
OUTPUT ${pcm}
83-
COMMAND ${CMAKE_CXX_COMPILER}
84-
-std=c++${std} -x c++-module --precompile -c
85-
-o ${pcm} ${CMAKE_CURRENT_SOURCE_DIR}/${src}
86-
"-I$<JOIN:$<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>,;-I>"
87-
# Required by the -I generator expression above.
88-
COMMAND_EXPAND_LISTS
89-
DEPENDS ${src})
90-
endforeach ()
91-
92-
# Add .pcm files as sources to make sure they are built before the library.
93-
set(sources)
94-
foreach (pcm ${pcms})
95-
get_filename_component(pcm_we ${pcm} NAME_WE)
96-
set(obj ${pcm_we}.o)
97-
# Use an absolute path to prevent target_link_libraries prepending -l.
98-
set(sources ${sources} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})
99-
add_custom_command(
100-
OUTPUT ${obj}
101-
COMMAND ${CMAKE_CXX_COMPILER} $<TARGET_PROPERTY:${name},COMPILE_OPTIONS>
102-
-c -o ${obj} ${pcm}
103-
DEPENDS ${pcm})
104-
endforeach ()
105-
endif ()
106-
target_sources(${name} PRIVATE ${sources})
72+
target_compile_definitions(${name} PRIVATE FMT_MODULE)
73+
74+
if (FMT_USE_CMAKE_MODULES)
75+
target_sources(${name} PUBLIC FILE_SET fmt TYPE CXX_MODULES
76+
FILES ${sources})
77+
else()
78+
# `std` is affected by CMake options and may be higher than C++20.
79+
get_target_property(std ${name} CXX_STANDARD)
80+
81+
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
82+
set(pcms)
83+
foreach (src ${sources})
84+
get_filename_component(pcm ${src} NAME_WE)
85+
set(pcm ${pcm}.pcm)
86+
87+
# Propagate -fmodule-file=*.pcm to targets that link with this library.
88+
target_compile_options(
89+
${name} PUBLIC -fmodule-file=${CMAKE_CURRENT_BINARY_DIR}/${pcm})
90+
91+
# Use an absolute path to prevent target_link_libraries prepending -l
92+
# to it.
93+
set(pcms ${pcms} ${CMAKE_CURRENT_BINARY_DIR}/${pcm})
94+
add_custom_command(
95+
OUTPUT ${pcm}
96+
COMMAND ${CMAKE_CXX_COMPILER}
97+
-std=c++${std} -x c++-module --precompile -c
98+
-o ${pcm} ${CMAKE_CURRENT_SOURCE_DIR}/${src}
99+
"-I$<JOIN:$<TARGET_PROPERTY:${name},INCLUDE_DIRECTORIES>,;-I>"
100+
# Required by the -I generator expression above.
101+
COMMAND_EXPAND_LISTS
102+
DEPENDS ${src})
103+
endforeach ()
104+
105+
# Add .pcm files as sources to make sure they are built before the library.
106+
set(sources)
107+
foreach (pcm ${pcms})
108+
get_filename_component(pcm_we ${pcm} NAME_WE)
109+
set(obj ${pcm_we}.o)
110+
# Use an absolute path to prevent target_link_libraries prepending -l.
111+
set(sources ${sources} ${pcm} ${CMAKE_CURRENT_BINARY_DIR}/${obj})
112+
add_custom_command(
113+
OUTPUT ${obj}
114+
COMMAND ${CMAKE_CXX_COMPILER} $<TARGET_PROPERTY:${name},COMPILE_OPTIONS>
115+
-c -o ${obj} ${pcm}
116+
DEPENDS ${pcm})
117+
endforeach ()
118+
endif ()
119+
target_sources(${name} PRIVATE ${sources})
120+
endif()
107121
endfunction()
108122

109123
include(CMakeParseArguments)
@@ -150,9 +164,10 @@ option(FMT_INSTALL "Generate the install target." ON)
150164
option(FMT_TEST "Generate the test target." ${FMT_MASTER_PROJECT})
151165
option(FMT_FUZZ "Generate the fuzz target." OFF)
152166
option(FMT_CUDA_TEST "Generate the cuda-test target." OFF)
153-
option(FMT_OS "Include core requiring OS (Windows/Posix) " ON)
167+
option(FMT_OS "Include OS-specific APIs." ON)
154168
option(FMT_MODULE "Build a module instead of a traditional library." OFF)
155169
option(FMT_SYSTEM_HEADERS "Expose headers with marking them as system." OFF)
170+
option(FMT_UNICODE "Enable Unicode support." ON)
156171

157172
if (FMT_TEST AND FMT_MODULE)
158173
# The tests require {fmt} to be compiled as traditional library
@@ -167,18 +182,18 @@ if (CMAKE_SYSTEM_NAME STREQUAL "MSDOS")
167182
message(STATUS "MSDOS is incompatible with gtest")
168183
endif ()
169184

170-
# Get version from core.h
171-
file(READ include/fmt/core.h core_h)
172-
if (NOT core_h MATCHES "FMT_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])")
173-
message(FATAL_ERROR "Cannot get FMT_VERSION from core.h.")
185+
# Get version from base.h
186+
file(READ include/fmt/base.h base_h)
187+
if (NOT base_h MATCHES "FMT_VERSION ([0-9]+)([0-9][0-9])([0-9][0-9])")
188+
message(FATAL_ERROR "Cannot get FMT_VERSION from base.h.")
174189
endif ()
175190
# Use math to skip leading zeros if any.
176191
math(EXPR CPACK_PACKAGE_VERSION_MAJOR ${CMAKE_MATCH_1})
177192
math(EXPR CPACK_PACKAGE_VERSION_MINOR ${CMAKE_MATCH_2})
178193
math(EXPR CPACK_PACKAGE_VERSION_PATCH ${CMAKE_MATCH_3})
179194
join(FMT_VERSION ${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.
180195
${CPACK_PACKAGE_VERSION_PATCH})
181-
message(STATUS "Version: ${FMT_VERSION}")
196+
message(STATUS "{fmt} version: ${FMT_VERSION}")
182197

183198
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
184199

@@ -274,20 +289,21 @@ function(add_headers VAR)
274289
endfunction()
275290

276291
# Define the fmt library, its includes and the needed defines.
277-
add_headers(FMT_HEADERS args.h chrono.h color.h compile.h core.h format.h
292+
add_headers(FMT_HEADERS args.h base.h chrono.h color.h compile.h core.h format.h
278293
format-inl.h os.h ostream.h printf.h ranges.h std.h
279294
xchar.h)
280295
set(FMT_SOURCES src/format.cc)
281-
if (FMT_OS)
282-
set(FMT_SOURCES ${FMT_SOURCES} src/os.cc)
283-
endif ()
284296

285297
add_module_library(fmt src/fmt.cc FALLBACK
286298
${FMT_SOURCES} ${FMT_HEADERS} README.md ChangeLog.md
287299
IF FMT_MODULE)
288300
add_library(fmt::fmt ALIAS fmt)
289301
if (FMT_MODULE)
290302
enable_module(fmt)
303+
elseif (FMT_OS)
304+
target_sources(fmt PRIVATE src/os.cc)
305+
else()
306+
target_compile_definitions(fmt PRIVATE FMT_OS=0)
291307
endif ()
292308

293309
if (FMT_WERROR)
@@ -339,6 +355,12 @@ endif ()
339355
add_library(fmt-header-only INTERFACE)
340356
add_library(fmt::fmt-header-only ALIAS fmt-header-only)
341357

358+
if (MSVC AND FMT_UNICODE)
359+
# Unicode support requires compiling with /utf-8.
360+
target_compile_options(fmt PUBLIC $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
361+
target_compile_options(fmt-header-only INTERFACE $<$<COMPILE_LANGUAGE:CXX>:/utf-8>)
362+
endif ()
363+
342364
target_compile_definitions(fmt-header-only INTERFACE FMT_HEADER_ONLY=1)
343365
target_compile_features(fmt-header-only INTERFACE cxx_std_11)
344366

@@ -388,12 +410,18 @@ if (FMT_INSTALL)
388410

389411
set(INSTALL_TARGETS fmt fmt-header-only)
390412

413+
set(INSTALL_FILE_SET)
414+
if (FMT_USE_CMAKE_MODULES)
415+
set(INSTALL_FILE_SET FILE_SET fmt DESTINATION "${FMT_INC_DIR}/fmt")
416+
endif()
417+
391418
# Install the library and headers.
392419
install(TARGETS ${INSTALL_TARGETS} EXPORT ${targets_export_name}
393420
LIBRARY DESTINATION ${FMT_LIB_DIR}
394421
ARCHIVE DESTINATION ${FMT_LIB_DIR}
395422
PUBLIC_HEADER DESTINATION "${FMT_INC_DIR}/fmt"
396-
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
423+
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
424+
${INSTALL_FILE_SET})
397425

398426
# Use a namespace because CMake provides better diagnostics for namespaced
399427
# imported targets.
@@ -410,8 +438,44 @@ if (FMT_INSTALL)
410438
install(FILES "${pkgconfig}" DESTINATION "${FMT_PKGCONFIG_DIR}")
411439
endif ()
412440

441+
function(add_doc_target)
442+
find_program(DOXYGEN doxygen
443+
PATHS "$ENV{ProgramFiles}/doxygen/bin"
444+
"$ENV{ProgramFiles\(x86\)}/doxygen/bin")
445+
if (NOT DOXYGEN)
446+
message(STATUS "Target 'doc' disabled because doxygen not found")
447+
return ()
448+
endif ()
449+
450+
find_program(MKDOCS mkdocs)
451+
if (NOT MKDOCS)
452+
message(STATUS "Target 'doc' disabled because mkdocs not found")
453+
return ()
454+
endif ()
455+
456+
set(sources )
457+
foreach (source api.md index.md syntax.md get-started.md fmt.css fmt.js)
458+
set(sources ${sources} doc/${source})
459+
endforeach()
460+
461+
add_custom_target(
462+
doc
463+
COMMAND
464+
${CMAKE_COMMAND}
465+
-E env PYTHONPATH=${CMAKE_CURRENT_SOURCE_DIR}/support/python
466+
${MKDOCS} build -f ${CMAKE_CURRENT_SOURCE_DIR}/support/mkdocs.yml
467+
# MkDocs requires the site dir to be outside of the doc dir.
468+
--site-dir ${CMAKE_CURRENT_BINARY_DIR}/doc-html
469+
--no-directory-urls
470+
SOURCES ${sources})
471+
472+
include(GNUInstallDirs)
473+
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/doc-html/
474+
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/doc/fmt OPTIONAL)
475+
endfunction()
476+
413477
if (FMT_DOC)
414-
add_subdirectory(doc)
478+
add_doc_target()
415479
endif ()
416480

417481
if (FMT_TEST)
@@ -441,8 +505,7 @@ if (FMT_MASTER_PROJECT AND EXISTS ${gitignore})
441505
string(REPLACE "*" ".*" line "${line}")
442506
set(ignored_files ${ignored_files} "${line}$" "${line}/")
443507
endforeach ()
444-
set(ignored_files ${ignored_files}
445-
/.git /breathe /format-benchmark sphinx/ .buildinfo .doctrees)
508+
set(ignored_files ${ignored_files} /.git /build/doxyxml .vagrant)
446509

447510
set(CPACK_SOURCE_GENERATOR ZIP)
448511
set(CPACK_SOURCE_IGNORE_FILES ${ignored_files})

0 commit comments

Comments
 (0)