Skip to content

Commit

Permalink
#1765: only enable sanitizers for vt target
Browse files Browse the repository at this point in the history
  • Loading branch information
cz4rs committed May 5, 2022
1 parent f6f65cc commit b7b5635
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions cmake-modules/SetCXXCompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@ elseif (NOT ${CMAKE_CXX_COMPILER_ID} MATCHES "Intel")
message(FATAL_ERROR "Your C++ compiler may not support C++14.")
endif ()

if (vt_asan_enabled)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
endif()
if ("${vt_target}" STREQUAL "${VIRTUAL_TRANSPORT_LIBRARY}")
if (vt_asan_enabled)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=address -fno-omit-frame-pointer -fno-optimize-sibling-calls)
endif()

if (vt_ubsan_enabled)
add_definitions(-DVT_UBSAN_ENABLED)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer)
if (vt_ubsan_enabled)
add_definitions(-DVT_UBSAN_ENABLED)
list(APPEND TARGET_PUBLIC_CXX_FLAGS -fsanitize=undefined -fno-omit-frame-pointer)
endif()
endif()

message(DEBUG "Target ${vt_target} public compile options: ${TARGET_CXX_FLAGS}")
message(DEBUG "Target ${vt_target} public compile options: ${TARGET_PUBLIC_CXX_FLAGS}")
target_compile_options(${vt_target} PUBLIC ${TARGET_PUBLIC_CXX_FLAGS})

message(DEBUG "Target ${vt_target} private compile options: ${TARGET_CXX_FLAGS}")
message(DEBUG "Target ${vt_target} private compile options: ${TARGET_PRIVATE_CXX_FLAGS}")
target_compile_options(${vt_target} PRIVATE ${TARGET_PRIVATE_CXX_FLAGS})

endmacro()

0 comments on commit b7b5635

Please sign in to comment.