If you want to add a flag to every link, e.g. -fsanitize=address
then I would not recommend using CMAKE_*_LINKER_FLAGS
. Even with them all set it still doesn't use the flag when linking a framework on OSX, and maybe in other situations. Instead use link_libraries()
:
add_compile_options("-fsanitize=address")
link_libraries("-fsanitize=address")
This works for everything.