1
+#
2
+# Copyright (c) 2020 Sibi Siddharthan
3
+#
4
+
5
+#[[
6
+
7
+Instructions to run CMake:
8
+
9
+cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
10
+Eg.
11
+From the root of git source tree
12
+ `cmake contrib/buildsystems/ `
13
+This will build the git binaries at the root
14
+
15
+For out of source builds, say build in 'git/git-build/'
16
+ `mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
17
+This will build the git binaries in git-build directory
18
+
19
+Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
20
+compiler flags
21
+Debug : -g
22
+Release: -O3
23
+RelWithDebInfo : -O2 -g
24
+MinSizeRel : -Os
25
+empty(default) :
26
+
27
+NOTE: -DCMAKE_BUILD_TYPE is optional. For multi-config generators like Visual Studio
28
+this option is ignored
29
+
30
+This process generates a Makefile(Linux/*BSD/MacOS) , Visual Studio solution(Windows) by default.
31
+Run `make` to build Git on Linux/*BSD/MacOS.
32
+Open git.sln on Windows and build Git.
33
+
34
+NOTE: By default CMake uses Makefile as the build tool on Linux and Visual Studio in Windows,
35
+to use another tool say `ninja` add this to the command line when configuring.
36
+`-G Ninja`
37
+
38
+]]
39
+cmake_minimum_required(VERSION 3.14)
40
+
41
+#set the source directory to root of git
42
+set(CMAKE_SOURCE_DIR ${CMAKE_CURRENT_LIST_DIR}/../..)
43
+
44
+find_program(SH_EXE sh)
45
+
46
+#Create GIT-VERSION-FILE using GIT-VERSION-GEN
47
+if(NOT EXISTS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE)
48
+ message("Generating GIT-VERSION-FILE")
49
+ execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN
50
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR})
51
+endif()
52
+
53
+#Parse GIT-VERSION-FILE to get the version
54
+file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-FILE git_version REGEX "GIT_VERSION = (.*)")
55
+string(REPLACE "GIT_VERSION = " "" git_version ${git_version})
56
+string(FIND ${git_version} "GIT" location)
57
+if(location EQUAL -1)
58
+ string(REGEX MATCH "[0-9]*\\.[0-9]*\\.[0-9]*" git_version ${git_version})
59
+else()
60
+ string(REGEX MATCH "[0-9]*\\.[0-9]*" git_version ${git_version})
61
+ string(APPEND git_version ".0") #for building from a snapshot
62
+endif()
63
+
64
+project(git
65
+ VERSION ${git_version}
66
+ LANGUAGES C)
67
+
68
+
69
+#macros for parsing the Makefile for sources
70
+macro(parse_makefile_for_sources list_var regex)
71
+ file(STRINGS ${CMAKE_SOURCE_DIR}/Makefile ${list_var} REGEX "^${regex} \\+=(.*)")
72
+ string(REPLACE "${regex} +=" "" ${list_var} ${${list_var}})
73
+ string(REPLACE "$(COMPAT_OBJS)" "" ${list_var} ${${list_var}}) #remove "$(COMPAT_OBJS)" This is only for libgit.
74
+ string(STRIP ${${list_var}} ${list_var}) #remove trailing/leading whitespaces
75
+ string(REPLACE ".o" ".c;" ${list_var} ${${list_var}}) #change .o to .c, ; is for converting the string into a list
76
+ list(TRANSFORM ${list_var} STRIP) #remove trailing/leading whitespaces for each element in list
77
+ list(REMOVE_ITEM ${list_var} "") #remove empty list elements
78
+endmacro()
79
+
80
+include(CheckTypeSize)
81
+include(CheckCSourceRuns)
82
+include(CheckCSourceCompiles)
83
+include(CheckIncludeFile)
84
+include(CheckFunctionExists)
85
+include(CheckSymbolExists)
86
+include(CheckStructHasMember)
87
+
88
+find_package(ZLIB REQUIRED)
89
+find_package(CURL)
90
+find_package(EXPAT)
91
+find_package(Iconv)
92
+find_package(Intl)
93
+
94
+if(NOT Intl_FOUND)
95
+ add_compile_definitions(NO_GETTEXT)
96
+ if(NOT Iconv_FOUND)
97
+ add_compile_definitions(NO_ICONV)
98
+ endif()
99
+endif()
100
+
101
+include_directories(SYSTEM ${ZLIB_INCLUDE_DIRS})
102
+if(CURL_FOUND)
103
+ include_directories(SYSTEM ${CURL_INCLUDE_DIRS})
104
+endif()
105
+if(EXPAT_FOUND)
106
+ include_directories(SYSTEM ${EXPAT_INCLUDE_DIRS})
107
+endif()
108
+if(Iconv_FOUND)
109
+ include_directories(SYSTEM ${Iconv_INCLUDE_DIRS})
110
+endif()
111
+if(Intl_FOUND)
112
+ include_directories(SYSTEM ${Intl_INCLUDE_DIRS})
113
+endif()
114
+
115
+#default behaviour
116
+include_directories(${CMAKE_SOURCE_DIR})
117
+add_compile_definitions(GIT_HOST_CPU="${CMAKE_SYSTEM_PROCESSOR}")
118
+add_compile_definitions(SHA256_BLK INTERNAL_QSORT RUNTIME_PREFIX)
119
+add_compile_definitions(NO_OPENSSL SHA1_DC SHA1DC_NO_STANDARD_INCLUDES
120
+ SHA1DC_INIT_SAFE_HASH_DEFAULT=0
121
+ SHA1DC_CUSTOM_INCLUDE_SHA1_C="cache.h"
122
+ SHA1DC_CUSTOM_INCLUDE_UBC_CHECK_C="git-compat-util.h" )
123
+list(APPEND compat_SOURCES sha1dc_git.c sha1dc/sha1.c sha1dc/ubc_check.c block-sha1/sha1.c sha256/block/sha256.c compat/qsort_s.c)
124
+
125
+
126
+add_compile_definitions(PAGER_ENV="LESS=FRX LV=-c"
127
+ ETC_GITATTRIBUTES="etc/gitattributes"
128
+ ETC_GITCONFIG="etc/gitconfig"
129
+ GIT_EXEC_PATH="libexec/git-core"
130
+ GIT_LOCALE_PATH="share/locale"
131
+ GIT_MAN_PATH="share/man"
132
+ GIT_INFO_PATH="share/info"
133
+ GIT_HTML_PATH="share/doc/git-doc"
134
+ DEFAULT_HELP_FORMAT="html"
135
+ DEFAULT_GIT_TEMPLATE_DIR="share/git-core/templates"
136
+ GIT_VERSION="${PROJECT_VERSION}.GIT"
137
+ GIT_USER_AGENT="git/${PROJECT_VERSION}.GIT"
138
+ BINDIR="bin"
139
+ GIT_BUILT_FROM_COMMIT="")
140
+
141
+set(FALLBACK_RUNTIME_PREFIX /home/$ENV{USER})
142
+add_compile_definitions(FALLBACK_RUNTIME_PREFIX="${FALLBACK_RUNTIME_PREFIX}")
143
+
144
+add_compile_definitions(PROCFS_EXECUTABLE_PATH="/proc/self/exe" HAVE_DEV_TTY )
145
+list(APPEND compat_SOURCES unix-socket.c)
146
+
147
+#header checks
148
+check_include_file(libgen.h HAVE_LIBGEN_H)
149
+if(NOT HAVE_LIBGEN_H)
150
+ add_compile_definitions(NO_LIBGEN_H)
151
+ list(APPEND compat_SOURCES compat/basename.c)
152
+endif()
153
+
154
+check_include_file(sys/sysinfo.h HAVE_SYSINFO)
155
+if(HAVE_SYSINFO)
156
+ add_compile_definitions(HAVE_SYSINFO)
157
+endif()
158
+
159
+check_c_source_compiles("
160
+#include <alloca.h>
161
+
162
+int main(void)
163
+{
164
+ char *p = (char *) alloca(2 * sizeof(int));
165
+
166
+ if (p)
167
+ return 0;
168
+ return 0;
169
+}"
170
+HAVE_ALLOCA_H)
171
+if(HAVE_ALLOCA_H)
172
+ add_compile_definitions(HAVE_ALLOCA_H)
173
+endif()
174
+
175
+check_include_file(strings.h HAVE_STRINGS_H)
176
+if(HAVE_STRINGS_H)
177
+ add_compile_definitions(HAVE_STRINGS_H)
178
+endif()
179
+
180
+check_include_file(sys/select.h HAVE_SYS_SELECT_H)
181
+if(NOT HAVE_SYS_SELECT_H)
182
+ add_compile_definitions(NO_SYS_SELECT_H)
183
+endif()
184
+
185
+check_include_file(sys/poll.h HAVE_SYS_POLL_H)
186
+if(NOT HAVE_SYS_POLL_H)
187
+ add_compile_definitions(NO_SYS_POLL_H)
188
+endif()
189
+
190
+check_include_file(poll.h HAVE_POLL_H)
191
+if(NOT HAVE_POLL_H)
192
+ add_compile_definitions(NO_POLL_H)
193
+endif()
194
+
195
+check_include_file(inttypes.h HAVE_INTTYPES_H)
196
+if(NOT HAVE_INTTYPES_H)
197
+ add_compile_definitions(NO_INTTYPES_H)
198
+endif()
199
+
200
+check_include_file(paths.h HAVE_PATHS_H)
201
+if(HAVE_PATHS_H)
202
+ add_compile_definitions(HAVE_PATHS_H)
203
+endif()
204
+
205
+#function checks
206
+set(function_checks
207
+ strcasestr memmem strlcpy strtoimax strtoumax strtoull
208
+ setenv mkdtemp poll pread memmem unsetenv hstrerror)
209
+
210
+foreach(f ${function_checks})
211
+ string(TOUPPER ${f} uf)
212
+ check_function_exists(${f} HAVE_${uf})
213
+ if(NOT HAVE_${uf})
214
+ add_compile_definitions(NO_${uf})
215
+ endif()
216
+endforeach()
217
+
218
+if(NOT HAVE_POLL_H OR NOT HAVE_SYS_POLL_H OR NOT HAVE_POLL)
219
+ include_directories(${CMAKE_SOURCE_DIR}/compat/poll)
220
+ add_compile_definitions(NO_POLL)
221
+ list(APPEND compat_SOURCES compat/poll/poll.c)
222
+endif()
223
+
224
+if(NOT HAVE_STRCASESTR)
225
+ list(APPEND compat_SOURCES compat/strcasestr.c)
226
+endif()
227
+
228
+if(NOT HAVE_STRLCPY)
229
+ list(APPEND compat_SOURCES compat/strlcpy.c)
230
+endif()
231
+
232
+if(NOT HAVE_STRTOUMAX)
233
+ list(APPEND compat_SOURCES compat/strtoumax.c compat/strtoimax.c)
234
+endif()
235
+
236
+if(NOT HAVE_SETENV)
237
+ list(APPEND compat_SOURCES compat/setenv.c)
238
+endif()
239
+
240
+if(NOT HAVE_MKDTEMP)
241
+ list(APPEND compat_SOURCES compat/mkdtemp.c)
242
+endif()
243
+
244
+if(NOT HAVE_PREAD)
245
+ list(APPEND compat_SOURCES compat/pread.c)
246
+endif()
247
+
248
+if(NOT HAVE_MEMMEM)
249
+ list(APPEND compat_SOURCES compat/memmem.c)
250
+endif()
251
+
252
+if(NOT WIN32)
253
+ if(NOT HAVE_UNSETENV)
254
+ list(APPEND compat_SOURCES compat/unsetenv.c)
255
+ endif()
256
+
257
+ if(NOT HAVE_HSTRERROR)
258
+ list(APPEND compat_SOURCES compat/hstrerror.c)
259
+ endif()
260
+endif()
261
+
262
+check_function_exists(getdelim HAVE_GETDELIM)
263
+if(HAVE_GETDELIM)
264
+ add_compile_definitions(HAVE_GETDELIM)
265
+endif()
266
+
267
+check_function_exists(clock_gettime HAVE_CLOCK_GETTIME)
268
+check_symbol_exists(CLOCK_MONOTONIC "time.h" HAVE_CLOCK_MONOTONIC)
269
+if(HAVE_CLOCK_GETTIME)
270
+ add_compile_definitions(HAVE_CLOCK_GETTIME)
271
+endif()
272
+if(HAVE_CLOCK_MONOTONIC)
273
+ add_compile_definitions(HAVE_CLOCK_MONOTONIC)
274
+endif()
275
+
276
+#check for st_blocks in struct stat
277
+check_struct_has_member("struct stat" st_blocks "sys/stat.h" STRUCT_STAT_HAS_ST_BLOCKS)
278
+if(NOT STRUCT_STAT_HAS_ST_BLOCKS)
279
+ add_compile_definitions(NO_ST_BLOCKS_IN_STRUCT_STAT)
280
+endif()
281
+
282
+#compile checks
283
+check_c_source_runs("
284
+#include<stdio.h>
285
+#include<stdarg.h>
286
+#include<string.h>
287
+#include<stdlib.h>
288
+
289
+int test_vsnprintf(char *str, size_t maxsize, const char *format, ...)
290
+{
291
+ int ret;
292
+ va_list ap;
293
+
294
+ va_start(ap, format);
295
+ ret = vsnprintf(str, maxsize, format, ap);
296
+ va_end(ap);
297
+ return ret;
298
+}
299
+
300
+int main(void)
301
+{
302
+ char buf[6];
303
+
304
+ if (test_vsnprintf(buf, 3, \"%s\", \"12345\") != 5
305
+ || strcmp(buf, \"12\"))
306
+ return 1;
307
+ if (snprintf(buf, 3, \"%s\", \"12345\") != 5
308
+ || strcmp(buf, \"12\"))
309
+ return 1;
310
+ return 0;
311
+}"
312
+SNPRINTF_OK)
313
+if(NOT SNPRINTF_OK)
314
+ add_compile_definitions(SNPRINTF_RETURNS_BOGUS)
315
+ list(APPEND compat_SOURCES compat/snprintf.c)
316
+endif()
317
+
318
+check_c_source_runs("
319
+#include<stdio.h>
320
+
321
+int main(void)
322
+{
323
+ FILE *f = fopen(\".\", \"r\");
324
+
325
+ return f != NULL;
326
+}"
327
+FREAD_READS_DIRECTORIES_NO)
328
+if(NOT FREAD_READS_DIRECTORIES_NO)
329
+ add_compile_definitions(FREAD_READS_DIRECTORIES)
330
+ list(APPEND compat_SOURCES compat/fopen.c)
331
+endif()
332
+
333
+check_c_source_compiles("
334
+#include <regex.h>
335
+#ifndef REG_STARTEND
336
+#error oops we dont have it
337
+#endif
338
+
339
+int main(void)
340
+{
341
+ return 0;
342
+}"
343
+HAVE_REGEX)
344
+if(NOT HAVE_REGEX)
345
+ include_directories(${CMAKE_SOURCE_DIR}/compat/regex)
346
+ list(APPEND compat_SOURCES compat/regex/regex.c )
347
+ add_compile_definitions(NO_REGEX NO_MBSUPPORT GAWK)
348
+endif()
349
+
350
+
351
+check_c_source_compiles("
352
+#include <stddef.h>
353
+#include <sys/types.h>
354
+#include <sys/sysctl.h>
355
+
356
+int main(void)
357
+{
358
+ int val, mib[2];
359
+ size_t len;
360
+
361
+ mib[0] = CTL_HW;
362
+ mib[1] = 1;
363
+ len = sizeof(val);
364
+ return sysctl(mib, 2, &val, &len, NULL, 0) ? 1 : 0;
365
+}"
366
+HAVE_BSD_SYSCTL)
367
+if(HAVE_BSD_SYSCTL)
368
+ add_compile_definitions(HAVE_BSD_SYSCTL)
369
+endif()
370
+
371
+set(CMAKE_REQUIRED_LIBRARIES ${Iconv_LIBRARIES})
372
+set(CMAKE_REQUIRED_INCLUDES ${Iconv_INCLUDE_DIRS})
373
+
374
+check_c_source_compiles("
375
+#include <iconv.h>
376
+
377
+extern size_t iconv(iconv_t cd,
378
+ char **inbuf, size_t *inbytesleft,
379
+ char **outbuf, size_t *outbytesleft);
380
+
381
+int main(void)
382
+{
383
+ return 0;
384
+}"
385
+HAVE_NEW_ICONV)
386
+if(HAVE_NEW_ICONV)
387
+ set(HAVE_OLD_ICONV 0)
388
+else()
389
+ set(HAVE_OLD_ICONV 1)
390
+endif()
391
+
392
+check_c_source_runs("
393
+#include <iconv.h>
394
+#if ${HAVE_OLD_ICONV}
395
+typedef const char *iconv_ibp;
396
+#else
397
+typedef char *iconv_ibp;
398
+#endif
399
+
400
+int main(void)
401
+{
402
+ int v;
403
+ iconv_t conv;
404
+ char in[] = \"a\";
405
+ iconv_ibp pin = in;
406
+ char out[20] = \"\";
407
+ char *pout = out;
408
+ size_t isz = sizeof(in);
409
+ size_t osz = sizeof(out);
410
+
411
+ conv = iconv_open(\"UTF-16\", \"UTF-8\");
412
+ iconv(conv, &pin, &isz, &pout, &osz);
413
+ iconv_close(conv);
414
+ v = (unsigned char)(out[0]) + (unsigned char)(out[1]);
415
+ return v != 0xfe + 0xff;
416
+}"
417
+ICONV_DOESNOT_OMIT_BOM)
418
+if(NOT ICONV_DOESNOT_OMIT_BOM)
419
+ add_compile_definitions(ICONV_OMITS_BOM)
420
+endif()
421
+
422
+unset(CMAKE_REQUIRED_LIBRARIES)
423
+unset(CMAKE_REQUIRED_INCLUDES)
424
+
425
+
426
+#programs
427
+set(PROGRAMS_BUILT
428
+ git git-bugreport git-credential-store git-daemon git-fast-import git-http-backend git-sh-i18n--envsubst
429
+ git-shell git-remote-testsvn git-credential-cache git-credential-cache--daemon)
430
+
431
+if(NOT CURL_FOUND)
432
+ list(APPEND excluded_progs git-http-fetch git-http-push)
433
+ add_compile_definitions(NO_CURL)
434
+ message(WARNING "git-http-push and git-http-fetch will not be built")
435
+else()
436
+ list(APPEND PROGRAMS_BUILT git-http-fetch git-http-push git-imap-send git-remote-http)
437
+ if(CURL_VERSION_STRING VERSION_GREATER_EQUAL 7.34.0)
438
+ add_compile_definitions(USE_CURL_FOR_IMAP_SEND)
439
+ endif()
440
+endif()
441
+
442
+if(NOT EXPAT_FOUND)
443
+ list(APPEND excluded_progs git-http-push)
444
+ add_compile_definitions(NO_EXPAT)
445
+else()
446
+ list(APPEND PROGRAMS_BUILT git-http-push)
447
+ if(EXPAT_VERSION_STRING VERSION_LESS_EQUAL 1.2)
448
+ add_compile_definitions(EXPAT_NEEDS_XMLPARSE_H)
449
+ endif()
450
+endif()
451
+
452
+list(REMOVE_DUPLICATES excluded_progs)
453
+list(REMOVE_DUPLICATES PROGRAMS_BUILT)
454
+
455
+
456
+foreach(p ${excluded_progs})
457
+ list(APPEND EXCLUSION_PROGS --exclude-program ${p} )
458
+endforeach()
459
+
460
+#for comparing null values
461
+list(APPEND EXCLUSION_PROGS empty)
462
+set(EXCLUSION_PROGS_CACHE ${EXCLUSION_PROGS} CACHE STRING "Programs not built" FORCE)
463
+
464
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/command-list.h OR NOT EXCLUSION_PROGS_CACHE STREQUAL EXCLUSION_PROGS)
465
+ list(REMOVE_ITEM EXCLUSION_PROGS empty)
466
+ message("Generating command-list.h")
467
+ execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-cmdlist.sh ${EXCLUSION_PROGS} command-list.txt
468
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
469
+ OUTPUT_FILE ${CMAKE_BINARY_DIR}/command-list.h)
470
+endif()
471
+
472
+if(NOT EXISTS ${CMAKE_BINARY_DIR}/config-list.h)
473
+ message("Generating config-list.h")
474
+ execute_process(COMMAND ${SH_EXE} ${CMAKE_SOURCE_DIR}/generate-configlist.sh
475
+ WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
476
+ OUTPUT_FILE ${CMAKE_BINARY_DIR}/config-list.h)
477
+endif()
478
+
479
+include_directories(${CMAKE_BINARY_DIR})
480
+
481
+#build
482
+#libgit
483
+parse_makefile_for_sources(libgit_SOURCES "LIB_OBJS")
484
+
485
+list(TRANSFORM libgit_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
486
+list(TRANSFORM compat_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
487
+add_library(libgit ${libgit_SOURCES} ${compat_SOURCES})
488
+
489
+#libxdiff
490
+parse_makefile_for_sources(libxdiff_SOURCES "XDIFF_OBJS")
491
+
492
+list(TRANSFORM libxdiff_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
493
+add_library(xdiff STATIC ${libxdiff_SOURCES})
494
+
495
+#libvcs-svn
496
+parse_makefile_for_sources(libvcs-svn_SOURCES "VCSSVN_OBJS")
497
+
498
+list(TRANSFORM libvcs-svn_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
499
+add_library(vcs-svn STATIC ${libvcs-svn_SOURCES})
500
+
501
+#link all required libraries to common-main
502
+add_library(common-main OBJECT ${CMAKE_SOURCE_DIR}/common-main.c)
503
+target_link_libraries(common-main libgit xdiff ${ZLIB_LIBRARIES} pthread rt)
504
+if(Intl_FOUND)
505
+ target_link_libraries(common-main ${Intl_LIBRARIES})
506
+endif()
507
+if(Iconv_FOUND)
508
+ target_link_libraries(common-main ${Iconv_LIBRARIES})
509
+endif()
510
+
511
+#git
512
+parse_makefile_for_sources(git_SOURCES "BUILTIN_OBJS")
513
+
514
+list(TRANSFORM git_SOURCES PREPEND "${CMAKE_SOURCE_DIR}/")
515
+add_executable(git ${CMAKE_SOURCE_DIR}/git.c ${git_SOURCES})
516
+target_link_libraries(git common-main)
517
+
518
+add_executable(git-bugreport ${CMAKE_SOURCE_DIR}/bugreport.c)
519
+target_link_libraries(git-bugreport common-main)
520
+
521
+add_executable(git-credential-store ${CMAKE_SOURCE_DIR}/credential-store.c)
522
+target_link_libraries(git-credential-store common-main)
523
+
524
+add_executable(git-daemon ${CMAKE_SOURCE_DIR}/daemon.c)
525
+target_link_libraries(git-daemon common-main)
526
+
527
+add_executable(git-fast-import ${CMAKE_SOURCE_DIR}/fast-import.c)
528
+target_link_libraries(git-fast-import common-main)
529
+
530
+add_executable(git-http-backend ${CMAKE_SOURCE_DIR}/http-backend.c)
531
+target_link_libraries(git-http-backend common-main)
532
+
533
+add_executable(git-sh-i18n--envsubst ${CMAKE_SOURCE_DIR}/sh-i18n--envsubst.c)
534
+target_link_libraries(git-sh-i18n--envsubst common-main)
535
+
536
+add_executable(git-shell ${CMAKE_SOURCE_DIR}/shell.c)
537
+target_link_libraries(git-shell common-main)
538
+
539
+if(CURL_FOUND)
540
+ add_library(http_obj OBJECT ${CMAKE_SOURCE_DIR}/http.c)
541
+
542
+ add_executable(git-imap-send ${CMAKE_SOURCE_DIR}/imap-send.c)
543
+ target_link_libraries(git-imap-send http_obj common-main ${CURL_LIBRARIES})
544
+
545
+ add_executable(git-http-fetch ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/http-fetch.c)
546
+ target_link_libraries(git-http-fetch http_obj common-main ${CURL_LIBRARIES})
547
+
548
+ add_executable(git-remote-http ${CMAKE_SOURCE_DIR}/http-walker.c ${CMAKE_SOURCE_DIR}/remote-curl.c)
549
+ target_link_libraries(git-remote-http http_obj common-main ${CURL_LIBRARIES} )
550
+
551
+ if(EXPAT_FOUND)
552
+ add_executable(git-http-push ${CMAKE_SOURCE_DIR}/http-push.c)
553
+ target_link_libraries(git-http-push http_obj common-main ${CURL_LIBRARIES} ${EXPAT_LIBRARIES})
554
+ endif()
555
+endif()
556
+
557
+add_executable(git-remote-testsvn ${CMAKE_SOURCE_DIR}/remote-testsvn.c)
558
+target_link_libraries(git-remote-testsvn common-main vcs-svn)
559
+
560
+add_executable(git-credential-cache ${CMAKE_SOURCE_DIR}/credential-cache.c)
561
+target_link_libraries(git-credential-cache common-main)
562
+
563
+add_executable(git-credential-cache--daemon ${CMAKE_SOURCE_DIR}/credential-cache--daemon.c)
564
+target_link_libraries(git-credential-cache--daemon common-main)
565
+
566
+
567
+set(git_builtin_extra
568
+ cherry cherry-pick format-patch fsck-objects
569
+ init merge-subtree restore show
570
+ stage status switch whatchanged)
571
+
572
+#Creating hardlinks
573
+foreach(s ${git_SOURCES} ${git_builtin_extra})
574
+ string(REPLACE "${CMAKE_SOURCE_DIR}/builtin/" "" s ${s})
575
+ string(REPLACE ".c" "" s ${s})
576
+ file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git git-${s})\n")
577
+ list(APPEND git_links ${CMAKE_BINARY_DIR}/git-${s})
578
+endforeach()
579
+
580
+if(CURL_FOUND)
581
+ set(remote_exes
582
+ git-remote-https git-remote-ftp git-remote-ftps)
583
+ foreach(s ${remote_exes})
584
+ file(APPEND ${CMAKE_BINARY_DIR}/CreateLinks.cmake "file(CREATE_LINK git-remote-http ${s})\n")
585
+ list(APPEND git_http_links ${CMAKE_BINARY_DIR}/${s})
586
+ endforeach()
587
+endif()
588
+
589
+add_custom_command(OUTPUT ${git_links} ${git_http_links}
590
+ COMMAND ${CMAKE_COMMAND} -P ${CMAKE_BINARY_DIR}/CreateLinks.cmake
591
+ DEPENDS git git-remote-http)
592
+add_custom_target(git-links ALL DEPENDS ${git_links} ${git_http_links})