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

[PATCH v2 00/11] CMake build system for git

From
Sibi Siddharthan via GitGitGadget <gitgitgadget@gmail.com>
Date
May 12, 2020, 16:50 UTC
Message-ID
<pull.614.v2.git.1589302254.gitgitgadget@gmail.com>
In-Reply-To
<pull.614.git.1587700897.gitgitgadget@gmail.com>

This is an attempt to build Git using CMake. CMake is cross-platform build generator which works well on a variety of platforms(primarily Linux and Windows). Using CMake we can check whether certain headers exist, certain functions exist, the required libraries are present and configure the build accordingly. Using CMake we can also build and test Git out of source, resulting in a clean source tree.

Tested platforms
Ubuntu 18.04 GCC 7.4 Clang 8.0.1
Windows MinGW GCC 9.2 Clang 9 Visual Studio 2015,2017,2019
Changes:
1) The CMake script has been relocated to contrib/buildsystems 2) The CMake
script parses the Makefile for the sources. 3) Philip suggested to change
the error message if sh/bash was not found on windows. 4) CMake now tests
for ICONV_OMITS_BOM, NO_ST_BLOCKS_IN_STRUCT_STAT
Sibi Siddharthan (11):
  Introduce CMake support for configuring Git on Linux
  cmake: generate the shell/perl/python scripts and templates,
    translations
  cmake: installation support for git
  cmake: support for testing git with ctest
  cmake: support for testing git when building out of the source tree
  cmake: support for building git on windows with mingw
  cmake: support for building git on windows with msvc and clang.
  cmake: added checks for struct stat and libiconv
  cmake: relocated script file contrib/buildsystems
  cmake: parse the makefile for the sources.
  ci: modification of main.yml to use cmake for vs-build job
 .github/workflows/main.yml          |  46 +-
 contrib/buildsystems/CMakeLists.txt | 945 ++++++++++++++++++++++++++++
 2 files changed, 971 insertions(+), 20 deletions(-)
 create mode 100644 contrib/buildsystems/CMakeLists.txt
