Skip to content

Commit 5a64bc8

Browse files
Tachi107kinetiknz
authored andcommitted
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)
1 parent 5d93d2d commit 5a64bc8

1 file changed

Lines changed: 10 additions & 4 deletions

File tree

CMakeLists.txt

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ option(BUILD_TESTS "Build tests" ON)
1010
option(BUILD_RUST_LIBS "Build rust backends" OFF)
1111
option(BUILD_TOOLS "Build tools" ON)
1212
option(LAZY_LOAD_LIBS "Lazily load shared libraries" ON)
13+
option(USE_SANITIZERS "Use sanitizers" ON)
1314

1415
if(NOT CMAKE_BUILD_TYPE)
1516
set(CMAKE_BUILD_TYPE "RelWithDebInfo" CACHE STRING
@@ -20,12 +21,17 @@ set(CMAKE_C_STANDARD 99)
2021
set(CMAKE_CXX_STANDARD 11)
2122
set(CMAKE_CXX_STANDARD_REQUIRED ON)
2223

23-
if(NOT COMMAND add_sanitizers)
24-
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake")
25-
find_package(Sanitizers)
24+
if(USE_SANITIZERS)
2625
if(NOT COMMAND add_sanitizers)
27-
message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout")
26+
list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake/sanitizers-cmake/cmake")
27+
find_package(Sanitizers)
28+
if(NOT COMMAND add_sanitizers)
29+
message(FATAL_ERROR "Could not find sanitizers-cmake: run\n\tgit submodule update --init --recursive\nin base git checkout")
30+
endif()
2831
endif()
32+
else()
33+
macro(add_sanitizers UNUSED)
34+
endmacro()
2935
endif()
3036

3137
if(BUILD_TESTS)

0 commit comments

Comments
 (0)