| 1 |
# SPDX-FileCopyrightText: 2025 Azhar Momin <[email protected]> |
| 2 |
# SPDX-License-Identifier: BSD-2-Clause |
| 3 |
|
| 4 |
if(DEFINED ENV{LIB_FUZZING_ENGINE}) |
| 5 |
set(fuzzing_engine $ENV{LIB_FUZZING_ENGINE}) |
| 6 |
else() |
| 7 |
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang") |
| 8 |
set(fuzzing_engine -fsanitize=fuzzer) |
| 9 |
else() |
| 10 |
message(FATAL_ERROR "Fuzzing engine not supported") |
| 11 |
endif() |
| 12 |
endif() |
| 13 |
|
| 14 |
function(add_thumbnail_fuzzer creator creator_header target_lib) |
| 15 |
set(gen_src ${CMAKE_CURRENT_BINARY_DIR}/${target_lib}_fuzzer.cc) |
| 16 |
set(CREATOR "${creator}") |
| 17 |
set(CREATOR_HEADER "${creator_header}") |
| 18 |
configure_file( |
| 19 |
${CMAKE_CURRENT_SOURCE_DIR}/kde_thumbnailers_fuzzer.cc.in |
| 20 |
${gen_src} |
| 21 |
@ONLY |
| 22 |
) |
| 23 |
|
| 24 |
add_executable(${target_lib}_fuzzer |
| 25 |
${gen_src} |
| 26 |
) |
| 27 |
|
| 28 |
kcoreaddons_target_static_plugins(${target_lib}_fuzzer |
| 29 |
LINK_OPTION PRIVATE |
| 30 |
TARGETS ${target_lib} |
| 31 |
) |
| 32 |
|
| 33 |
target_link_libraries(${target_lib}_fuzzer |
| 34 |
PRIVATE |
| 35 |
${fuzzing_engine} |
| 36 |
) |
| 37 |
|
| 38 |
if(FUZZERS_USE_QT_MINIMAL_INTEGRATION_PLUGIN) |
| 39 |
qt_import_plugins(${target_lib}_fuzzer INCLUDE Qt::QMinimalIntegrationPlugin) |
| 40 |
endif() |
| 41 |
|
| 42 |
set_target_properties(${target_lib}_fuzzer PROPERTIES |
| 43 |
RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin/fuzzers |
| 44 |
) |
| 45 |
endfunction() |
| 46 |
|
| 47 |
if(GETTEXTPO_FOUND) |
| 48 |
add_thumbnail_fuzzer(PoCreator pocreator.h pothumbnail) |
| 49 |
endif() |