Skip to content

Commit

Permalink
Adăugat opțiune run_sanitizers in CompilerFlags.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
Duta-Sebastian committed Jan 13, 2025
1 parent 500208c commit ec2bd92
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
3 changes: 2 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ add_executable(${MAIN_EXECUTABLE_NAME}
)

# NOTE: Add all defined targets (e.g. executables, libraries, etc. )
set_compiler_flags(TARGET_NAMES ${MAIN_EXECUTABLE_NAME})
# NOTE: RUN_SANITIZERS is optional, if it's not present it will default to true
set_compiler_flags(RUN_SANITIZERS TRUE TARGET_NAMES ${MAIN_EXECUTABLE_NAME})
# set_compiler_flags(TARGET_NAMES ${MAIN_EXECUTABLE_NAME} ${FOO} ${BAR})
# where ${FOO} and ${BAR} represent additional executables or libraries
# you want to compile with the set compiler flags
Expand Down
12 changes: 10 additions & 2 deletions cmake/CompilerFlags.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ include(cmake/CustomStdlibAndSanitizers.cmake)

function(set_compiler_flags)
set(multiValueArgs TARGET_NAMES)
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "" "${multiValueArgs}")
set(oneValueArgs RUN_SANITIZERS)
cmake_parse_arguments(PARSE_ARGV 0 ARG "" "${oneValueArgs}" "${multiValueArgs}")

if(NOT DEFINED ARG_RUN_SANITIZERS)
set(ARG_RUN_SANITIZERS TRUE)
endif()

# iterate over all specified targets
foreach (TARGET_NAME IN LISTS ARG_TARGET_NAMES)
Expand All @@ -30,6 +35,9 @@ function(set_compiler_flags)
###############################################################################

# sanitizers
set_custom_stdlib_and_sanitizers(${TARGET_NAME} true)
if("${ARG_RUN_SANITIZERS}" STREQUAL "TRUE")
set_custom_stdlib_and_sanitizers(${TARGET_NAME} true)
endif ()

endforeach ()
endfunction()

0 comments on commit ec2bd92

Please sign in to comment.