Skip to content

cmake: use target_link_options() when available#17670

Closed
vszakats wants to merge 5 commits intocurl:masterfrom
vszakats:cm-use-target_link_options
Closed

cmake: use target_link_options() when available#17670
vszakats wants to merge 5 commits intocurl:masterfrom
vszakats:cm-use-target_link_options

Conversation

@vszakats
Copy link
Copy Markdown
Member

@vszakats vszakats commented Jun 19, 2025

To pass -municode to the linker. Before this patch we passed this via
target_link_libraries() which is designed to pass libraries. Keep
using it for old CMake versions, where no better alternative existed.

https://cmake.org/cmake/help/latest/command/target_link_options.html

Also:

  • also pass -municode as PRIVATE for old cmake versions.
    (it should not make a difference because no target depends on the curl
    tool, but this seem to be the modern, non-ambiguous syntax.)
  • unfold a bunch of split lines for greppability of add_library() and
    add_executable() commands.
  • quote a string.

To pass `-municode` to the linker. Before this patch we passed this via
`target_link_libraries()` which is designed to pass libraries. Keep
using it for old CMake versions, where no better alternative existed.

https://cmake.org/cmake/help/latest/command/target_link_options.html
@vszakats vszakats closed this in 5488739 Jun 19, 2025
@vszakats vszakats deleted the cm-use-target_link_options branch June 19, 2025 11:03
denandz pushed a commit to denandz/curl that referenced this pull request Jun 21, 2025
To pass `-municode` to the linker. Before this patch we passed this via
`target_link_libraries()` which is designed to pass libraries. Keep
using it for old CMake versions, where no better alternative existed.

https://cmake.org/cmake/help/latest/command/target_link_options.html

Also:
- also pass `-municode` as `PRIVATE` for old cmake versions.
  (it should not make a difference because no target depends on the curl
  tool, but this seem to be the modern, non-ambiguous syntax.)
- unfold a bunch of split lines for greppability of `add_library()` and
  `add_executable()` commands.
- quote a string.

Closes curl#17670
vszakats added a commit that referenced this pull request Sep 29, 2025
- replace `COMPILE_FLAGS` with `COMPILE_OPTIONS` that superceded it.

  Follow-up to 6140dfc
  https://cmake.org/cmake/help/v4.1/prop_sf/COMPILE_FLAGS.html

- replace `target_link_libraries()` with `LINK_FLAGS` property for
  CMake <=3.12, because we are passing linker options (not libs).

  Follow-up to 91720b6 #18468
  Follow-up to 5488739 #17670
  Follow-up to 95aea79 #5843
  https://cmake.org/cmake/help/v3.7/command/target_link_libraries.html
  https://cmake.org/cmake/help/v3.7/prop_tgt/LINK_FLAGS.html

- replace `target_link_options()` with `LINK_OPTIONS` propery for
  CMake 3.13+, to use the modern style.

  Follow-up to 91720b6 #18468
  Follow-up to 5488739 #17670
  https://cmake.org/cmake/help/v3.13/command/target_link_options.html
  https://cmake.org/cmake/help/v3.13/prop_tgt/LINK_OPTIONS.html

Also:

- fix to append to, not override, previously set linker options when
  using `CURL_LIBCURL_VERSIONED_SYMBOLS=ON`. Before this patch, it was
  overwriting linker options when using `CURL_CODE_COVERAGE=ON`.

  Follow-up to 91720b6 #18468

Closes #18762
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Development

Successfully merging this pull request may close these issues.

1 participant