git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 01/11] Introduce CMake support for configuring Git on Linux

From
Junio C Hamano <gitster@pobox.com>
Date
May 12, 2020, 20:59 UTC
Message-ID
<xmqqo8qsc1it.fsf@gitster.c.googlers.com>
In-Reply-To
<70ab1f03dd5413256166bf9db47be47b746ea6b1.1589302254.git.gitgitgadget@gmail.com>
"Sibi Siddharthan via GitGitGadget" <gitgitgadget@gmail.com> writes:
Show 7 quoted lines
> To make this a little less awkward, the Git for Windows project offers
> the `vs/master` branch which has a full Visual Studio solution generated
> and committed. This branch can therefore be used to tinker with Git in
> Visual Studio _without_ having to download the full Git for Windows SDK.
> Unfortunatly, that branch is auto-generated from Git for Windows'
> `master`. If a developer wants to tinker, say, with `pu`, they are out
> of luck.

'pu' or 'next' are not to be built upon, so this is not a good line of reasoning to complain that generating only for 'master' is bad.

> CMake was invented to make this sort of problem go away, by providing a
> more standardized, cross-platform way to configure builds.

I think everything above this point (including Makefile, autoconf etc.) can be replaced with a single sentence

	The build infrastructure for Git is written around being
	able to run make, which is not supported natively on
	Windows.
without anything else.  That will flow naturally to
	Add a build script that uses CMake to help developers on
	Windows to build git.
and then you can continue the current state, like this paragraph.
Show 14 quoted lines
> This is only the first step, and to make it easier to review, it only
> allows for configuring builds on the platform that is easiest to
> configure for: Linux.
>
> The CMake script checks whether the headers are present(eg. libgen.h),
> whether the functions are present(eg. memmem), whether the funtions work
> properly (eg. snprintf) and generate the required compile definitions
> for the platform. The script also searches for the required libraries,
> if it fails to find the required libraries the respective executables
> won't be built.(eg. If libcurl is not found then git-remote-http won't
> be built). This will help building Git easier.
>
> With a CMake script an out of source build of git is possible resulting
> in a clean source tree.
Show 8 quoted lines
> Note: earlier endeavors on the Git mailing list to introduce CMake ended
> up in dead water. The primary reason for that was that reviewers
> _expected_ CMake support to fall out of maintenance, unless the
> contributor would promise to keep an eye on keeping CMake support up to
> date. However, in the meantime, support for automated testing has been
> introduced in Git's source code, and a later patch will modify the
> (still experimental) GitHub workflow to continually verify that CMake
> support is still complete. That will make maintenance reasonably easy.
I am not sure this belongs to the log message.
Show 5 quoted lines
> Note: this patch asks for the minimum version v3.14 of CMake (which is
> not all that old as of time of writing) because that is the first
> version to offer a platform-independent way to generate hardlinks as
> part of the build. This is needed to generate all those hardlinks for
> the built-in commands of Git.

This does, but I do not think hardlinks are not required for our build. On Unix filesystems, it is not just possible but convenient to use, and that is the only reason why we use hardlinks.

If hardlinks are possible but inconvenient to use on Windows, you shouldn't force your target audience to use it.

Show 20 quoted lines
> Instructions to run CMake:
>
> cmake `relative-path-to-srcdir` -DCMAKE_BUILD_TYPE=Release
>
> Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
> compiler flags
> Debug : -g
> Release: -O3
> RelWithDebInfo : -O2 -g
> MinSizeRel : -Os
> empty(default) :
>
> NOTE: -DCMAKE_BUILD_TYPE is optional
>
> This process generates a Makefile.
> Then run `make` to build Git.
>
> NOTE: By default CMake uses Makefile as the build tool on Linux, to use
> another tool say `ninja` add this to the command line when configuring.
> `-G Ninja`

I find it curious that from the instruction, the most important platform, the primary reason why we are reviewing this patch, is missing. Don't Windows folks need to be told how to run CMake to build?

In any case, all of the above "Instructions" should go at the top part of CMakeLists.txt in a comment, and not in the log message. "git log" output is not an easy way for your target audience to learn how to use what the commit adds. Think what they need to do when they discover there is CMakeLists.txt in our tree in three months. Don't force them to run "git blame" to find this commit that added the support.

