I have a enable_sanitizers()
function like this:
function(enable_sanitizers project_name)
...
target_compile_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS} -fno-optimize-sibling-calls -lrt -fno-omit-frame-pointer)
target_link_options(${project_name} INTERFACE -fsanitize=${LIST_OF_SANITIZERS} -fno-optimize-sibling-calls -lrt -fno-omit-frame-pointer)
...
message("[sanitizer] Project: ${project_name}")
message("[sanitizer] Compile options: ${COMPILE_OPTIONS}")
message("[sanitizer] Link options: ${LINK_OPTIONS}")
# Tried this too:
message("[sanitizer] Compile options: ${${project_name}_COMPILE_OPTIONS}")
message("[sanitizer] Link options: ${${project_name}_LINK_OPTIONS}")
endfunction()
The thing, the reason I wanna print this is because I don’t see CMAKE_CXX_FLAGS
being set after adding the executable, enabling the sanitizers and etc. I also don’t see sanitizers working on a small test I put up.