set default build type, add sanitizer build support

This commit is contained in:
Lukas Böger 2021-05-31 09:00:49 +01:00
parent e9391c93fb
commit d7c28021c8

View file

@ -16,10 +16,16 @@ project(chibi-scheme LANGUAGES C VERSION ${version}
include(CheckIncludeFile) include(CheckIncludeFile)
include(CheckSymbolExists) include(CheckSymbolExists)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
SET(CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
"Build type: None, Debug, Release, RelWithDebInfo, MinSizeRel, or Sanitizer." FORCE)
if (NOT EXISTS ${CMAKE_BINARY_DIR}/CMakeCache.txt AND NOT CMAKE_BUILD_TYPE)
# CMake doesn't have a default build type, so set one manually
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING "" FORCE)
endif() endif()
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
# #
# Features # Features
@ -86,6 +92,12 @@ if(NOT HAVE_POLL_H)
target_compile_definitions(libchibi-common INTERFACE SEXP_USE_GREEN_THREADS=0) target_compile_definitions(libchibi-common INTERFACE SEXP_USE_GREEN_THREADS=0)
endif() endif()
target_compile_options(libchibi-common
INTERFACE
$<$<CONFIG:SANITIZER>:-g
-fsanitize=address,undefined,integer-divide-by-zero,float-divide-by-zero,float-cast-overflow,return
-fno-omit-frame-pointer>)
# #
# Sources # Sources
# #