-
Notifications
You must be signed in to change notification settings - Fork 216
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Expose spdlog option to use std::format instead of internal fmt lib #1336
Conversation
23ffc2a
to
9cb5e31
Compare
Might want to add a check if std::format can be used. |
@neheb added a check for the |
@@ -24,7 +24,9 @@ if get_option('external_fmt').enabled() | |||
endif | |||
|
|||
if get_option('std_format').enabled() | |||
spdlog_compile_args += '-DSPDLOG_USE_STD_FORMAT' | |||
if meson.get_compiler('cpp').has_header('format', required: true) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
required can take a feature option directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm aware that required can take get_option('std_format'))
directly but this whole branch is gated by the if get_option('std_format').enabled()
anyway so the header check is always required.
If the option isn't specified in the first if statement, the has_header()
check will never execute.
Setting required to true
is a logical optimization.
This is what I think you're proposing, please clarify if my assumption is wrong:
if get_option('std_format').enabled()
if meson.get_compiler('cpp').has_header('format', required: get_option('std_format'))
spdlog_compile_args += '-DSPDLOG_USE_STD_FORMAT'
endif
endif
The check is not enough actually. If compiling in a C++ mode lower than 17, it will still succeed. I haven't tested if check_header works. That would be the cleanest solution. In exiv2, I currently use
|
Updated the check to use the new C++20 library feature test macros like you proposed, and verified it worked locally with GCC 13 on macOS. One question: do we need to do any feature gating for the C++ standard version here? If a user is using C++17 and using the |
I think it's best to modify the build file as such:
|
Looks reasonable and passed tests locally. I didn't realize |
if meson.get_compiler('cpp').has_header_symbol('format', '__cpp_lib_format', required: get_option('std_format')) | ||
spdlog_compile_args += '-DSPDLOG_USE_STD_FORMAT' | ||
else | ||
fmt_dep = dependency('fmt', version: '>=8.1', required: get_option('external_fmt').enabled()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you don't need enabled() here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed
…esonbuild#1336) * Expose spdlog option to use std::format instead of internal fmt lib
Now that
std::format
is available in recent compiler versions (Clang 17, GCC 13), it's possible to use the compiler-providedstd::format
instead of fmtlib.spdlog already provides this functionality upstream and exposes it in CMake, but it's not an option with Meson.
This change adds support for that functionality to our wrap.