File: EnableSanitize.cmake

package info (click to toggle)
openorienteering-mapper 0.6.7-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 42,556 kB
  • ctags: 8,993
  • sloc: cpp: 84,560; sh: 3,530; ansic: 1,917; java: 145; xml: 135; sed: 43; makefile: 30
file content (39 lines) | stat: -rw-r--r-- 1,343 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#
#    Copyright 2016 Kai Pastor
#    
#    This file is part of OpenOrienteering.
# 
#    OpenOrienteering is free software: you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation, either version 3 of the License, or
#    (at your option) any later version.
# 
#    OpenOrienteering is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
# 
#    You should have received a copy of the GNU General Public License
#    along with OpenOrienteering.  If not, see <http://www.gnu.org/licenses/>.


if(NOT COMMAND check_cxx_compiler_flag)
	include(CheckCXXCompilerFlag)
endif()

macro(enable_sanitize)
	foreach(option ${ARGV})
		if (option STREQUAL "NO_RECOVER")
			set(full_option "-fno-sanitize-recover=all")
		else()
			set(full_option "-fsanitize=${option}")
		endif()
		if(NOT CMAKE_CXX_FLAGS MATCHES "${full_option}")
			string(MAKE_C_IDENTIFIER ${option} option_id)
			check_cxx_compiler_flag("${full_option}" SANITIZE_${option_id})
			if(SANITIZE_${option_id})
				set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${full_option}")
			endif()
		endif()
	endforeach()
endmacro()