Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Setting /PROFILE Linker Flag for CMake MSVC Target

How do I get CMake to always set/add the /PROFILE linker flag for the RelWithDebInfo MSVC (17) target?

like image 584
Adi Shavit Avatar asked Nov 18 '25 08:11

Adi Shavit


1 Answers

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.

like image 170
TartanLlama Avatar answered Nov 21 '25 09:11

TartanLlama