Add elfio_fuzzer to tests' compilation

This commit is contained in:
Serge Lamikhov-Center 2022-06-21 09:49:46 +03:00
parent 9d6984a59b
commit ef2fa127c0

View File

@ -1,8 +1,8 @@
include(FetchContent)
FetchContent_Declare(
googletest
URL https://github.com/google/googletest/archive/9a32aee22d771387c494be2d8519fbdf46a713b2.zip
googletest
URL https://github.com/google/googletest/archive/9a32aee22d771387c494be2d8519fbdf46a713b2.zip
)
# For Windows: Prevent overriding the parent project's compiler/linker settings
@ -21,7 +21,7 @@ file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/elf_examples)
# Second, glob all files under elf_examples
file(GLOB elf_examples
LIST_DIRECTORIES
false
false
CONFIGURE_DEPENDS
elf_examples/*)
@ -43,16 +43,35 @@ add_executable(
target_link_libraries(
ELFIOTest
PRIVATE
elfio::elfio
gtest_main)
elfio::elfio
gtest_main)
add_test(
NAME
ELFIOTest
ELFIOTest
COMMAND
${CMAKE_CURRENT_BINARY_DIR}/ELFIOTest
${CMAKE_CURRENT_BINARY_DIR}/ELFIOTest
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR})
${CMAKE_CURRENT_BINARY_DIR})
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_executable(
elfio_fuzzer
elfio_fuzzer.cpp)
target_link_libraries(
elfio_fuzzer
PRIVATE
elfio::elfio)
target_compile_options(elfio_fuzzer
PRIVATE $<$<C_COMPILER_ID:Clang>:-g -O1 -fsanitize=fuzzer>
)
target_link_libraries(elfio_fuzzer
PRIVATE $<$<C_COMPILER_ID:Clang>:-fsanitize=fuzzer>
)
endif()
add_dependencies(check ELFIOTest)