From a48ce734b3beb8c52d30fbc32f42ffd509df253f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sa=C3=BAl=20Ibarra=20Corretg=C3=A9?= Date: Tue, 29 Mar 2022 09:07:36 +0200 Subject: [PATCH] build: add the ability to build with ASAN --- CMakeLists.txt | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 437cc854..899914aa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 3.4) +cmake_minimum_required(VERSION 3.14) project(tjs LANGUAGES C) @@ -42,6 +42,8 @@ macro(cpr_option OPTION_NAME OPTION_TEXT OPTION_DEFAULT) message(STATUS " ${OPTION_NAME}: ${${OPTION_NAME}}") endmacro() +cpr_option(BUILD_WITH_ASAN "If ON, build with the address sanitizer enabled" OFF) + configure_file( ${CMAKE_SOURCE_DIR}/src/js/bundle.js ${CMAKE_CURRENT_BINARY_DIR}/bundle.js @@ -110,3 +112,8 @@ target_link_libraries(tjs qjs uv_a m3 m ${CURL_LIBRARIES}) if(MINGW) target_link_libraries(tjs pthread) endif() + +if (BUILD_WITH_ASAN) + target_compile_options(tjs PRIVATE -fsanitize=address) + target_link_options(tjs PRIVATE -fsanitize=address) +endif()