mirror of
https://github.com/Kitware/CMake.git
synced 2026-01-04 12:49:36 -06:00
In commit d7159f9591, (Ninja: Fix LINK_WHAT_YOU_USE link flag placement,
2021-06-24), we fixed usage of -Wl,--no-as-needed to override
-Wl,--as-needed from LDFLAGS. However, that change also passes
-Wl,--no-as-needed to `ar`, which is incorrect flag for `ar`.
Let's check the target type before passing down the flags.
Fixes: #22487
6 lines
141 B
CMake
6 lines
141 B
CMake
enable_language(C)
|
|
set(CMAKE_LINK_WHAT_YOU_USE TRUE)
|
|
add_executable(main main.c)
|
|
target_link_libraries(main m)
|
|
add_library(foo STATIC foo.c)
|