From 582061957589be9190fe7e7e1a2afb4f26b45622 Mon Sep 17 00:00:00 2001 From: James Turner Date: Wed, 19 Aug 2020 14:02:45 +0100 Subject: [PATCH] Move ENABLE_ASAN check to global scope Allows ASan with GCC. --- CMakeLists.txt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2fecdc306..9b6f6fc40 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -495,8 +495,11 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Ap set(CMAKE_XCODE_ATTRIBUTE_CLANG_CXX_LIBRARY "libc++") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++") set(WARNING_FLAGS_C "-Wall") +endif() - if (ENABLE_ASAN) +# ASan is enabled in SimGear's configuration, in case you are +# wondering why there is no option() for it above. +if (ENABLE_ASAN) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -fsanitize=address") @@ -504,8 +507,6 @@ if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang" OR CMAKE_CXX_COMPILER_ID STREQUAL "Ap # needed for check_cxx_source_compiles set(CMAKE_REQUIRED_LINK_OPTIONS "-fsanitize=address") - endif() - endif() if(WIN32)