File tree Expand file tree Collapse file tree 4 files changed +11
-11
lines changed
Expand file tree Collapse file tree 4 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -31,9 +31,7 @@ target_link_libraries(${PROJECT_NAME}
3131 PRIVATE arithmetic
3232)
3333
34- if (TARGET sanitizers)
35- target_link_libraries (${PROJECT_NAME} PRIVATE sanitizers)
36- endif ()
34+ target_link_with_sanitizers(${PROJECT_NAME} )
3735
3836# === Unit Testing ===
3937option (ENABLE_TESTING "Build tests" ON )
Original file line number Diff line number Diff line change @@ -11,5 +11,12 @@ if(CMAKE_BUILD_TYPE STREQUAL "Sanitize")
1111 target_compile_options (sanitizers INTERFACE ${SANITIZER_FLAGS} )
1212 target_link_options (sanitizers INTERFACE ${SANITIZER_FLAGS} )
1313
14- message (STATUS "Sanitize build: enabled with flags: ${SANITIZER_FLAGS} " )
14+ message (STATUS "✅ Sanitize build: enabled with flags: ${SANITIZER_FLAGS} " )
1515endif ()
16+
17+ function (target_link_with_sanitizers target )
18+ if (TARGET sanitizers)
19+ message (STATUS "✅ Enabled sanitizers for target ${target} " )
20+ target_link_libraries (${target} PRIVATE sanitizers)
21+ endif ()
22+ endfunction ()
Original file line number Diff line number Diff line change @@ -6,6 +6,4 @@ target_include_directories(arithmetic
66 PUBLIC ${PROJECT_SOURCE_DIR} /include
77)
88
9- if (TARGET sanitizers)
10- target_link_libraries (arithmetic PUBLIC sanitizers)
11- endif ()
9+ target_link_with_sanitizers(arithmetic)
Original file line number Diff line number Diff line change @@ -22,10 +22,7 @@ target_link_libraries(unit_tests
2222 PRIVATE gtest_main arithmetic
2323)
2424
25- if (TARGET sanitizers)
26- message (STATUS "✅ Enabled sanitizers for unit tests" )
27- target_link_libraries (unit_tests PRIVATE sanitizers)
28- endif ()
25+ target_link_with_sanitizers(unit_tests)
2926
3027# Automatically discover and register all test cases
3128include (GoogleTest)
You can’t perform that action at this time.
0 commit comments