base-commit: 744177e7f7fd407c26e9e4aa3b19696859010c48
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-614%2FSibiSiddharthan%2Fgit-og-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-614/SibiSiddharthan/git-og-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/614
Range-diff vs v1:
  1:  70ab1f03dd5 =  1:  70ab1f03dd5 Introduce CMake support for configuring Git on Linux
  2:  ca242cf5bda =  2:  ca242cf5bda cmake: generate the shell/perl/python scripts and templates, translations
  3:  10390063a39 !  3:  b2974432d77 cmake: installation support for git
     @@ Commit message
      
          Then run `make install`
      
     +    Changes:
     +    Removed a comment regarding the installation of gitk.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: if(MSGFMT_EXE)
      +#install
      +install(TARGETS git git-shell
      +	RUNTIME DESTINATION bin)
     -+install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver  #${CMAKE_SOURCE_DIR}/gitk-git/gitk check
     ++install(PROGRAMS ${CMAKE_BINARY_DIR}/git-cvsserver
      +	DESTINATION bin)
      +
      +list(REMOVE_ITEM PROGRAMS_BUILT git git-shell)
  4:  35a3554df3e !  4:  2bd8870fb96 cmake: support for testing git with ctest
     @@ Commit message
      
          NOTE: Testing only works when building in source for now.
      
     +    Changes:
     +    Renamed the variable test_helper_sources to test-tool_SOURCES
     +    to be consistent with the naming of source variables.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +add_executable(test-svn-fe t/helper/test-svn-fe.c)
      +target_link_libraries(test-svn-fe common-main vcs-svn)
      +
     -+set(test_helper_sources
     ++set(test-tool_SOURCES
      +	t/helper/test-tool.c t/helper/test-advise.c t/helper/test-bloom.c t/helper/test-chmtime.c
      +	t/helper/test-config.c t/helper/test-ctype.c t/helper/test-date.c t/helper/test-delta.c
      +	t/helper/test-dir-iterator.c t/helper/test-drop-caches.c t/helper/test-dump-cache-tree.c
     @@ CMakeLists.txt: install(DIRECTORY ${CMAKE_BINARY_DIR}/templates/blt/ DESTINATION
      +	t/helper/test-trace2.c t/helper/test-urlmatch-normalization.c t/helper/test-xml-encode.c
      +	t/helper/test-wildmatch.c t/helper/test-windows-named-pipe.c t/helper/test-write-cache.c)
      +
     -+add_executable(test-tool ${test_helper_sources})
     ++add_executable(test-tool ${test-tool_SOURCES})
      +target_link_libraries(test-tool common-main)
      +
      +set_target_properties(test-fake-ssh test-line-buffer test-svn-fe test-tool
  5:  166b78f7175 =  5:  096f6311ad5 cmake: support for testing git when building out of the source tree
  6:  d6c630028bf !  6:  00cae10bbb7 cmake: support for building git on windows with mingw
     @@ Commit message
          To use CMake on Windows with MinGW do this:
          cmake `relative-path-to-srcdir` -G "MinGW Makefiles"
      
     +    Changes:
     +    Changed the error message when sh.exe is not found on Windows as
     +    suggested by Philip Oakley <philipoakley@iee.email>
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## CMakeLists.txt ##
     @@ CMakeLists.txt: if(Intl_FOUND)
       
       find_program(SH_EXE sh)
      +if(NOT SH_EXE)
     -+	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
     ++	message(FATAL_ERROR "sh: shell interpreter was not found in your path, please install one."
     ++			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
      +endif()
      +
      +if(WIN32)
  7:  0577d7bf0a8 !  7:  af6c606881d cmake: support for building git on windows with msvc and clang.
     @@ CMakeLists.txt: find_package(ZLIB REQUIRED)
       if(NOT Intl_FOUND)
       	add_compile_definitions(NO_GETTEXT)
      @@ CMakeLists.txt: if(NOT SH_EXE)
     - 	message(FATAL_ERROR "sh interpreter was not found in your path, please install one. On Windows you can get it from here https://gitforwindows.org/")
     + 			"On Windows, you can get it as part of 'Git for Windows' install at https://gitforwindows.org/")
       endif()
       
      -if(WIN32)
  -:  ----------- >  8:  f496cd7d8aa cmake: added checks for struct stat and libiconv
  -:  ----------- >  9:  9c674372fb5 cmake: relocated script file contrib/buildsystems
  -:  ----------- > 10:  b0a321a714a cmake: parse the makefile for the sources.
  8:  f0294be3f11 ! 11:  fa1b8032906 ci: modification of main.yml to use cmake for vs-build job
     @@ Commit message
          FindCURL module. An extra definition (-DCURL_NO_CURL_CMAKE=ON) has been
          added to revert to the old behaviour.
      
     +    Edit(Explanation for the reordering of build steps):
     +    In the configuration phase CMake looks for the required libraries for
     +    building git (eg zlib,libiconv). So we extract the libraries before we
     +    configure.
     +
     +    Changes:
     +    The CMake script has been relocated to contib/buildsystems, so point
     +    to the CMakeLists.txt in the invocation commands.
     +
     +    The generation command now uses the absolute paths for the generation
     +    step.
     +
     +    To check for ICONV_OMITS_BOM libiconv.dll needs to be in the working
     +    directory of script or path. So we copy the dlls before we configure.
     +
          Signed-off-by: Sibi Siddharthan <sibisiddharthan.github@gmail.com>
      
       ## .github/workflows/main.yml ##
     @@ .github/workflows/main.yml: jobs:
               Remove-Item compat.zip
           - name: add msbuild to PATH
             uses: microsoft/setup-msbuild@v1.0.0
     -+    - name: generate Visual Studio solution
     ++    - name: copy dlls to root
      +      shell: powershell
      +      run: |
     -+        & .\git-sdk-64-minimal\usr\bin\bash.exe -lc @"
     -+          cmake . -DCMAKE_PREFIX_PATH=./compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=./git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
     -+        "@
     ++        & compat\vcbuild\vcpkg_copy_dlls.bat release
      +        if (!$?) { exit(1) }
     ++    - name: generate Visual Studio solution
     ++      shell: bash
     ++      run: cmake `pwd`/contrib/buildsystems/ -DCMAKE_PREFIX_PATH=`pwd`/compat/vcbuild/vcpkg/installed/x64-windows -DMSGFMT_EXE=`pwd`/git-sdk-64-minimal/mingw64/bin/msgfmt.exe -DPERL_TESTS=OFF -DPYTHON_TESTS=OFF -DCURL_NO_CURL_CMAKE=ON
           - name: MSBuild
             run: msbuild git.sln -property:Configuration=Release -property:Platform=x64 -maxCpuCount:4 -property:PlatformToolset=v142
           - name: bundle artifact tar
     +@@ .github/workflows/main.yml: jobs:
     +         MSVC: 1
     +         VCPKG_ROOT: ${{github.workspace}}\compat\vcbuild\vcpkg
     +       run: |
     +-        & compat\vcbuild\vcpkg_copy_dlls.bat release
     +-        if (!$?) { exit(1) }
     +         & git-sdk-64-minimal\usr\bin\bash.exe -lc @"
     +           mkdir -p artifacts &&
     +           eval \"`$(make -n artifacts-tar INCLUDE_DLLS_IN_ARTIFACTS=YesPlease ARTIFACTS_DIRECTORY=artifacts 2>&1 | grep ^tar)\"
      @@ .github/workflows/main.yml: jobs:
               nr: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
           steps:
-- 
gitgitgadget
Previous: Jeff KingNext: Sibi Siddharthan via GitGitGadget
Message 85 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.