From 5a64bc898cf1823a46aa1d4aa2dc1830e02c69d2 Mon Sep 17 00:00:00 2001 From: Andrea Pappacoda Date: Sat, 6 Nov 2021 22:56:00 +0100 Subject: build: add USE_SANITIZERS option This is useful to users who can't recursively clone the repo or that simply want to build the project from the downloadable tarball (like Linux distributions, for example) --- CMakeLists.txt | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index be0e3b1..d505bfc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -10,6 +10,7 @@ option(BUILD_TESTS "Build tests" ON) option(BUILD_RUST_LIBS "Build rust backends" OFF) option(BUILD_TOOLS "Build tools" ON) option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON) +option(USE_SANITIZERS "Use sanitizers" ON) if(NOT CMAKE_BUILD_TYPE) set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING @@ -20,12 +21,17 @@ set(CMAKE_C_STANDARD 99) set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) -if(NOT COMMAND add_sanitizers) - list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake") - find_package(Sanitizers) +if(USE_SANITIZERS) if(NOT COMMAND add_sanitizers) - message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout") + list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake") + find_package(Sanitizers) + if(NOT COMMAND add_sanitizers) + message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout") + endif() endif() +else() + macro(add_sanitizers UNUSED) + endmacro() endif() if(BUILD_TESTS) -- cgit v1.2.3