Show 22 quoted lines
> Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
> ---
>  CMakeLists.txt | 528 +++++++++++++++++++++++++++++++++++++++++++++++++
>  1 file changed, 528 insertions(+)
>  create mode 100644 CMakeLists.txt
>
> diff --git a/CMakeLists.txt b/CMakeLists.txt
> new file mode 100644
> index 00000000000..73703bd321f
> --- /dev/null
> +++ b/CMakeLists.txt
> @@ -0,0 +1,528 @@
> +#
> +#	Copyright (c) 2020 Sibi Siddharthan
> +#
> +
> +cmake_minimum_required(VERSION 3.14)
> +
> +#Parse GIT-VERSION-GEN to get the version
> +file(STRINGS ${CMAKE_SOURCE_DIR}/GIT-VERSION-GEN git_version REGEX "DEF_VER=v(.*)")
> +string(REPLACE "DEF_VER=v" "" git_version ${git_version})
> +string(REPLACE ".GIT" ".0" git_version ${git_version})#for building from a snapshot

Hmph, I'd really prefer to see the logic in GIT-VERSION-GEN not bypassed like this. People know they can create a text file 'version' and record the version name they desire in it and expect GIT-VERSION-GEN to pick it up, for example.

Later in this file, you seem to depend on the shell to do things like generating config-list.h file, so I'd rather see the same technique used here a well.

> +set(libgit_SOURCES
> +	abspath.c add-interactive.c add-patch.c advice.c alias.c
> +...
> +	zlib.c)
Hmph.
Show 34 quoted lines
> +set(git_SOURCES
> +	builtin/add.c builtin/am.c builtin/annotate.c builtin/apply.c
> +	builtin/archive.c builtin/bisect--helper.c builtin/blame.c
> +	builtin/branch.c builtin/bundle.c builtin/cat-file.c builtin/check-attr.c
> +	builtin/check-ignore.c builtin/check-mailmap.c builtin/check-ref-format.c
> +	builtin/checkout-index.c builtin/checkout.c builtin/clean.c
> +	builtin/clone.c builtin/column.c builtin/commit-tree.c
> +	builtin/commit.c builtin/commit-graph.c builtin/config.c
> +	builtin/count-objects.c builtin/credential.c builtin/describe.c
> +	builtin/diff-files.c builtin/diff-index.c builtin/diff-tree.c
> +	builtin/diff.c builtin/difftool.c builtin/env--helper.c
> +	builtin/fast-export.c builtin/fetch-pack.c builtin/fetch.c builtin/fmt-merge-msg.c
> +	builtin/for-each-ref.c builtin/fsck.c builtin/gc.c
> +	builtin/get-tar-commit-id.c builtin/grep.c builtin/hash-object.c
> +	builtin/help.c builtin/index-pack.c builtin/init-db.c
> +	builtin/interpret-trailers.c builtin/log.c builtin/ls-files.c
> +	builtin/ls-remote.c builtin/ls-tree.c builtin/mailinfo.c builtin/mailsplit.c
> +	builtin/merge.c builtin/merge-base.c builtin/merge-file.c builtin/merge-index.c
> +	builtin/merge-ours.c builtin/merge-recursive.c builtin/merge-tree.c
> +	builtin/mktag.c builtin/mktree.c builtin/multi-pack-index.c builtin/mv.c
> +	builtin/name-rev.c builtin/notes.c builtin/pack-objects.c builtin/pack-redundant.c
> +	builtin/pack-refs.c builtin/patch-id.c builtin/prune-packed.c builtin/prune.c
> +	builtin/pull.c builtin/push.c builtin/range-diff.c builtin/read-tree.c
> +	builtin/rebase.c builtin/receive-pack.c builtin/reflog.c builtin/remote.c
> +	builtin/remote-ext.c builtin/remote-fd.c builtin/repack.c builtin/replace.c
> +	builtin/rerere.c builtin/reset.c builtin/rev-list.c builtin/rev-parse.c
> +	builtin/revert.c builtin/rm.c builtin/send-pack.c builtin/shortlog.c
> +	builtin/show-branch.c builtin/show-index.c builtin/show-ref.c
> +	builtin/sparse-checkout.c builtin/stash.c builtin/stripspace.c
> +	builtin/submodule--helper.c builtin/symbolic-ref.c builtin/tag.c
> +	builtin/unpack-file.c builtin/unpack-objects.c builtin/update-index.c
> +	builtin/update-ref.c builtin/update-server-info.c builtin/upload-archive.c
> +	builtin/upload-pack.c builtin/var.c builtin/verify-commit.c builtin/verify-pack.c
> +	builtin/verify-tag.c builtin/worktree.c builtin/write-tree.c)
Can't we do a bit better here?  

