|
|
@@ -18,9 +18,16 @@ include(compiler_id)
|
|
|
|
|
|
option(FUZZING "Build for Fuzz Testing (local fuzzing and OSS Fuzz)" OFF)
|
|
|
|
|
|
-# If fuzzing is enabled, multiple compile and linking flags must be set.
|
|
|
-# These flags are set according to the compiler kind.
|
|
|
-if(FUZZING)
|
|
|
+# Assume OSS Fuzz if LIB_FUZZING_ENGINE environment variable is set. OSS Fuzz
|
|
|
+# provides its required compiler-specific flags in CXXFLAGS, which are
|
|
|
+# automatically added to CMAKE_CXX_FLAGS. For local fuzzing, multiple compile
|
|
|
+# and linking flags must be set. These flags depend on the compiler version.
|
|
|
+if(FUZZING AND NOT DEFINED ENV{LIB_FUZZING_ENGINE})
|
|
|
+ if(WIN32)
|
|
|
+ # Currently, libFuzzer cannot be built on Windows.
|
|
|
+ message(FATAL_ERROR "Fuzzing is currently not supported on Windows.")
|
|
|
+ endif()
|
|
|
+
|
|
|
# Address sanitizer must be enabled during fuzzing to detect memory errors.
|
|
|
if(NOT WITH_ASAN)
|
|
|
message(FATAL_ERROR "Fuzzing requires WITH_ASAN=ON to detect memory errors.")
|