Skip to content

Commit 3648daf

Browse files
committed
feat(initcpp.sh): add conditional enabling of sanitizers based on build type
refactor(initcpp.sh): move sanitizers option setting to after build type check
1 parent 5e0fbdb commit 3648daf

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

initcpp.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,8 +302,14 @@ set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
302302
set(CMAKE_CXX_EXTENSIONS ${ENABLE_CXX_EXTENSIONS})
303303
set(CMAKE_C_EXTENSIONS ${ENABLE_C_EXTENSIONS})
304304
305+
if ("\${CMAKE_BUILD_TYPE}" STREQUAL "Debug")
306+
set(SHOULD_ENABLE_SANITIZERS ON)
307+
else()
308+
set(SHOULD_ENABLE_SANITIZERS OFF)
309+
endif()
310+
305311
option(ENABLE_TESTS "Enable tests" ON)
306-
option(ENABLE_SANITIZERS "Enable sanitizers" ON)
312+
option(ENABLE_SANITIZERS "Enable sanitizers" \${SHOULD_ENABLE_SANITIZERS})
307313
308314
if (\${CMAKE_CXX_COMPILER_ID} STREQUAL "GNU")
309315
message(STATUS "Setting G++ flags")

0 commit comments

Comments
 (0)