]>
Commit | Line | Data |
---|---|---|
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 | 7 | cmake_minimum_required(VERSION 3.5.1) |
22a2d3d5 | 8 | |
ad5611d8 | 9 | project(libgit2 VERSION "1.5.0" LANGUAGES C) |
583cf169 | 10 | |
7a6e0281 | 11 | # Add find modules to the path |
e579e0f7 | 12 | set(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 |
19 | option(BUILD_SHARED_LIBS "Build Shared Library (OFF for Static)" ON) | |
20 | option(BUILD_TESTS "Build Tests using the Clar suite" ON) | |
ad5611d8 | 21 | option(BUILD_CLI "Build the command-line interface" ON) |
e579e0f7 MB |
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) | |
ad5611d8 TR |
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) | |
e579e0f7 MB |
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() | |
ed0571f8 | 61 | |
e579e0f7 MB |
62 | option(ENABLE_REPRODUCIBLE_BUILDS "Enable reproducible builds" OFF) |
63 | endif() | |
73291aff | 64 | |
e579e0f7 MB |
65 | if(APPLE) |
66 | option(USE_ICONV "Link with and use iconv library" ON) | |
67 | endif() | |
82b2fc2c | 68 | |
e579e0f7 | 69 | if(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) |
80 | endif() | |
19be3f9e | 81 | |
e579e0f7 MB |
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) | |
98b8fcff | 110 | |
19be3f9e | 111 | |
e579e0f7 MB |
112 | # |
113 | # Subdirectories | |
114 | # | |
c6cd3f8b | 115 | |
e579e0f7 | 116 | add_subdirectory(src) |
c6cd3f8b | 117 | |
e579e0f7 MB |
118 | if(BUILD_TESTS) |
119 | enable_testing() | |
120 | add_subdirectory(tests) | |
121 | endif() | |
b6a2fd0e | 122 | |
e579e0f7 MB |
123 | if(BUILD_EXAMPLES) |
124 | add_subdirectory(examples) | |
125 | endif() | |
22a2d3d5 | 126 | |
e579e0f7 MB |
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") | |
22a2d3d5 | 130 | endif() |
e579e0f7 MB |
131 | add_subdirectory(fuzzers) |
132 | endif() | |
e632f687 | 133 | |
eae0bfdc | 134 | |
ad5611d8 TR |
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 | ||
e579e0f7 | 143 | # Summary |
ac3d33df | 144 | |
e579e0f7 MB |
145 | feature_summary(WHAT ENABLED_FEATURES DESCRIPTION "Enabled features:") |
146 | feature_summary(WHAT DISABLED_FEATURES DESCRIPTION "Disabled features:") |