Skip to content

Commit 95b4763

Browse files
committed
Update fmt and spdlog to fix build issue with recent Clang
1 parent 85780ee commit 95b4763

7 files changed

Lines changed: 210 additions & 1 deletion

File tree

CMakePresets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,8 @@
5050
"CMAKE_TOOLCHAIN_FILE": {
5151
"type": "PATH",
5252
"value": "${sourceDir}/submodules/vcpkg/scripts/buildsystems/vcpkg.cmake"
53-
}
53+
},
54+
"VCPKG_OVERLAY_PORTS": "${sourceDir}/vcpkg_overlay_ports"
5455
},
5556
"environment": {
5657
"CMAKE_POLICY_VERSION_MINIMUM": "3.5"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
vcpkg_download_distfile(FMT_BACKPORT_4813_PATCH
2+
URLS https://github.com/fmtlib/fmt/commit/588b3a0f8f6a8bcf2a959cae882d5b2703e86737.patch?full_index=1
3+
FILENAME fmt-backport-4813.patch
4+
SHA512 afda8fdfcdcb4b0dd5df4d4dae96a57a85fb9c4b65d0b49d51258f0913d4aed93ed146ebf96ed7b277490b1dde6c7117f43332013071441a96c3147520de8368
5+
)
6+
7+
vcpkg_from_github(
8+
OUT_SOURCE_PATH SOURCE_PATH
9+
REPO fmtlib/fmt
10+
REF "${VERSION}"
11+
SHA512 5ac2ba0f54a484999ed5407d82b77aad170cea49a267decd2c0eedadf3b14413e2a83fcc8e9ca9c16640595e019b8636e160f72314d8be50653324e82ac745eb
12+
HEAD_REF master
13+
PATCHES
14+
"${FMT_BACKPORT_4813_PATCH}"
15+
)
16+
17+
vcpkg_cmake_configure(
18+
SOURCE_PATH "${SOURCE_PATH}"
19+
OPTIONS
20+
-DFMT_CMAKE_DIR=share/fmt
21+
-DFMT_TEST=OFF
22+
-DFMT_DOC=OFF
23+
)
24+
25+
vcpkg_cmake_install()
26+
vcpkg_cmake_config_fixup()
27+
vcpkg_fixup_pkgconfig()
28+
vcpkg_copy_pdbs()
29+
30+
file(REMOVE_RECURSE
31+
"${CURRENT_PACKAGES_DIR}/debug/include"
32+
"${CURRENT_PACKAGES_DIR}/debug/share"
33+
)
34+
35+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
36+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

vcpkg_overlay_ports/fmt/usage

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The package fmt provides CMake targets:
2+
3+
find_package(fmt CONFIG REQUIRED)
4+
target_link_libraries(main PRIVATE fmt::fmt)
5+
6+
# Or use the header-only version
7+
find_package(fmt CONFIG REQUIRED)
8+
target_link_libraries(main PRIVATE fmt::fmt-header-only)

vcpkg_overlay_ports/fmt/vcpkg.json

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"name": "fmt",
3+
"version": "12.2.0",
4+
"port-version": 1,
5+
"description": "{fmt} is an open-source formatting library providing a fast and safe alternative to C stdio and C++ iostreams.",
6+
"homepage": "https://github.com/fmtlib/fmt",
7+
"license": "MIT",
8+
"dependencies": [
9+
{
10+
"name": "vcpkg-cmake",
11+
"host": true
12+
},
13+
{
14+
"name": "vcpkg-cmake-config",
15+
"host": true
16+
}
17+
]
18+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
vcpkg_download_distfile(SPDLOG_BACKPORT_3541_PATCH
2+
URLS https://github.com/gabime/spdlog/commit/1685e694c5cd8328280c48f8b94b1281c17c6fee.patch?full_index=1
3+
FILENAME spdlog-backport-3541.patch
4+
SHA512 9b5340c93b9a869ae7479395e23672288fc3b4347fc1e9a4535b580a6ade1dadd985e939fb5fbb820d262f0c2153599a88dd572443b62dab3498da8b327ee034
5+
)
6+
vcpkg_download_distfile(SPDLOG_BACKPORT_3543_PATCH
7+
URLS https://github.com/gabime/spdlog/commit/d5af52d903ed69f96c7350155e94aeff248b31eb.patch?full_index=1
8+
FILENAME spdlog-backport-3543.patch
9+
SHA512 ada7e63920a48fa1641bf4929b6172c4e8570e2610534caf9fd1a769d00d304b7c5907987420f85989295a939aa1e75cf18c54bbf3ccc6ccad594a24aba2e8b9
10+
)
11+
12+
vcpkg_from_github(
13+
OUT_SOURCE_PATH SOURCE_PATH
14+
REPO gabime/spdlog
15+
REF "v${VERSION}"
16+
SHA512 8df117055d19ff21c9c9951881c7bdf27cc0866ea3a4aa0614b2c3939cedceab94ac9abaa63dc4312b51562b27d708cb2f014c68c603fd1c1051d3ed5c1c3087
17+
HEAD_REF v1.x
18+
PATCHES
19+
"${SPDLOG_BACKPORT_3541_PATCH}"
20+
"${SPDLOG_BACKPORT_3543_PATCH}"
21+
)
22+
23+
vcpkg_check_features(OUT_FEATURE_OPTIONS FEATURE_OPTIONS
24+
FEATURES
25+
benchmark SPDLOG_BUILD_BENCH
26+
fmt SPDLOG_FMT_EXTERNAL
27+
wchar SPDLOG_WCHAR_SUPPORT
28+
INVERTED_FEATURES
29+
fmt SPDLOG_USE_STD_FORMAT
30+
tz-offset SPDLOG_NO_TZ_OFFSET
31+
)
32+
33+
# SPDLOG_WCHAR_FILENAMES can only be configured in triplet file since it is an alternative (not additive)
34+
if(NOT DEFINED SPDLOG_WCHAR_FILENAMES)
35+
set(SPDLOG_WCHAR_FILENAMES OFF)
36+
endif()
37+
if(NOT VCPKG_TARGET_IS_WINDOWS AND SPDLOG_WCHAR_FILENAMES)
38+
message(FATAL_ERROR "Build option 'SPDLOG_WCHAR_FILENAMES' is for Windows.")
39+
endif()
40+
41+
string(COMPARE EQUAL "${VCPKG_LIBRARY_LINKAGE}" "dynamic" SPDLOG_BUILD_SHARED)
42+
43+
vcpkg_cmake_configure(
44+
SOURCE_PATH "${SOURCE_PATH}"
45+
OPTIONS
46+
${FEATURE_OPTIONS}
47+
-DSPDLOG_INSTALL=ON
48+
-DSPDLOG_BUILD_SHARED=${SPDLOG_BUILD_SHARED}
49+
-DSPDLOG_WCHAR_FILENAMES=${SPDLOG_WCHAR_FILENAMES}
50+
-DSPDLOG_BUILD_EXAMPLE=OFF
51+
)
52+
53+
vcpkg_cmake_install()
54+
vcpkg_cmake_config_fixup(CONFIG_PATH lib/cmake/spdlog)
55+
vcpkg_fixup_pkgconfig()
56+
vcpkg_copy_pdbs()
57+
58+
if(NOT VCPKG_BUILD_TYPE)
59+
vcpkg_replace_string("${CURRENT_PACKAGES_DIR}/debug/lib/pkgconfig/spdlog.pc" " -lspdlog" " -lspdlogd")
60+
endif()
61+
62+
# add support for integration other than cmake
63+
if(SPDLOG_FMT_EXTERNAL)
64+
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
65+
"// #define SPDLOG_FMT_EXTERNAL"
66+
"#ifndef SPDLOG_FMT_EXTERNAL\n#define SPDLOG_FMT_EXTERNAL\n#endif"
67+
)
68+
endif()
69+
if(SPDLOG_USE_STD_FORMAT)
70+
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
71+
"// #define SPDLOG_USE_STD_FORMAT"
72+
"#ifndef SPDLOG_USE_STD_FORMAT\n#define SPDLOG_USE_STD_FORMAT\n#endif"
73+
)
74+
endif()
75+
if(SPDLOG_WCHAR_SUPPORT)
76+
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
77+
"// #define SPDLOG_WCHAR_TO_UTF8_SUPPORT"
78+
"#ifndef SPDLOG_WCHAR_TO_UTF8_SUPPORT\n#define SPDLOG_WCHAR_TO_UTF8_SUPPORT\n#endif"
79+
)
80+
endif()
81+
if(SPDLOG_WCHAR_FILENAMES)
82+
vcpkg_replace_string(${CURRENT_PACKAGES_DIR}/include/spdlog/tweakme.h
83+
"// #define SPDLOG_WCHAR_FILENAMES"
84+
"#ifndef SPDLOG_WCHAR_FILENAMES\n#define SPDLOG_WCHAR_FILENAMES\n#endif"
85+
)
86+
endif()
87+
88+
file(REMOVE_RECURSE
89+
"${CURRENT_PACKAGES_DIR}/include/spdlog/fmt/bundled"
90+
"${CURRENT_PACKAGES_DIR}/debug/include"
91+
"${CURRENT_PACKAGES_DIR}/debug/share"
92+
)
93+
94+
file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/usage" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
95+
vcpkg_install_copyright(FILE_LIST "${SOURCE_PATH}/LICENSE")

