@@ -38,33 +38,36 @@ INCLUDE(EnableWarnings)
3838
3939# Build options
4040#
41- OPTION ( SONAME "Set the (SO)VERSION of the target" ON )
42- OPTION ( BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON )
43- OPTION ( THREADSAFE "Build libgit2 as threadsafe" ON )
44- OPTION ( BUILD_CLAR "Build Tests using the Clar suite" ON )
45- OPTION ( BUILD_EXAMPLES "Build library usage example apps" OFF )
46- OPTION ( TAGS "Generate tags" OFF )
47- OPTION ( PROFILE "Generate profiling information" OFF )
48- OPTION ( ENABLE_TRACE "Enables tracing support" OFF )
49- OPTION ( LIBGIT2_FILENAME "Name of the produced binary" OFF )
50-
51- SET (SHA1_BACKEND "CollisionDetection" CACHE STRING "Backend to use for SHA1. One of Generic, OpenSSL, Win32, CommonCrypto, mbedTLS, CollisionDetection. " )
52- OPTION ( USE_SSH "Link with libssh to enable SSH support" ON )
53- OPTION ( USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON )
54- OPTION ( USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
55- OPTION ( VALGRIND "Configure build for valgrind" OFF )
56- OPTION ( CURL "Use curl for HTTP if available" ON )
57- OPTION ( USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON )
58- OPTION ( DEBUG_POOL "Enable debug pool allocator" OFF )
59- OPTION ( ENABLE_WERROR "Enable compilation with -Werror" OFF )
60- OPTION ( USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )
41+ OPTION (SONAME "Set the (SO)VERSION of the target" ON )
42+ OPTION (BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON )
43+ OPTION (THREADSAFE "Build libgit2 as threadsafe" ON )
44+ OPTION (BUILD_CLAR "Build Tests using the Clar suite" ON )
45+ OPTION (BUILD_EXAMPLES "Build library usage example apps" OFF )
46+ OPTION (BUILD_FUZZERS "Build the fuzz targets" OFF )
47+ OPTION (TAGS "Generate tags" OFF )
48+ OPTION (PROFILE "Generate profiling information" OFF )
49+ OPTION (ENABLE_TRACE "Enables tracing support" OFF )
50+ OPTION (LIBGIT2_FILENAME "Name of the produced binary" OFF )
51+
52+ SET (SHA1_BACKEND "CollisionDetection" CACHE STRING
53+ "Backend to use for SHA1. One of Generic, OpenSSL, Win32, CommonCrypto, mbedTLS, CollisionDetection." )
54+ OPTION (USE_SSH "Link with libssh to enable SSH support" ON )
55+ OPTION (USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON )
56+ OPTION (USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF )
57+ OPTION (USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF )
58+ OPTION (VALGRIND "Configure build for valgrind" OFF )
59+ OPTION (CURL "Use curl for HTTP if available" ON )
60+ OPTION (USE_EXT_HTTP_PARSER "Use system HTTP_Parser if available" ON )
61+ OPTION (DEBUG_POOL "Enable debug pool allocator" OFF )
62+ OPTION (ENABLE_WERROR "Enable compilation with -Werror" OFF )
63+ OPTION (USE_BUNDLED_ZLIB "Use the bundled version of zlib" OFF )
6164
6265IF (UNIX AND NOT APPLE )
63- OPTION ( ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
66+ OPTION (ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF )
6467ENDIF ()
6568
6669IF (APPLE )
67- OPTION ( USE_ICONV "Link with and use iconv library" ON )
70+ OPTION (USE_ICONV "Link with and use iconv library" ON )
6871ENDIF ()
6972
7073IF (MSVC )
@@ -74,27 +77,27 @@ IF(MSVC)
7477 #
7578 # If you are writing a CLR program and want to link to libgit2, you'll want
7679 # to turn this on by invoking CMake with the "-DSTDCALL=ON" argument.
77- OPTION ( STDCALL "Build libgit2 with the __stdcall convention" OFF )
80+ OPTION (STDCALL "Build libgit2 with the __stdcall convention" OFF )
7881
7982 # This option must match the settings used in your program, in particular if you
8083 # are linking statically
81- OPTION ( STATIC_CRT "Link the static CRT libraries" ON )
84+ OPTION (STATIC_CRT "Link the static CRT libraries" ON )
8285
8386 # If you want to embed a copy of libssh2 into libgit2, pass a
8487 # path to libssh2
85- OPTION ( EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF )
88+ OPTION (EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF )
8689ENDIF ()
8790
8891
8992IF (WIN32 )
9093 # By default, libgit2 is built with WinHTTP. To use the built-in
9194 # HTTP transport, invoke CMake with the "-DWINHTTP=OFF" argument.
92- OPTION ( WINHTTP "Use Win32 WinHTTP routines" ON )
95+ OPTION (WINHTTP "Use Win32 WinHTTP routines" ON )
9396ENDIF ()
9497
9598IF (MSVC )
9699 # Enable MSVC CRTDBG memory leak reporting when in debug mode.
97- OPTION (MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF )
100+ OPTION (MSVC_CRTDBG "Enable CRTDBG memory leak reporting" OFF )
98101ENDIF ()
99102
100103FILE (STRINGS "${libgit2_SOURCE_DIR} /include/git2/version.h" GIT2_HEADER REGEX "^#define LIBGIT2_VERSION \" [^\" ]*\" $" )
@@ -245,6 +248,14 @@ ELSE()
245248 # that uses CMAKE_CONFIGURATION_TYPES and not CMAKE_BUILD_TYPE
246249ENDIF ()
247250
251+ IF (BUILD_FUZZERS AND NOT USE_STANDALONE_FUZZERS)
252+ # The actual sanitizer link target will be added when linking the fuzz
253+ # targets.
254+ SET (CMAKE_REQUIRED_FLAGS "-fsanitize=fuzzer-no-link" )
255+ ADD_C_FLAG(-fsanitize=fuzzer-no -link)
256+ UNSET (CMAKE_REQUIRED_FLAGS)
257+ ENDIF ()
258+
248259ADD_SUBDIRECTORY (src)
249260
250261# Tests
@@ -282,6 +293,18 @@ IF (BUILD_EXAMPLES)
282293 ADD_SUBDIRECTORY (examples)
283294ENDIF ()
284295
296+ IF (BUILD_FUZZERS)
297+ IF (NOT USE_STANDALONE_FUZZERS)
298+ IF (BUILD_EXAMPLES)
299+ MESSAGE (FATAL_ERROR "Cannot build the fuzzer targets and the examples together" )
300+ ENDIF ()
301+ IF (BUILD_CLAR)
302+ MESSAGE (FATAL_ERROR "Cannot build the fuzzer targets and the tests together" )
303+ ENDIF ()
304+ ENDIF ()
305+ ADD_SUBDIRECTORY (fuzzers)
306+ ENDIF ()
307+
285308IF (CMAKE_VERSION VERSION_GREATER 3)
286309 FEATURE_SUMMARY(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:" )
287310 FEATURE_SUMMARY(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:" )
0 commit comments