onnxruntime

Форк
0
/
onnxruntime_fuzz_test.cmake 
65 строк · 2.9 Кб
1
# Copyright (c) Microsoft Corporation. All rights reserved.
2
# Licensed under the MIT License.
3

4
# Check that the options are properly set for
5
# the fuzzing project
6
if (onnxruntime_FUZZ_ENABLED)
7
	message(STATUS "Building dependency protobuf-mutator and libfuzzer")
8
	
9
	# set the options used to control the protobuf-mutator build
10
	set(PROTOBUF_LIBRARIES ${PROTOBUF_LIB})
11
	set(LIB_PROTO_MUTATOR_TESTING OFF)
12
	
13
	# include the protobuf-mutator CMakeLists.txt rather than the projects CMakeLists.txt to avoid target clashes
14
	# with google test
15
	add_subdirectory("external/libprotobuf-mutator/src")
16
	
17
	# add the appropriate include directory and compilation flags
18
	# needed by the protobuf-mutator target and the libfuzzer
19
	set(PROTOBUF_MUT_INCLUDE_DIRS "external/libprotobuf-mutator")
20
	onnxruntime_add_include_to_target(protobuf-mutator ${PROTOBUF_LIB})
21
	onnxruntime_add_include_to_target(protobuf-mutator-libfuzzer ${PROTOBUF_LIB})
22
	target_include_directories(protobuf-mutator PRIVATE ${INCLUDE_DIRECTORIES} ${PROTOBUF_MUT_INCLUDE_DIRS})
23
	target_include_directories(protobuf-mutator-libfuzzer PRIVATE ${INCLUDE_DIRECTORIES} ${PROTOBUF_MUT_INCLUDE_DIRS})
24
	target_compile_options(protobuf-mutator PRIVATE "/wd4244" "/wd4245" "/wd4267" "/wd4100" "/wd4456")
25
	target_compile_options(protobuf-mutator-libfuzzer PRIVATE "/wd4146" "/wd4267")
26
	
27
	# add Fuzzing Engine Build Configuration 
28
	message(STATUS "Building Fuzzing engine")
29
	
30
	# set Fuzz root directory
31
	set(SEC_FUZZ_ROOT ${TEST_SRC_DIR}/fuzzing)
32
	
33
	# Security fuzzing engine src file reference 
34
	set(SEC_FUZ_SRC "${SEC_FUZZ_ROOT}/src/BetaDistribution.cpp" 
35
					"${SEC_FUZZ_ROOT}/src/OnnxPrediction.cpp" 
36
					"${SEC_FUZZ_ROOT}/src/testlog.cpp" 
37
					"${SEC_FUZZ_ROOT}/src/test.cpp")
38
					
39
	# compile the executables
40
	onnxruntime_add_executable(onnxruntime_security_fuzz ${SEC_FUZ_SRC})
41
	
42
	# compile with c++17
43
	target_compile_features(onnxruntime_security_fuzz PUBLIC cxx_std_17)
44
	
45
	# Security fuzzing engine header file reference
46
	onnxruntime_add_include_to_target(onnxruntime_security_fuzz onnx onnxruntime)
47
	
48
	# Assign all include to one variable
49
	set(SEC_FUZ_INC "${SEC_FUZZ_ROOT}/include")
50
	set(INCLUDE_FILES ${SEC_FUZ_INC} "$<TARGET_PROPERTY:protobuf-mutator,INCLUDE_DIRECTORIES>")
51
	
52
	# add all these include directory to the Fuzzing engine
53
	target_include_directories(onnxruntime_security_fuzz PRIVATE ${INCLUDE_FILES})
54
	
55
	# add link libraries the project
56
	target_link_libraries(onnxruntime_security_fuzz onnx_proto onnxruntime protobuf-mutator ${PROTOBUF_LIB})
57
	
58
	# add the dependencies
59
	add_dependencies(onnxruntime_security_fuzz onnx_proto onnxruntime protobuf-mutator ${PROTOBUF_LIB})
60
	
61
	# copy the dlls to the execution directory
62
	add_custom_command(TARGET onnxruntime_security_fuzz POST_BUILD
63
		COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:onnxruntime>  $<TARGET_FILE_DIR:onnxruntime_security_fuzz>
64
		COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:${PROTOBUF_LIB}>  $<TARGET_FILE_DIR:onnxruntime_security_fuzz>)
65
endif()

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.