mirror of
https://github.com/zeek/zeek.git
synced 2025-10-08 01:28:20 +00:00
Fix building fuzz targets on macOS
This commit is contained in:
parent
48153ba12f
commit
c4d41dcfbb
1 changed files with 19 additions and 10 deletions
|
@ -22,16 +22,26 @@ if ( NOT DEFINED ZEEK_FUZZING_ENGINE AND DEFINED ENV{LIB_FUZZING_ENGINE} )
|
|||
endif ()
|
||||
endif ()
|
||||
|
||||
# The bind library is handled a bit hack-ishly since it defaults to linking it
|
||||
# as static library by default on Linux, but at least on one common distro,
|
||||
# that static library wasn't compiled with -fPIC and so not usable in the
|
||||
# shared library we're trying to build. So instead, the fuzzer executable, not
|
||||
# the shared lib, links it.
|
||||
string(REGEX MATCH ".*\\.a$" _have_static_bind_lib "${BIND_LIBRARY}")
|
||||
|
||||
macro(ADD_FUZZ_TARGET _name)
|
||||
set(_fuzz_target zeek-${_name}-fuzzer)
|
||||
set(_fuzz_source ${_name}-fuzzer.cc)
|
||||
|
||||
add_executable(${_fuzz_target} ${_fuzz_source} ${ARGN})
|
||||
|
||||
target_link_libraries(${_fuzz_target}
|
||||
zeek_fuzzer_shared
|
||||
${BIND_LIBRARY}
|
||||
${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||
target_link_libraries(${_fuzz_target} zeek_fuzzer_shared)
|
||||
|
||||
if ( _have_static_bind_lib )
|
||||
target_link_libraries(${_fuzz_target} ${BIND_LIBRARY})
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${_fuzz_target} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS})
|
||||
|
||||
if ( DEFINED ZEEK_FUZZING_ENGINE )
|
||||
target_link_libraries(${_fuzz_target} ${ZEEK_FUZZING_ENGINE})
|
||||
|
@ -55,12 +65,11 @@ add_library(zeek_fuzzer_shared SHARED
|
|||
set(zeek_fuzzer_shared_deps)
|
||||
|
||||
foreach(_dep ${zeekdeps} )
|
||||
# The bind library is handled a bit hack-ishly since it defaults to
|
||||
# linking it as static library by default on Linux, but at least
|
||||
# on one common distro, that static library wasn't compiled with -fPIC
|
||||
# and so not usable in the shared library we're trying to build.
|
||||
# So instead, the fuzzer executable, not the shared lib, links it.
|
||||
if ( NOT "${_dep}" STREQUAL "${BIND_LIBRARY}" )
|
||||
if ( "${_dep}" STREQUAL "${BIND_LIBRARY}" )
|
||||
if ( NOT _have_static_bind_lib )
|
||||
set(zeek_fuzzer_shared_deps ${zeek_fuzzer_shared_deps} ${_dep})
|
||||
endif ()
|
||||
else ()
|
||||
set(zeek_fuzzer_shared_deps ${zeek_fuzzer_shared_deps} ${_dep})
|
||||
endif ()
|
||||
endforeach ()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue