How do I get CMake to always set/add the /PROFILE linker flag for the RelWithDebInfo MSVC (17) target?
You can check if you're targeting MSVC, and if so use a generator expression to add /PROFILE to the link options for your target if RelWithDebInfo is the target.
if (MSVC)
target_link_options(my_target PRIVATE $<$<CONFIG:RELWITHDEBINFO>:/PROFILE>)
endif()
target_link_options is from 3.13, you can use target_link_libraries if you're on an old version.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With