-
-
Notifications
You must be signed in to change notification settings - Fork 6.7k
cmake: prefer COMPILE_OPTIONS
over CMAKE_C_FLAGS
for custom C options
#17047
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
Closed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pass to feature checks pipe2 also requires _GNU_SOURCE fixup passing _GNU_SOURCE to feature checks
d7fa798
to
5f6eec4
Compare
This reverts commit aa4330e.
3f12422
to
7bb998b
Compare
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Apr 14, 2025
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Apr 14, 2025
vszakats
added a commit
that referenced
this pull request
Apr 14, 2025
Also: - drop unnecessary type conversion. `CMAKE_REQUIRED_FLAGS` is already space-separated. https://cmake.org/cmake/help/latest/module/CheckCSourceCompiles.html Follow-up to e865420 #17047 Closes #17055
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Apr 15, 2025
Safe to do this now, as the code no longer relies on setting these options after feature detection. Follow-up to e865420 curl#17047
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Apr 24, 2025
Follow-up to e865420 curl#17047 Ref: 866e029 curl#1711
This was referenced Apr 24, 2025
vszakats
added a commit
to vszakats/curl
that referenced
this pull request
Apr 25, 2025
Follow-up to e865420 curl#17047 Ref: 866e029 curl#1711
vszakats
added a commit
that referenced
this pull request
Apr 25, 2025
1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it may be unexpected. 2. We pass `-W4`/`-Wall` internally now, which do override custom `-W<n>` options in all supported MSVC versions. (as tested with Visual Studio generators) Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51945416 Follow-up to e865420 #17047 Ref: 866e029 #1711 Closes #17179
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
…ions Also: - pass `-D_GNU_SOURCE` via `COMPILE_DEFINITIONS`. - make it explicit to pass these C flags to feature checks. - update `_GNU_SOURCE` comment with `pipe2()`. - enable `-pedantic-errors` picky option for GCC with CMake <3.23. - drop redundant condition when stripping existing MSVC `/Wn` options. CMake passes `CMAKE_C_FLAGS` to targets, feature checks and raw `try_compile()` calls. With `COMPILE_OPTIONS`, this is limited to targets, and we must explicitly pass them to feature checks. This makes the build logic clearer, and offers more control. It also reduces log noise by omitting these options from linker commands, and from `CMAKE_C_FLAGS` dumps in feature checks. Closes curl#17047
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
Also: - drop unnecessary type conversion. `CMAKE_REQUIRED_FLAGS` is already space-separated. https://cmake.org/cmake/help/latest/module/CheckCSourceCompiles.html Follow-up to e865420 curl#17047 Closes curl#17055
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
Safe to do this now, as the code no longer relies on setting these options after feature detection. Also: Tidy up the way we handle options not to be passed to feature checks, and make sure to show them in the configure log. Follow-up to e865420 curl#17047 Closes curl#17062
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
1. `CMAKE_C_FLAGS` may apply to other projects, and deleting/altering it may be unexpected. 2. We pass `-W4`/`-Wall` internally now, which do override custom `-W<n>` options in all supported MSVC versions. (as tested with Visual Studio generators) Ref: https://ci.appveyor.com/project/curlorg/curl/builds/51945416 Follow-up to e865420 curl#17047 Ref: 866e029 curl#1711 Closes curl#17179
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
…ions Also: - pass `-D_GNU_SOURCE` via `COMPILE_DEFINITIONS`. - make it explicit to pass these C flags to feature checks. - update `_GNU_SOURCE` comment with `pipe2()`. - enable `-pedantic-errors` picky option for GCC with CMake <3.23. - drop redundant condition when stripping existing MSVC `/Wn` options. CMake passes `CMAKE_C_FLAGS` to targets, feature checks and raw `try_compile()` calls. With `COMPILE_OPTIONS`, this is limited to targets, and we must explicitly pass them to feature checks. This makes the build logic clearer, and offers more control. It also reduces log noise by omitting these options from linker commands, and from `CMAKE_C_FLAGS` dumps in feature checks. Closes curl#17047
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
Also: - drop unnecessary type conversion. `CMAKE_REQUIRED_FLAGS` is already space-separated. https://cmake.org/cmake/help/latest/module/CheckCSourceCompiles.html Follow-up to e865420 curl#17047 Closes curl#17055
nbaws
pushed a commit
to nbaws/curl
that referenced
this pull request
Apr 26, 2025
Safe to do this now, as the code no longer relies on setting these options after feature detection. Also: Tidy up the way we handle options not to be passed to feature checks, and make sure to show them in the configure log. Follow-up to e865420 curl#17047 Closes curl#17062
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Also:
-D_GNU_SOURCE
viaCOMPILE_DEFINITIONS
._GNU_SOURCE
comment withpipe2()
.-pedantic-errors
picky option for GCC with CMake <3.23./Wn
options.CMake passes
CMAKE_C_FLAGS
to targets, feature checks and rawtry_compile()
calls. WithCOMPILE_OPTIONS
, this is limited totargets, and we must explicitly pass them to feature checks. This
makes the build logic clearer, and offers more control. It also
reduces log noise by omitting these options from linker commands,
and from
CMAKE_C_FLAGS
dumps in feature checks.