Just for reference, I’m guessing this is related to the problem in this post?
How did you verify that the options weren’t set? Variables such as CMAKE_CXX_FLAGS will not be modified by target_compile_options, you’d have to check the actual options on the target via get_target_properties on property COMPILE_OPTIONS (or by checking the actual compiler calls in the output of a verbose build).
The flags are not in the target properties, I’ve checked with get_target_property() after that post. I literally have no idea why they aren’t being set.
get_target_property(cflags ${AVL_CURRENT_PROJECT_NAME} COMPILE_OPTIONS)
message("The project has set the following flags: ${cflags}")
The example code looks fine to me. I’d check cmake --trace-expand to make sure that your -fsanitize= flags are actually being added in the first place.
I’ll note that -fsanitize= usually needs passed to the linker as well to grab the right runtime library too.