Move C and CXX flags earlier to allow libraries of STK to use sanitizer

This commit is contained in:
Benau 2020-02-28 09:30:00 +08:00
parent fa0da462fb
commit ef1d74b961

View File

@ -83,6 +83,15 @@ if(UNIX AND NOT APPLE)
option(USE_LIBBFD "Use libbfd for crash reporting and leak check" OFF)
endif()
if(USE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()
if(USE_TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
endif()
set(STK_SOURCE_DIR "src")
set(STK_DATA_DIR "${PROJECT_SOURCE_DIR}/data")
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
@ -648,11 +657,9 @@ if(UNIX AND NOT APPLE)
endif()
endif()
if(USE_ASAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
target_link_libraries(supertuxkart "-fsanitize=address")
endif()
if(USE_TSAN)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=thread -fno-omit-frame-pointer")
target_link_libraries(supertuxkart "-fsanitize=thread")
endif()
endif()