Perhaps grab this out of our Makefile? The same command applies to huge lists of sources we have seen.

Or do the equivalent of $(wildcard builtin/*.c) if CMake has such a feature?

> ...
> \ No newline at end of file

Double check and make sure you have a text file without an incomplete line at the end.

Thanks.
Previous: Sibi Siddharthan via GitGitGadgetNext: Sibi Siddharthan
Message 90 of 179 in “CMake build system for git”
  1. 0/8 CMake build system for gitSibi Siddharthan via GitGitGadget, Apr 24, 2020
  2. 2/8 cmake: generate the shell/perl/python scripts and templates, translationsSibi Siddharthan via GitGitGadget, Apr 24, 2020
  3. Danh DoanApr 24, 2020
  4. Sibi SiddharthanApr 24, 2020
  5. 3/8 cmake: installation support for gitSibi Siddharthan via GitGitGadget, Apr 24, 2020
  6. Danh DoanApr 24, 2020
  7. Sibi SiddharthanApr 24, 2020
  8. 1/8 Introduce CMake support for configuring Git on LinuxSibi Siddharthan via GitGitGadget, Apr 24, 2020
  9. Danh DoanApr 24, 2020
  10. Sibi SiddharthanApr 24, 2020
  11. Danh DoanApr 24, 2020
  12. Sibi SiddharthanApr 25, 2020
  13. Johannes SchindelinApr 25, 2020
  14. brian m. carlsonApr 25, 2020
  15. Randall S. BeckerApr 25, 2020
  16. Philip OakleyApr 25, 2020
  17. Sibi SiddharthanApr 25, 2020
  18. 5/8 cmake: support for testing git when building out of the source treeSibi Siddharthan via GitGitGadget, Apr 24, 2020
  19. Danh DoanApr 24, 2020
  20. Sibi SiddharthanApr 24, 2020
  21. Danh DoanApr 24, 2020
  22. Sibi SiddharthanApr 25, 2020
  23. 7/8 cmake: support for building git on windows with msvc and clang.Sibi Siddharthan via GitGitGadget, Apr 24, 2020
  24. Danh DoanApr 24, 2020
  25. Sibi SiddharthanApr 24, 2020
  26. 4/8 cmake: support for testing git with ctestSibi Siddharthan via GitGitGadget, Apr 24, 2020
  27. Danh DoanApr 24, 2020
  28. Sibi SiddharthanApr 24, 2020
  29. 8/8 ci: modification of main.yml to use cmake for vs-build jobSibi Siddharthan via GitGitGadget, Apr 24, 2020
  30. Danh DoanApr 24, 2020
  31. Sibi SiddharthanApr 24, 2020
  32. Johannes SchindelinApr 24, 2020
  33. 6/8 cmake: support for building git on windows with mingwSibi Siddharthan via GitGitGadget, Apr 24, 2020
  34. Philip OakleyApr 24, 2020
  35. Sibi SiddharthanApr 24, 2020
  36. Philip OakleyApr 25, 2020
  37. Sibi SiddharthanApr 25, 2020
  38. Junio C HamanoApr 24, 2020
  39. Sibi SiddharthanApr 24, 2020
  40. Junio C HamanoApr 24, 2020
  41. Sibi SiddharthanApr 25, 2020
  42. Philip OakleyApr 25, 2020
  43. Johannes SchindelinApr 25, 2020
  44. Sibi SiddharthanApr 25, 2020
  45. Johannes SchindelinApr 25, 2020
  46. Sibi SiddharthanApr 25, 2020
  47. Johannes SchindelinApr 25, 2020
  48. Sibi SiddharthanApr 25, 2020
  49. Danh DoanApr 26, 2020
  50. Sibi SiddharthanApr 26, 2020
  51. Johannes SchindelinApr 25, 2020
  52. Jeff KingApr 27, 2020
  53. Jeff KingApr 27, 2020
  54. Danh DoanApr 28, 2020
  55. Jeff KingApr 28, 2020
  56. Sibi SiddharthanApr 29, 2020
  57. Johannes SchindelinMay 1, 2020
  58. Sibi SiddharthanMay 2, 2020
  59. Randall S. BeckerMay 2, 2020
  60. Junio C HamanoMay 2, 2020
  61. Sibi SiddharthanMay 3, 2020
  62. Junio C HamanoMay 3, 2020
  63. Konstantin TokarevMay 3, 2020
  64. Junio C HamanoMay 3, 2020
  65. Johannes SchindelinMay 4, 2020
  66. Konstantin TokarevMay 4, 2020
  67. Sibi SiddharthanMay 5, 2020
  68. Junio C HamanoMay 5, 2020
  69. Sibi SiddharthanMay 5, 2020
  70. Junio C HamanoMay 5, 2020
  71. Sibi SiddharthanMay 6, 2020
  72. Đoàn Trần Công DanhMay 7, 2020
  73. Johannes SchindelinMay 6, 2020
  74. Johannes SchindelinMay 7, 2020
  75. Danh DoanMay 2, 2020
  76. Sibi SiddharthanMay 2, 2020
  77. Danh DoanMay 2, 2020
  78. Sibi SiddharthanMay 2, 2020
  79. Junio C HamanoApr 27, 2020
  80. Michal SuchánekApr 27, 2020
  81. Jeff KingApr 27, 2020
  82. Elijah NewrenApr 27, 2020
  83. Junio C HamanoApr 27, 2020
  84. Jeff KingApr 28, 2020
  85. 00/11 CMake build system for gitSibi Siddharthan via GitGitGadget, May 12, 2020
  86. 02/11 cmake: generate the shell/perl/python scripts and templates, translationsSibi Siddharthan via GitGitGadget, May 12, 2020
  87. Junio C HamanoMay 12, 2020
  88. Sibi SiddharthanMay 13, 2020
  89. 01/11 Introduce CMake support for configuring Git on LinuxSibi Siddharthan via GitGitGadget, May 12, 2020
  90. Junio C HamanoMay 12, 2020
  91. Sibi SiddharthanMay 13, 2020
  92. 05/11 cmake: support for testing git when building out of the source treeSibi Siddharthan via GitGitGadget, May 12, 2020
  93. 03/11 cmake: installation support for gitSibi Siddharthan via GitGitGadget, May 12, 2020
  94. 06/11 cmake: support for building git on windows with mingwSibi Siddharthan via GitGitGadget, May 12, 2020
  95. Đoàn Trần Công DanhMay 14, 2020
  96. Sibi SiddharthanMay 14, 2020
  97. 04/11 cmake: support for testing git with ctestSibi Siddharthan via GitGitGadget, May 12, 2020
  98. 07/11 cmake: support for building git on windows with msvc and clang.Sibi Siddharthan via GitGitGadget, May 12, 2020
  99. 08/11 cmake: added checks for struct stat and libiconvSibi Siddharthan via GitGitGadget, May 12, 2020
  100. Junio C HamanoMay 12, 2020
  101. Sibi SiddharthanMay 13, 2020
  102. Junio C HamanoMay 14, 2020
  103. Đoàn Trần Công DanhMay 14, 2020
  104. Sibi SiddharthanMay 14, 2020
  105. 11/11 ci: modification of main.yml to use cmake for vs-build jobSibi Siddharthan via GitGitGadget, May 12, 2020
  106. Junio C HamanoMay 12, 2020
  107. Sibi SiddharthanMay 13, 2020
  108. Sibi SiddharthanMay 25, 2020
  109. Junio C HamanoMay 25, 2020
  110. Sibi SiddharthanMay 25, 2020
  111. Johannes SchindelinMay 25, 2020
  112. 10/11 cmake: parse the makefile for the sources.Sibi Siddharthan via GitGitGadget, May 12, 2020
  113. Junio C HamanoMay 12, 2020
  114. Sibi SiddharthanMay 13, 2020
  115. Junio C HamanoMay 13, 2020
  116. 09/11 cmake: relocated script file contrib/buildsystemsSibi Siddharthan via GitGitGadget, May 12, 2020
  117. Junio C HamanoMay 12, 2020
  118. Sibi SiddharthanMay 13, 2020
  119. 0/8 CMake build system for gitSibi Siddharthan via GitGitGadget, May 29, 2020
  120. 1/8 Introduce CMake support for configuring GitSibi Siddharthan via GitGitGadget, May 29, 2020
  121. Junio C HamanoMay 29, 2020
  122. Sibi SiddharthanMay 30, 2020
  123. Junio C HamanoMay 31, 2020
  124. Johannes SchindelinMay 30, 2020
  125. Đoàn Trần Công DanhMay 30, 2020
  126. 3/8 cmake: installation support for gitSibi Siddharthan via GitGitGadget, May 29, 2020
  127. 2/8 cmake: generate the shell/perl/python scripts and templates, translationsSibi Siddharthan via GitGitGadget, May 29, 2020
  128. Junio C HamanoMay 29, 2020
  129. Sibi SiddharthanMay 30, 2020
  130. Sibi SiddharthanJun 8, 2020
  131. Junio C HamanoJun 8, 2020
  132. 4/8 cmake: support for testing git with ctestSibi Siddharthan via GitGitGadget, May 29, 2020
  133. Đoàn Trần Công DanhMay 30, 2020
  134. Sibi SiddharthanMay 30, 2020
  135. Đoàn Trần Công DanhMay 31, 2020
  136. 6/8 cmake: support for building git on windows with mingwSibi Siddharthan via GitGitGadget, May 29, 2020
  137. 5/8 cmake: support for testing git when building out of the source treeSibi Siddharthan via GitGitGadget, May 29, 2020
  138. 7/8 cmake: support for building git on windows with msvc and clang.Sibi Siddharthan via GitGitGadget, May 29, 2020
  139. Đoàn Trần Công DanhMay 30, 2020
  140. Sibi SiddharthanMay 30, 2020
  141. 8/8 ci: modification of main.yml to use cmake for vs-build jobSibi Siddharthan via GitGitGadget, May 29, 2020
  142. Đoàn Trần Công DanhMay 30, 2020
  143. Sibi SiddharthanMay 30, 2020
  144. 0/8 CMake build system for gitSibi Siddharthan via GitGitGadget, Jun 12, 2020
  145. 3/8 cmake: installation support for gitSibi Siddharthan via GitGitGadget, Jun 12, 2020
  146. 1/8 Introduce CMake support for configuring GitSibi Siddharthan via GitGitGadget, Jun 12, 2020
  147. Øystein WalleJun 15, 2020
  148. Sibi SiddharthanJun 15, 2020
  149. 4/8 cmake: support for testing git with ctestSibi Siddharthan via GitGitGadget, Jun 12, 2020
  150. Øystein WalleJun 15, 2020
  151. Sibi SiddharthanJun 15, 2020
  152. 2/8 cmake: generate the shell/perl/python scripts and templates, translationsSibi Siddharthan via GitGitGadget, Jun 12, 2020
  153. 5/8 cmake: support for testing git when building out of the source treeSibi Siddharthan via GitGitGadget, Jun 12, 2020
  154. 7/8 cmake: support for building git on windows with msvc and clang.Sibi Siddharthan via GitGitGadget, Jun 12, 2020
  155. Øystein WalleJun 15, 2020
  156. Sibi SiddharthanJun 15, 2020
  157. 6/8 cmake: support for building git on windows with mingwSibi Siddharthan via GitGitGadget, Jun 12, 2020
  158. Øystein WalleJun 15, 2020
  159. Sibi SiddharthanJun 15, 2020
  160. Junio C HamanoJun 18, 2020
  161. Sibi SiddharthanJun 18, 2020
  162. Junio C HamanoJun 18, 2020
  163. Sibi SiddharthanJun 18, 2020
  164. Junio C HamanoJun 18, 2020
  165. Sibi SiddharthanJun 19, 2020
  166. Junio C HamanoJun 19, 2020
  167. 8/8 ci: modification of main.yml to use cmake for vs-build jobSibi Siddharthan via GitGitGadget, Jun 12, 2020
  168. 0/8 CMake build system for gitSibi Siddharthan via GitGitGadget, Jun 26, 2020
  169. 1/8 Introduce CMake support for configuring GitSibi Siddharthan via GitGitGadget, Jun 26, 2020
  170. 3/8 cmake: installation support for gitSibi Siddharthan via GitGitGadget, Jun 26, 2020
  171. 7/8 cmake: support for building git on windows with msvc and clang.Sibi Siddharthan via GitGitGadget, Jun 26, 2020
  172. 6/8 cmake: support for building git on windows with mingwSibi Siddharthan via GitGitGadget, Jun 26, 2020
  173. David AguilarJun 30, 2020
  174. Sibi SiddharthanJul 1, 2020
  175. Sibi SiddharthanJul 1, 2020
  176. 2/8 cmake: generate the shell/perl/python scripts and templates, translationsSibi Siddharthan via GitGitGadget, Jun 26, 2020
  177. 8/8 ci: modification of main.yml to use cmake for vs-build jobSibi Siddharthan via GitGitGadget, Jun 26, 2020
  178. 5/8 cmake: support for testing git when building out of the source treeSibi Siddharthan via GitGitGadget, Jun 26, 2020
  179. 4/8 cmake: support for testing git with ctestSibi Siddharthan via GitGitGadget, Jun 26, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.