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