Skip to content

Commit 5457c3e

Browse files
committed
Add Analyze Compile Flags
1 parent 48422b2 commit 5457c3e

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

indra/cmake/00-Common.cmake

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,14 @@ if (LINUX)
182182
-lm
183183
)
184184
endif()
185+
186+
if (CMAKE_BUILD_TYPE MATCHES "^RelWithDebInfo(OS)?$")
187+
if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
188+
add_compile_options(--analyze)
189+
elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
190+
add_compile_options(-fanalyzer)
191+
endif ()
192+
endif ()
185193
endif (LINUX)
186194

187195
if (DARWIN)
@@ -203,6 +211,10 @@ if (DARWIN)
203211
# required for clang-15/xcode-15 since our boost package still uses deprecated std::unary_function/binary_function
204212
# see https://developer.apple.com/documentation/xcode-release-notes/xcode-15-release-notes#C++-Standard-Library
205213
add_compile_definitions(_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION)
214+
215+
if (CMAKE_BUILD_TYPE MATCHES "^RelWithDebInfo(OS)?$")
216+
add_compile_options(--analyze)
217+
endif ()
206218
endif(DARWIN)
207219

208220
if(LINUX OR DARWIN)
@@ -218,4 +230,8 @@ if(LINUX OR DARWIN)
218230

219231
add_compile_options(${GCC_WARNINGS})
220232
add_compile_options(-m${ADDRESS_SIZE})
233+
234+
if (CMAKE_BUILD_TYPE MATCHES "^RelWithDebInfo(OS)?$")
235+
add_compile_options(-fno-omit-frame-pointer -fsanitize=undefined -fsanitize=bounds)
236+
endif ()
221237
endif (LINUX OR DARWIN)

0 commit comments

Comments
 (0)