@@ -2316,37 +2316,18 @@ function(add_swift_host_tool executable)
2316
2316
endif ()
2317
2317
endfunction ()
2318
2318
2319
- macro (add_swift_fuzz_tool executable )
2320
- cmake_parse_arguments (
2321
- ADDSWIFTHOSTTOOL # prefix
2322
- "" # options
2323
- "" # single-value args
2324
- "SWIFT_COMPONENT" # multi-value args
2325
- ${ARGN} )
2326
-
2327
- # Create the executable rule.
2328
- add_swift_executable (${executable} ${ADDSWIFTHOSTTOOL_UNPARSED_ARGUMENTS} )
2329
-
2330
- set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=fuzzer" )
2331
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=fuzzer" )
2332
- set (LINK_FLAGS "${LINK_FLAGS} -fsanitize=fuzzer" )
2333
-
2334
- # And then create the install rule if we are asked to.
2335
- if (ADDSWIFTHOSTTOOL_SWIFT_COMPONENT )
2336
- swift_install_in_component (${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2337
- TARGETS ${executable}
2338
- RUNTIME DESTINATION bin )
2339
-
2340
- swift_is_installing_component (${ADDSWIFTHOSTTOOL_SWIFT_COMPONENT}
2341
- is_installing )
2342
-
2343
- if (NOT is_installing )
2344
- set_property (GLOBAL APPEND PROPERTY SWIFT_BUILDTREE_EXPORTS ${executable} )
2345
- else ()
2346
- set_property (GLOBAL APPEND PROPERTY SWIFT_EXPORTS ${executable} )
2347
- endif ()
2348
- endif ()
2349
- endmacro ()
2319
+ # This declares a swift host tool that links with libfuzzer.
2320
+ function (add_swift_fuzzer_host_tool executable )
2321
+ # First create our target. We do not actually parse the argument since we do
2322
+ # not care about the arguments, we just pass them all through to
2323
+ # add_swift_host_tool.
2324
+ add_swift_host_tool (${executable} ${ARGN} )
2325
+
2326
+ # Then make sure that we pass the -fsanitize=fuzzer flag both on the cflags
2327
+ # and cxx flags line.
2328
+ target_compile_options (${executable} PRIVATE "-fsanitize=fuzzer" )
2329
+ target_link_libraries (${executable} PRIVATE "-fsanitize=fuzzer" )
2330
+ endfunction ()
2350
2331
2351
2332
macro (add_swift_tool_symlink name dest component )
2352
2333
add_llvm_tool_symlink (${name} ${dest} ALWAYS_GENERATE )
0 commit comments