Skip to content

Commit 4d2a683

Browse files
committed
cmake: move fuzzer args to the fuzzer's cmake
1 parent 7b527c1 commit 4d2a683

File tree

2 files changed

+5
-15
lines changed

2 files changed

+5
-15
lines changed

CMakeLists.txt

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -113,14 +113,6 @@ else()
113113
# that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
114114
endif()
115115

116-
IF(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
117-
# The actual sanitizer link target will be added when linking the fuzz
118-
# targets.
119-
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
120-
add_c_flag(-fsanitize=fuzzer-no-link)
121-
unset(CMAKE_REQUIRED_FLAGS)
122-
endif()
123-
124116
#
125117
# Subdirectories
126118
#
@@ -137,13 +129,8 @@ if(BUILD_EXAMPLES)
137129
endif()
138130

139131
if(BUILD_FUZZERS)
140-
if(NOT USE_STANDALONE_FUZZERS)
141-
if(BUILD_EXAMPLES)
142-
message(FATAL_ERROR "Cannot build the fuzzer targets and the examples together")
143-
endif()
144-
if(BUILD_TESTS)
145-
message(FATAL_ERROR "Cannot build the fuzzer targets and the tests together")
146-
endif()
132+
if((BUILD_TESTS OR BUILD_EXAMPLES) AND NOT USE_STANDALONE_FUZZERS)
133+
message(FATAL_ERROR "Cannot build the fuzzer and the tests or examples together")
147134
endif()
148135
add_subdirectory(fuzzers)
149136
endif()

fuzzers/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,10 @@ include_directories(${LIBGIT2_INCLUDES})
33
include_directories(SYSTEM ${LIBGIT2_SYSTEM_INCLUDES})
44

55
if(BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
6+
set(CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link")
67
add_c_flag(-fsanitize=fuzzer)
8+
add_c_flag(-fsanitize=fuzzer-no-link)
9+
unset(CMAKE_REQUIRED_FLAGS)
710
endif()
811

912
file(GLOB SRC_FUZZ RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} *_fuzzer.c)

0 commit comments

Comments
 (0)