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 )
@@ -232,6 +233,11 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M
232
233
set (CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "" )
233
234
set (CMAKE_SHARED_LIBRARY_LINK_CXX_FLAGS "" )
234
235
236
+ if (CMAKE_BUILD_TYPE MATCHES "DEBUG" OR CMAKE_BUILD_TYPE MATCHES "Debug" AND UseSanitizer)
237
+ add_compile_options (-fsanitize=address)
238
+ add_link_options (-fsanitize=address)
239
+ endif ()
240
+
235
241
# additional flags for debug configuration
236
242
set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -ggdb" )
237
243
set (CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -ggdb" )
@@ -246,7 +252,7 @@ elseif (("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") OR ("${CMAKE_C_COMPILER_ID}" M
246
252
247
253
# enable somewhat modern C++
248
254
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11" )
249
-
255
+
250
256
if ("${CMAKE_C_COMPILER_ID} " STREQUAL "GNU" )
251
257
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall" )
252
258
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-comment" )
0 commit comments