Build in CMake with these params:
CMAKE_CXX_FLAGS:STRING= -fsanitize=address -fsanitize=leak -g
CMAKE_C_FLAGS:STRING=-fsanitize=address -fsanitize=leak -g
CMAKE_EXE_LINKER_FLAGS:STRING=-fsanitize=address -fsanitize=leak
CMAKE_MODULE_LINKER_FLAGS:STRING=-fsanitize=address -fsanitize=leak
Which can be done with:
cmake .. -DCMAKE_CXX_FLAGS="-fsanitize=address -fsanitize=leak -g" -DCMAKE_C_FLAGS="-fsanitize=address -fsanitize=leak -g" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak" -DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=address -fsanitize=leak"
Then run with:
export ASAN_OPTIONS=fast_unwind_on_malloc=0
Which can be done with:
cmake .. -DCMAKE_CXX_FLAGS="-fsanitize=thread -g" -DCMAKE_C_FLAGS="-fsanitize=thread -g" -DCMAKE_EXE_LINKER_FLAGS="-fsanitize=thread" -DCMAKE_MODULE_LINKER_FLAGS="-fsanitize=thread"
these seems to not work if i have a Makefile instead of a CMakeLists.txt.
I think this should work tought if you put this at the beginning of the file: (deny/confirm?)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fsanitize=leak -g")