]>
Commit | Line | Data |
---|---|---|
ad5611d8 TR |
1 | # The main libgit2 source tree: this CMakeLists.txt identifies platform |
2 | # support and includes the subprojects that make up core libgit2 support. | |
22a2d3d5 | 3 | |
ad5611d8 TR |
4 | # |
5 | # Optional build configuration settings | |
6 | # | |
eae0bfdc | 7 | |
e579e0f7 MB |
8 | if(DEPRECATE_HARD) |
9 | add_definitions(-DGIT_DEPRECATE_HARD) | |
10 | endif() | |
11 | ||
ad5611d8 TR |
12 | if(USE_LEAK_CHECKER STREQUAL "valgrind") |
13 | add_definitions(-DVALGRIND) | |
14 | endif() | |
15 | ||
16 | # | |
17 | # Optional debugging functionality | |
18 | # | |
19 | ||
e579e0f7 MB |
20 | if(DEBUG_POOL) |
21 | set(GIT_DEBUG_POOL 1) | |
22 | endif() | |
23 | add_feature_info(debugpool GIT_DEBUG_POOL "debug pool allocator") | |
24 | ||
25 | if(DEBUG_STRICT_ALLOC) | |
26 | set(GIT_DEBUG_STRICT_ALLOC 1) | |
27 | endif() | |
28 | add_feature_info(debugalloc GIT_DEBUG_STRICT_ALLOC "debug strict allocators") | |
29 | ||
30 | if(DEBUG_STRICT_OPEN) | |
31 | set(GIT_DEBUG_STRICT_OPEN 1) | |
32 | endif() | |
33 | add_feature_info(debugopen GIT_DEBUG_STRICT_OPEN "path validation in open") | |
c25aa7cd | 34 | |
ad5611d8 TR |
35 | # |
36 | # Optional feature enablement | |
37 | # | |
c25aa7cd | 38 | |
ad5611d8 TR |
39 | include(SelectGSSAPI) |
40 | include(SelectHTTPSBackend) | |
41 | include(SelectHashes) | |
42 | include(SelectHTTPParser) | |
43 | include(SelectRegex) | |
44 | include(SelectSSH) | |
45 | include(SelectWinHTTP) | |
46 | include(SelectZlib) | |
22a2d3d5 | 47 | |
ad5611d8 TR |
48 | # |
49 | # Platform support | |
50 | # | |
eae0bfdc | 51 | |
ad5611d8 | 52 | # futimes/futimens |
eae0bfdc | 53 | |
e579e0f7 MB |
54 | if(HAVE_FUTIMENS) |
55 | set(GIT_USE_FUTIMENS 1) | |
56 | endif () | |
57 | add_feature_info(futimens GIT_USE_FUTIMENS "futimens support") | |
eae0bfdc | 58 | |
ad5611d8 TR |
59 | # qsort |
60 | ||
e579e0f7 | 61 | check_prototype_definition(qsort_r |
6c7cee42 | 62 | "void qsort_r(void *base, size_t nmemb, size_t size, void *thunk, int (*compar)(void *, const void *, const void *))" |
e579e0f7 | 63 | "" "stdlib.h" GIT_QSORT_R_BSD) |
6c7cee42 | 64 | |
e579e0f7 | 65 | check_prototype_definition(qsort_r |
6c7cee42 | 66 | "void qsort_r(void *base, size_t nmemb, size_t size, int (*compar)(const void *, const void *, void *), void *arg)" |
e579e0f7 | 67 | "" "stdlib.h" GIT_QSORT_R_GNU) |
eae0bfdc | 68 | |
e579e0f7 MB |
69 | check_function_exists(qsort_s GIT_QSORT_S) |
70 | ||
ad5611d8 TR |
71 | # random / entropy data |
72 | ||
e579e0f7 | 73 | check_function_exists(getentropy GIT_RAND_GETENTROPY) |
ad5611d8 | 74 | check_function_exists(getloadavg GIT_RAND_GETLOADAVG) |
eae0bfdc | 75 | |
ad5611d8 | 76 | # determine architecture of the machine |
eae0bfdc | 77 | |
ad5611d8 TR |
78 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) |
79 | set(GIT_ARCH_64 1) | |
80 | elseif(CMAKE_SIZEOF_VOID_P EQUAL 4) | |
81 | set(GIT_ARCH_32 1) | |
82 | elseif(CMAKE_SIZEOF_VOID_P) | |
83 | message(FATAL_ERROR "Unsupported architecture (pointer size is ${CMAKE_SIZEOF_VOID_P} bytes)") | |
84 | else() | |
85 | message(FATAL_ERROR "Unsupported architecture (CMAKE_SIZEOF_VOID_P is unset)") | |
86 | endif() | |
87 | ||
88 | # nanosecond mtime/ctime support | |
89 | ||
90 | if(USE_NSEC) | |
91 | set(GIT_USE_NSEC 1) | |
e579e0f7 MB |
92 | endif() |
93 | ||
ad5611d8 TR |
94 | # high-resolution stat support |
95 | ||
96 | if(HAVE_STRUCT_STAT_ST_MTIM) | |
97 | set(GIT_USE_STAT_MTIM 1) | |
98 | elseif(HAVE_STRUCT_STAT_ST_MTIMESPEC) | |
99 | set(GIT_USE_STAT_MTIMESPEC 1) | |
100 | elseif(HAVE_STRUCT_STAT_ST_MTIME_NSEC) | |
101 | set(GIT_USE_STAT_MTIME_NSEC 1) | |
102 | endif() | |
103 | ||
104 | # realtime support | |
105 | ||
e579e0f7 MB |
106 | check_library_exists(rt clock_gettime "time.h" NEED_LIBRT) |
107 | if(NEED_LIBRT) | |
108 | list(APPEND LIBGIT2_SYSTEM_LIBS rt) | |
109 | list(APPEND LIBGIT2_PC_LIBS "-lrt") | |
110 | endif() | |
111 | ||
ad5611d8 TR |
112 | # platform libraries |
113 | ||
114 | if(WIN32) | |
115 | list(APPEND LIBGIT2_SYSTEM_LIBS ws2_32) | |
e579e0f7 | 116 | endif() |
eae0bfdc | 117 | |
ad5611d8 TR |
118 | if(CMAKE_SYSTEM_NAME MATCHES "(Solaris|SunOS)") |
119 | list(APPEND LIBGIT2_SYSTEM_LIBS socket nsl) | |
120 | list(APPEND LIBGIT2_PC_LIBS "-lsocket" "-lnsl") | |
121 | endif() | |
eae0bfdc | 122 | |
ad5611d8 TR |
123 | if(CMAKE_SYSTEM_NAME MATCHES "Haiku") |
124 | list(APPEND LIBGIT2_SYSTEM_LIBS gnu network) | |
125 | list(APPEND LIBGIT2_PC_LIBS "-lgnu -lnetwork") | |
126 | endif() | |
22a2d3d5 | 127 | |
ad5611d8 TR |
128 | if(AMIGA) |
129 | add_definitions(-DNO_ADDRINFO -DNO_READDIR_R -DNO_MMAP) | |
22a2d3d5 | 130 | endif() |
eae0bfdc | 131 | |
ad5611d8 | 132 | # threads |
e579e0f7 | 133 | |
ad5611d8 TR |
134 | if(USE_THREADS) |
135 | if(NOT WIN32) | |
136 | find_package(Threads REQUIRED) | |
137 | list(APPEND LIBGIT2_SYSTEM_LIBS ${CMAKE_THREAD_LIBS_INIT}) | |
138 | list(APPEND LIBGIT2_PC_LIBS ${CMAKE_THREAD_LIBS_INIT}) | |
139 | endif() | |
e579e0f7 | 140 | |
ad5611d8 | 141 | set(GIT_THREADS 1) |
e579e0f7 | 142 | endif() |
ad5611d8 TR |
143 | add_feature_info(threadsafe USE_THREADS "threadsafe support") |
144 | ||
145 | # | |
146 | # Optional bundled features | |
147 | # | |
eae0bfdc | 148 | |
ad5611d8 | 149 | # ntlmclient |
e579e0f7 MB |
150 | if(USE_NTLMCLIENT) |
151 | set(GIT_NTLM 1) | |
152 | add_subdirectory("${PROJECT_SOURCE_DIR}/deps/ntlmclient" "${PROJECT_BINARY_DIR}/deps/ntlmclient") | |
153 | list(APPEND LIBGIT2_DEPENDENCY_INCLUDES "${PROJECT_SOURCE_DIR}/deps/ntlmclient") | |
154 | list(APPEND LIBGIT2_DEPENDENCY_OBJECTS "$<TARGET_OBJECTS:ntlmclient>") | |
155 | endif() | |
156 | add_feature_info(ntlmclient GIT_NTLM "NTLM authentication support for Unix") | |
22a2d3d5 | 157 | |
ad5611d8 TR |
158 | # |
159 | # Optional external dependencies | |
22a2d3d5 | 160 | |
ad5611d8 | 161 | # iconv |
e579e0f7 MB |
162 | if(USE_ICONV) |
163 | find_package(Iconv) | |
164 | endif() | |
165 | if(ICONV_FOUND) | |
166 | set(GIT_USE_ICONV 1) | |
167 | list(APPEND LIBGIT2_SYSTEM_INCLUDES ${ICONV_INCLUDE_DIR}) | |
168 | list(APPEND LIBGIT2_SYSTEM_LIBS ${ICONV_LIBRARIES}) | |
169 | list(APPEND LIBGIT2_PC_LIBS ${ICONV_LIBRARIES}) | |
170 | endif() | |
171 | add_feature_info(iconv GIT_USE_ICONV "iconv encoding conversion support") | |
172 | ||
ad5611d8 TR |
173 | # |
174 | # Configure support | |
175 | # | |
e579e0f7 | 176 | |
ad5611d8 | 177 | configure_file(features.h.in git2/sys/features.h) |
22a2d3d5 | 178 | |
ad5611d8 TR |
179 | # |
180 | # Include child projects | |
181 | # | |
22a2d3d5 | 182 | |
ad5611d8 TR |
183 | add_subdirectory(libgit2) |
184 | add_subdirectory(util) | |
eae0bfdc | 185 | |
ad5611d8 TR |
186 | if(BUILD_CLI) |
187 | add_subdirectory(cli) | |
e579e0f7 MB |
188 | endif() |
189 | ||
ad5611d8 TR |
190 | # re-export these to the root so that peer projects (tests, fuzzers, |
191 | # examples) can use them | |
e579e0f7 MB |
192 | set(LIBGIT2_INCLUDES ${LIBGIT2_INCLUDES} PARENT_SCOPE) |
193 | set(LIBGIT2_OBJECTS ${LIBGIT2_OBJECTS} PARENT_SCOPE) | |
194 | set(LIBGIT2_DEPENDENCY_INCLUDES ${LIBGIT2_DEPENDENCY_INCLUDES} PARENT_SCOPE) | |
195 | set(LIBGIT2_DEPENDENCY_OBJECTS ${LIBGIT2_DEPENDENCY_OBJECTS} PARENT_SCOPE) | |
196 | set(LIBGIT2_SYSTEM_INCLUDES ${LIBGIT2_SYSTEM_INCLUDES} PARENT_SCOPE) | |
197 | set(LIBGIT2_SYSTEM_LIBS ${LIBGIT2_SYSTEM_LIBS} PARENT_SCOPE) |