Skip to content

Commit

Permalink
Renamed option to HIDAPI_ENABLE_ASAN and made it a real option
Browse files Browse the repository at this point in the history
HIDAPI_ENABLE_ASAN is no set platform independent
  • Loading branch information
JoergAtGithub committed Oct 13, 2022
1 parent 4d9bda0 commit c244e55
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
10 changes: 7 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,16 @@ if(CMAKE_BUILD_TYPE STREQUAL "Debug")
set(IS_DEBUG_BUILD ON)
endif()

option(HIDAPI_ENABLE_ASAN "Build HIDAPI with ASAN address sanitizer instrumentation" ON)

if(HIDAPI_ENABLE_ASAN)
add_compile_options(-fsanitize=address)
endif()

if(WIN32)
# so far only Windows has tests
set(EnableAsanDump ${IS_DEBUG_BUILD})
option(HIDAPI_WITH_TESTS "Build HIDAPI (unit-)tests" ${IS_DEBUG_BUILD})
else()
set(EnableAsanDump OFF)
else()
set(HIDAPI_WITH_TESTS OFF)
endif()

Expand Down
4 changes: 2 additions & 2 deletions windows/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ set(SOURCES
hidapi_hidsdi.h
)

if(EnableAsanDump)
if(HIDAPI_ENABLE_ASAN)
# Option /MTd needed to embedd ASAN library
add_compile_options(-fsanitize=address /MTd)
add_compile_options(/MTd)
endif()

if(BUILD_SHARED_LIBS)
Expand Down
2 changes: 1 addition & 1 deletion windows/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ foreach(TEST_CASE ${HID_DESCRIPTOR_RECONSTRUCT_TEST_CASES})
COMMAND hid_report_reconstructor_test "${TEST_PP_DATA}" "${TEST_EXPECTED_DESCRIPTOR}"
WORKING_DIRECTORY "$<TARGET_FILE_DIR:hidapi_winapi>"
)
if(EnableAsanDump)
if(HIDAPI_ENABLE_ASAN)
set_property(TEST "WinHidReportReconstructTest_${TEST_CASE}" PROPERTY ENVIRONMENT "ASAN_SAVE_DUMPS=AsanDump_${TEST_CASE}.dmp")
endif()
endforeach()

0 comments on commit c244e55

Please sign in to comment.