1
1
#============================================================================
2
2
# Copyright (C) 2013 - 2018, OpenJK contributors
3
- #
3
+ #
4
4
# This file is part of the OpenJK source code.
5
- #
5
+ #
6
6
# OpenJK is free software; you can redistribute it and/or modify it
7
7
# under the terms of the GNU General Public License version 2 as
8
8
# published by the Free Software Foundation.
9
- #
9
+ #
10
10
# This program is distributed in the hope that it will be useful,
11
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
13
# GNU General Public License for more details.
14
- #
14
+ #
15
15
# You should have received a copy of the GNU General Public License
16
16
# along with this program; if not, see <http://www.gnu.org/licenses/>.
17
17
#============================================================================
@@ -48,6 +48,7 @@ option(BuildJK2SPGame "Whether to create projects for the jk2 sp gamecode mod (j
48
48
option (BuildJK2SPRdVanilla "Whether to create projects for the jk2 sp renderer (rdjosp-vanilla_x86.dll)" OFF )
49
49
50
50
option (BuildTests "Whether to build automatic unit tests (requires Boost)" OFF )
51
+ option (UseSanitizer "Whether to enable runtime sanitizers (e.g. AddressSanitizer)" OFF )
51
52
52
53
include (CMakeDependentOption)
53
54
cmake_dependent_option(BuildSymbolServer "Build WIP Windows Symbol Server (experimental and unused)" OFF "NOT WIN32 OR NOT MSVC" OFF )
@@ -229,6 +230,11 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M
229
230
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
230
231
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
231
232
233
+ if (CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "Debug" AND UseSanitizer)
234
+ add_compile_options (-fsanitize=address)
235
+ add_link_options (-fsanitize=address)
236
+ endif ()
237
+
232
238
# additional flags for debug configuration
233
239
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb" )
234
240
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb" )
@@ -243,7 +249,7 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M
243
249
244
250
# enable somewhat modern C++
245
251
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
246
-
252
+
247
253
if ("${CMAKE_C_COMPILER_ID} " STREQUAL "GNU" )
248
254
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
249
255
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-comment" )
@@ -388,4 +394,4 @@ endif()
388
394
if (BuildTests)
389
395
enable_testing ()
390
396
add_subdirectory ("tests" )
391
- endif ()
397
+ endif ()
0 commit comments