Skip to content

Commit

Permalink
Add sanitizers as build options
Browse files Browse the repository at this point in the history
  • Loading branch information
cgmb committed May 31, 2017
1 parent ac24d25 commit 4cff784
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
cmake_minimum_required(VERSION 2.8)
project(euler)
option(OPTIMIZE "Enable platform-specific optimizations")
set(SANITIZER "" CACHE STRING "Enable specified sanitizer")
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
include_directories(.)

Expand All @@ -15,6 +16,10 @@ if(${OPTIMIZE})
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -ffast-math")
endif()

if(NOT ${SANITIZER} STREQUAL "")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=${SANITIZER} -fno-omit-frame-pointer")
endif()

if(CMAKE_BUILD_TYPE STREQUAL "" OR CMAKE_BUILD_TYPE STREQUAL "Debug")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O2")
endif()
Expand Down

0 comments on commit 4cff784

Please sign in to comment.