Skip to content

cmake: avoid passing options via CMAKE_*_FLAGS - #1575

Closed
vszakats wants to merge 6 commits into
libssh2:masterfrom
vszakats:cm-compoptions
Closed

vszakats wants to merge 6 commits into
libssh2:masterfrom
vszakats:cm-compoptions

Conversation

@vszakats

@vszakats vszakats commented Apr 14, 2025 •

Copy link
Copy Markdown
Member
  • replace CMAKE_C_FLAGS* and CMAKE_CXX_FLAGS with COMPILE_OPTIONS.
  • replace CMAKE_SHARED_LINKER_FLAGS_DEBUG with
    LINK_OPTIONS/LINK_FLAGS.
  • make it explicit to pass these C flags to feature checks.
  • 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.

@vszakats vszakats added the build label Apr 14, 2025
@vszakats vszakats closed this in a8e4456 Apr 14, 2025
@vszakats
vszakats deleted the cm-compoptions branch April 14, 2025 23:48
vszakats added a commit to vszakats/libssh2 that referenced this pull request Sep 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant