Skip to content

Commit

Permalink
added ASAN_BUILD CMake flag
Browse files Browse the repository at this point in the history
  • Loading branch information
eranif committed Sep 17, 2023
1 parent 674f2ed commit a6b0d0d
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
cmake_minimum_required(VERSION 3.2)
set(ENV{CC} clang)
set(ENV{CXX} clang++)

if(ASAN_BUILD)
set(ENV{CC} clang)
set(ENV{CXX} clang++)
message(STATUS "Using clang toolchain")
endif()

project(tinyjson)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
if(ASAN_BUILD)
# build with ASAN for our all of our targets
message(STATUS "Enabling ASAN checks")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -O0")
set(CMAKE_LINKER_FLAGS_DEBUG "${CMAKE_LINKER_FLAGS_DEBUG} -fno-omit-frame-pointer -fsanitize=address -O0")
endif()
Expand Down

0 comments on commit a6b0d0d

Please sign in to comment.