]> git.ipfire.org Git - thirdparty/curl.git/commit
cmake: prefer `COMPILE_OPTIONS` over `CMAKE_C_FLAGS` for custom C options
authorViktor Szakats <commit@vsz.me>
Mon, 14 Apr 2025 07:50:30 +0000 (09:50 +0200)
committerViktor Szakats <commit@vsz.me>
Mon, 14 Apr 2025 19:31:39 +0000 (21:31 +0200)
commite86542038dda88dadf8959584e803895f979310c
treefbae9319904e537d990d78649e3f34a53b997b9f
parentd9ca7ad5cb036c429faca2af81be8c8cbc332236
cmake: prefer `COMPILE_OPTIONS` over `CMAKE_C_FLAGS` for custom C options

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 #17047
CMake/Macros.cmake
CMake/PickyWarnings.cmake
CMakeLists.txt