Skip to content

Instantly share code, notes, and snippets.

@robertodr
Created November 19, 2017 16:04
Show Gist options
  • Save robertodr/b16848f117d4c4dfe6807cad25ace8c0 to your computer and use it in GitHub Desktop.
Save robertodr/b16848f117d4c4dfe6807cad25ace8c0 to your computer and use it in GitHub Desktop.
include(CheckCXXCompilerFlag)
list(APPEND ASAN_FLAGS "-fsanitize=address" "-fno-omit-frame-pointer")
foreach(flag IN LISTS ASAN_FLAGS)
set(CMAKE_REQUIRED_FLAGS ${flag})
check_cxx_compiler_flag(${flag} flag_works)
unset(CMAKE_REQUIRED_FLAGS)
if(flag_works)
string(REPLACE " " ";" _flag ${flag})
list(APPEND _asan_flags ${_flag})
endif()
unset(flag_works CACHE)
endforeach()
@robertodr
Copy link
Author

@bast primitive version of a compiler flag manager in CMake. More to come.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment