cpp-best-practices / cpp-best-practices/cmake_template
Linker.cmake should use target_link_options instead of target_compile_options
- Dominant language
- CMake
- Stars
- 1.8k
- Forks
- 204
- PR merge metrics
- No merged PRs in 30d
Description
https://github.com/cpp-best-practices/cmake_template/blob/d19d8921771ba582824948f0cc57f849a5c6efd8/cmake/Linker.cmake#L29
From my understanding `target_compile_options` can be replaced by the more appropriate `target_link_options`.
### Motivation
Functionally there's no difference, but adding linker-specific flags to the compilation step will raise warnings e.g. `clang: error: argument unused during compilation: '-fuse-ld=mold' [-Werror,-Wunused-command-line-argument]` in certain setups.
Example from CI in a [project of mine](https://github.com/CramBL/mtgo-collection-manager/actions/runs/6598600605/job/17926746476). Treating warnings as errors means this harmless warning caused CI to fail.
Using `target_link_options` resolved it.
> Thank you for sharing and maintaining this template project, it is a tremendous help!
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.