File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1- # Copyright (C) 2025 Raven Computing
1+ # Copyright (C) 2026 Raven Computing
22#
33# Licensed under the Apache License, Version 2.0 (the "License");
44# you may not use this file except in compliance with the License.
2424# Adds sanitizer support to a given CMake target.
2525#
2626# Appends the appropriate compiler and linker flags to enable sanitizers for
27- # the specified target.
27+ # the specified target. Supported platforms are GNU/Linux and Windows.
28+ # Sanitizers can be used for release build variants but preferably are only
29+ # enabled for debug builds to get the most informative output.
2830#
2931# Arguments:
3032#
@@ -42,10 +44,11 @@ function(add_sanitizers target_name)
4244 "-fno-omit-frame-pointer"
4345 )
4446 set (
45- SAN_LINK_FLAGS
47+ SAN_LINK_FLAGS_LINUX
4648 "-fsanitize=address" "-fsanitize=leak" "-fsanitize=undefined"
4749 )
48- set (SAN_COMPILE_FLAGS_WINDOWS "/fsanitize=address" "/Oy-" )
50+ set (SAN_COMPILE_FLAGS_WINDOWS "/fsanitize=address" "/Oy-" "/Zi" )
51+ set (SAN_LINK_FLAGS_WINDOWS "/INCREMENTAL:NO" )
4952
5053 target_compile_options (
5154 ${target_name}
@@ -56,7 +59,8 @@ function(add_sanitizers target_name)
5659 target_link_options (
5760 ${target_name}
5861 PUBLIC
59- $<$<NOT :$<PLATFORM_ID :Windows >>:${SAN_LINK_FLAGS} >
62+ $<$<PLATFORM_ID :Linux >:${SAN_LINK_FLAGS_LINUX} >
63+ $<$<PLATFORM_ID :Windows >:${SAN_LINK_FLAGS_WINDOWS} >
6064 )
6165
6266endfunction ()
You can’t perform that action at this time.
0 commit comments