vcpkg_overlay_ports/spdlog/usage

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
The package spdlog provides CMake targets:
2+
3+
find_package(spdlog CONFIG REQUIRED)
4+
target_link_libraries(main PRIVATE spdlog::spdlog)
5+
6+
# Or use the header-only version
7+
find_package(spdlog CONFIG REQUIRED)
8+
target_link_libraries(main PRIVATE spdlog::spdlog_header_only)
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"name": "spdlog",
3+
"version-semver": "1.17.0",
4+
"port-version": 1,
5+
"description": "Very fast, header-only/compiled, C++ logging library.",
6+
"homepage": "https://github.com/gabime/spdlog",
7+
"license": "MIT",
8+
"dependencies": [
9+
{
10+
"name": "vcpkg-cmake",
11+
"host": true
12+
},
13+
{
14+
"name": "vcpkg-cmake-config",
15+
"host": true
16+
}
17+
],
18+
"default-features": [
19+
"fmt",
20+
"tz-offset"
21+
],
22+
"features": {
23+
"benchmark": {
24+
"description": "Use google benchmark",
25+
"dependencies": [
26+
"benchmark"
27+
]
28+
},
29+
"fmt": {
30+
"description": "Use fmt library",
31+
"dependencies": [
32+
"fmt"
33+
]
34+
},
35+
"tz-offset": {
36+
"description": "Omit %z timezone offset (use on platforms without tm_gmtoff)"
37+
},
38+
"wchar": {
39+
"description": "Build with wchar_t (Windows only)",
40+
"supports": "windows"
41+
}
42+
}
43+
}

0 commit comments

Comments
 (0)