Reputation: 478
I'm working on a CMake projects with several targets.
I'm activating ADDRESS SANITIZER by CMake (ccmake .
and put ADDRESS_SANITIZER=ON
). It is activated correctly, although I would like to inactivate it on one of the target. To do this, I added -fno-sanitize=all
to the compiler flags of the target but it is not taken into account.
Is there a way to inactivate the sanitizer for a certain target? The target in question does not depend on any library or any other target of the project. It only depends on LLVM libraries installed on the machine.
The subproject has its own CMakeList.txt
and added as a subproject to the main one.
-fno-sanitize=all
is set by set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=all"
Upvotes: 0
Views: 1063
Reputation: 478
Instead of set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-sanitize=all
I've used target_compile_options(target -fno-sanitize=all)
which solved the problem.
Upvotes: 2