]> git.proxmox.com Git - libgit2.git/blame - CMakeLists.txt
Apply M-A hint to libgit2-fixtures
[libgit2.git] / CMakeLists.txt
CommitLineData
ad5611d8 1# libgit2: the cross-platform, linkable library implementation of git.
e579e0f7 2# See `README.md` for build instructions.
ad5611d8
TR
3#
4# This top-level CMakeLists.txt sets up configuration options and
5# determines which subprojects to build.
73c46d53 6
e579e0f7 7cmake_minimum_required(VERSION 3.5.1)
22a2d3d5 8
ad5611d8 9project(libgit2 VERSION "1.5.0" LANGUAGES C)
583cf169 10
7a6e0281 11# Add find modules to the path
e579e0f7 12set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
5bda607c 13
e579e0f7 14#
19a766a2
SC
15# Build options
16#
22a2d3d5 17
e579e0f7
MB
18# Optional subsystems
19option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
20option(BUILD_TESTS "Build Tests using the Clar suite" ON)
ad5611d8 21option(BUILD_CLI "Build the command-line interface" ON)
e579e0f7
MB
22option(BUILD_EXAMPLES "Build library usage example apps" OFF)
23option(BUILD_FUZZERS "Build the fuzz targets" OFF)
24
25# Suggested functionality that may not be available on a per-platform basis
26option(USE_THREADS "Use threads for parallel processing when possible" ON)
27option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
28
29# Backend selection
30option(USE_SSH "Link with libssh2 to enable SSH support" OFF)
31option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
ad5611d8
TR
32option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
33option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
e579e0f7
MB
34option(USE_GSSAPI "Link with libgssapi for SPNEGO auth" OFF)
35 set(USE_HTTP_PARSER "" CACHE STRING "Specifies the HTTP Parser implementation; either system or builtin.")
36 set(REGEX_BACKEND "" CACHE STRING "Regular expression implementation. One of regcomp_l, pcre2, pcre, regcomp, or builtin.")
37option(USE_BUNDLED_ZLIB "Use the bundled version of zlib. Can be set to one of Bundled(ON)/Chromium. The Chromium option requires a x86_64 processor with SSE4.2 and CLMUL" OFF)
38
39# Debugging options
40option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
41option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
42option(DEBUG_POOL "Enable debug pool allocator" OFF)
43option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
44option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
45
46# Output options
47option(SONAME "Set the (SO)VERSION of the target" ON)
48 set(LIBGIT2_FILENAME "git2" CACHE STRING "Name of the produced binary")
49option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
50
51# Compilation options
52option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
53
54if(UNIX)
55 # NTLM client requires crypto libraries from the system HTTPS stack
56 if(NOT USE_HTTPS)
57 option(USE_NTLMCLIENT "Enable NTLM support on Unix." OFF)
58 else()
59 option(USE_NTLMCLIENT "Enable NTLM support on Unix." ON)
60 endif()
ed0571f8 61
e579e0f7
MB
62 option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
63endif()
73291aff 64
e579e0f7
MB
65if(APPLE)
66 option(USE_ICONV "Link with and use iconv library" ON)
67endif()
82b2fc2c 68
e579e0f7 69if(MSVC)
08f32085
Q
70 # This option must match the settings used in your program, in particular if you
71 # are linking statically
e579e0f7 72 option(STATIC_CRT "Link the static CRT libraries" ON)
1bfe7133 73
01fe8374
CMN
74 # If you want to embed a copy of libssh2 into libgit2, pass a
75 # path to libssh2
e579e0f7 76 option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
8f426d7d 77
c25aa7cd 78 # Enable leak checking using the debugging C runtime.
e579e0f7
MB
79 option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
80endif()
19be3f9e 81
e579e0f7
MB
82if(WIN32)
83 # By default, libgit2 is built with WinHTTP. To use the built-in
84 # HTTP transport, invoke CMake with the "-DUSE_WINHTTP=OFF" argument.
85 option(USE_WINHTTP "Use Win32 WinHTTP routines" ON)
86endif()
87
88if(NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
89 set(CMAKE_BUILD_TYPE "Debug" CACHE STRING "Choose the type of build, options are: Debug Release RelWithDebInfo MinSizeRel." FORCE)
90endif()
91
92
93# Modules
94
95include(CheckLibraryExists)
96include(CheckFunctionExists)
97include(CheckSymbolExists)
98include(CheckStructHasMember)
99include(CheckPrototypeDefinition)
100include(AddCFlagIfSupported)
101include(FindPkgLibraries)
102include(FindThreads)
103include(FindStatNsec)
104include(Findfutimens)
105include(GNUInstallDirs)
106include(IdeSplitSources)
107include(FeatureSummary)
108include(EnableWarnings)
109include(DefaultCFlags)
98b8fcff 110
19be3f9e 111
e579e0f7
MB
112#
113# Subdirectories
114#
c6cd3f8b 115
e579e0f7 116add_subdirectory(src)
c6cd3f8b 117
e579e0f7
MB
118if(BUILD_TESTS)
119 enable_testing()
120 add_subdirectory(tests)
121endif()
b6a2fd0e 122
e579e0f7
MB
123if(BUILD_EXAMPLES)
124 add_subdirectory(examples)
125endif()
22a2d3d5 126
e579e0f7
MB
127if(BUILD_FUZZERS)
128 if((BUILD_TESTS OR BUILD_EXAMPLES) AND NOT USE_STANDALONE_FUZZERS)
129 message(FATAL_ERROR "Cannot build the fuzzer and the tests or examples together")
22a2d3d5 130 endif()
e579e0f7
MB
131 add_subdirectory(fuzzers)
132endif()
e632f687 133
eae0bfdc 134
ad5611d8
TR
135# Export for people who use us as a dependency
136
137if(NOT "${CMAKE_CURRENT_SOURCE_DIR}" STREQUAL "${CMAKE_SOURCE_DIR}")
138 set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE)
139 set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE)
140endif()
141
142
e579e0f7 143# Summary
ac3d33df 144
e579e0f7
MB
145feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
146feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")