-
-
Notifications
You must be signed in to change notification settings - Fork 6.4k
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
cmake: fix to find snprintf #10155
cmake: fix to find snprintf #10155
Conversation
I haven't had the time to check other configurations, but on my macOS Ventura 13.1 with XCode 14.2 cmake does not find `snprintf`. curl continues to build and work just fine, however since HAVE_SNPRINTF variable is cached, other dependencies (for example [json-c](https://github.com/json-c/json-c)) skip the check due to the way `check_symbol_exists` and assume that `snprintf` is not defined. Solution: ensure stdio.h is checked for definitions This way other dependencies have a fair shot at checking whether this function is available without being presented with a false negative.
I am also trying to patch CMake to solve the underlying issue I ran into: https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8042 |
I deleted that check in 4d73854, because it wasn't used in the curl codebase. It seems unexpected to check for features we do not use locally (for a CMake novice at least). Could this be solved by fixing our If we end up checking for |
Of course, the more significant underlying issue is how CMake's I am not sure what you mean by "check for features we do not use locally" Here's one use of HAVE_SNPRINTF here: Lines 972 to 975 in 1c567f7
The surface is indeed tiny, but I wonder if in fact curl never/rarely detects snprintf as being available? I just spun up a bare Ubuntu docker image and tried to build curl on it, and here's what I got:
This suggests that curl may be not using Not sure about the implications of having HAVE_STDIO_H defined you had in mind. Can you elaborate? |
Sure it does, if you use configure or another build system that sets that define. |
Fair, I meant in the context of using CMake. Apologies for the lack of clarity on this. |
This PR does not change the way the presence of this function is checked, it simply gives |
@vszakats there's a check for snprintf: https://github.com/curl/curl/blob/master/CMakeLists.txt#L1095 But it is failing because stdio.h is not included |
Got it. Still looks odd, and maintaining my opinion that a comment documenting this peculiarity would be useful. This could prevent accidentally deleting this check in the future because of no local macro references. If there is a more self-documenting way to force-include |
Solution: move stdio.h reference to the check that uses it
@vszakats got it! I've updated the PR to clarify which check requires |
@yrashk Thank you for your update, it clears up all concerns from my end indeed. |
Thanks! |
I haven't had the time to check other configurations, but on my macOS Ventura 13.1 with XCode 14.2 cmake does not find
snprintf
.curl continues to build and work just fine, however since HAVE_SNPRINTF variable is cached, other dependencies (for example json-c) skip the check due to the way
check_symbol_exists
and assume thatsnprintf
is not defined.Solution: ensure stdio.h is checked for definitions
This way other dependencies have a fair shot at checking whether this function is available without being presented with a false negative.