79275542

Date: 2024-12-12 14:54:34
Score: 2.5
Natty:
Report link

Now CMake has CMAKE_LINK_WHAT_YOU_USE, simply set it to ON before you create the target.

document:

https://cmake.org/cmake/help/latest/variable/CMAKE_LINK_WHAT_YOU_USE.html

and you can see its effect:

https://gitlab.kitware.com/cmake/cmake/-/blob/f4428d97843d34663e2a40d4424c12477540a9b2/Modules/Internal/CMakeCommonLinkerInformation.cmake#L12

it will add -Wl,--no-as-needed to link flags.

Reasons:
  • Probably link only (1):
  • Low length (1):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: LXYan