]> git.proxmox.com Git - libgit2.git/blob - CMakeLists.txt
Update changelog for 1.5.0+ds-4 release
[libgit2.git] / CMakeLists.txt
1 # libgit2: the cross-platform, linkable library implementation of git.
2 # See `README.md` for build instructions.
3 #
4 # This top-level CMakeLists.txt sets up configuration options and
5 # determines which subprojects to build.
6
7 cmake_minimum_required(VERSION 3.5.1)
8
9 project(libgit2 VERSION "1.5.0" LANGUAGES C)
10
11 # Add find modules to the path
12 set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake")
13
14 #
15 # Build options
16 #
17
18 # Optional subsystems
19 option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON)
20 option(BUILD_TESTS "Build Tests using the Clar suite" ON)
21 option(BUILD_CLI "Build the command-line interface" ON)
22 option(BUILD_EXAMPLES "Build library usage example apps" OFF)
23 option(BUILD_FUZZERS "Build the fuzz targets" OFF)
24
25 # Suggested functionality that may not be available on a per-platform basis
26 option(USE_THREADS "Use threads for parallel processing when possible" ON)
27 option(USE_NSEC "Support nanosecond precision file mtimes and ctimes" ON)
28
29 # Backend selection
30 option(USE_SSH "Link with libssh2 to enable SSH support" OFF)
31 option(USE_HTTPS "Enable HTTPS support. Can be set to a specific backend" ON)
32 option(USE_SHA1 "Enable SHA1. Can be set to CollisionDetection(ON)/HTTPS" ON)
33 option(USE_SHA256 "Enable SHA256. Can be set to HTTPS/Builtin" ON)
34 option(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.")
37 option(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
40 option(USE_LEAK_CHECKER "Run tests with leak checker" OFF)
41 option(USE_STANDALONE_FUZZERS "Enable standalone fuzzers (compatible with gcc)" OFF)
42 option(DEBUG_POOL "Enable debug pool allocator" OFF)
43 option(DEBUG_STRICT_ALLOC "Enable strict allocator behavior" OFF)
44 option(DEBUG_STRICT_OPEN "Enable path validation in open" OFF)
45
46 # Output options
47 option(SONAME "Set the (SO)VERSION of the target" ON)
48 set(LIBGIT2_FILENAME "git2" CACHE STRING "Name of the produced binary")
49 option(DEPRECATE_HARD "Do not include deprecated functions in the library" OFF)
50
51 # Compilation options
52 option(ENABLE_WERROR "Enable compilation with -Werror" OFF)
53
54 if(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()
61
62 option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF)
63 endif()
64
65 if(APPLE)
66 option(USE_ICONV "Link with and use iconv library" ON)
67 endif()
68
69 if(MSVC)
70 # This option must match the settings used in your program, in particular if you
71 # are linking statically
72 option(STATIC_CRT "Link the static CRT libraries" ON)
73
74 # If you want to embed a copy of libssh2 into libgit2, pass a
75 # path to libssh2
76 option(EMBED_SSH_PATH "Path to libssh2 to embed (Windows)" OFF)
77
78 # Enable leak checking using the debugging C runtime.
79 option(WIN32_LEAKCHECK "Enable leak reporting via crtdbg" OFF)
80 endif()
81
82 if(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)
86 endif()
87
88 if(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)
90 endif()
91
92
93 # Modules
94
95 include(CheckLibraryExists)
96 include(CheckFunctionExists)
97 include(CheckSymbolExists)
98 include(CheckStructHasMember)
99 include(CheckPrototypeDefinition)
100 include(AddCFlagIfSupported)
101 include(FindPkgLibraries)
102 include(FindThreads)
103 include(FindStatNsec)
104 include(Findfutimens)
105 include(GNUInstallDirs)
106 include(IdeSplitSources)
107 include(FeatureSummary)
108 include(EnableWarnings)
109 include(DefaultCFlags)
110
111
112 #
113 # Subdirectories
114 #
115
116 add_subdirectory(src)
117
118 if(BUILD_TESTS)
119 enable_testing()
120 add_subdirectory(tests)
121 endif()
122
123 if(BUILD_EXAMPLES)
124 add_subdirectory(examples)
125 endif()
126
127 if(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")
130 endif()
131 add_subdirectory(fuzzers)
132 endif()
133
134
135 # Export for people who use us as a dependency
136
137 if(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)
140 endif()
141
142
143 # Summary
144
145 feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:")
146 feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:")