Skip to content

Commit

Permalink
cmake: Add an Address Sanitizer option
Browse files Browse the repository at this point in the history
UBSAN has a link error.
  • Loading branch information
iamsergio committed Dec 2, 2024
1 parent 08aa052 commit 4bb9cc9
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@
# Alternative install path for Python bindings.
# Default=CMAKE_INSTALL_PREFIX
#
# -DKDChart_ENABLE_SANITIZERS=[true|false]
# Builds with ASAN and UBSAN support.
# Default=false

cmake_minimum_required(VERSION 3.12)

Expand Down Expand Up @@ -81,6 +84,7 @@ option(${PROJECT_NAME}_TESTS "Build the tests" OFF)
option(${PROJECT_NAME}_EXAMPLES "Build the examples" ON)
option(${PROJECT_NAME}_DOCS "Build the API documentation" OFF)
option(${PROJECT_NAME}_PYTHON_BINDINGS "Build python bindings" OFF)
option(${PROJECT_NAME}_ENABLE_SANITIZERS "Build with Address Sanitizer" OFF)

list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/ECM/modules")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/KDAB/modules")
Expand All @@ -107,6 +111,11 @@ if(NOT CMAKE_BUILD_TYPE AND NOT CMAKE_CONFIGURATION_TYPES)
)
endif()

if (${PROJECT_NAME}_ENABLE_SANITIZERS)
add_compile_options(-fsanitize=address)
add_link_options(-fsanitize=address)
endif()

if(${PROJECT_NAME}_QT6)
set(QT_VERSION_MAJOR 6)
set(QT_MIN_VERSION "6.0.0")
Expand Down

0 comments on commit 4bb9cc9

Please sign in to comment.