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

[PATCH v2 00/10] CMake and Visual Studio

From
Johannes Schindelin via GitGitGadget <gitgitgadget@gmail.com>
Date
Sep 26, 2020, 21:32 UTC
Message-ID
<pull.738.v2.git.1601155970.gitgitgadget@gmail.com>
In-Reply-To
<pull.738.git.1601044118.gitgitgadget@gmail.com>

The intention of this patch series is to make it as easy as possible for a Visual Studio user to start building Git from scratch. The idea is to

 * clone Git's source code,
 * open it in Visual Studio via File>Open>Folder...
 * let CMake configure things (and vcpkg build the dependencies, which will
   take a while), and
 * start the build.

It does require a Git for Windows to be installed (so that the source can be cloned, but also to run the shell script parts of the CMake configuration), and also to run the tests.

This patch series replaces the patch "Ignore files generated by CMake" I sent via https://github.com/gitgitgadget/git/pull/735.

Changes since v1:
 * Touched up a couple commit messages in response to reviewer comments
 * Adjusted the instructions at the top of CMakeLists.txt so that the part
   talking about running CMake manually also talks about using 
   contrib/buildsystems/out/ as build directory (in line with the part
   talking about Visual Studio's out-of-the-box experience)
 * Replaced patch 10/10 with Junio's much more elegant solution of editing
   the hashmap_for_each_entry() macro instead of all of its callers.
Johannes Schindelin (9):
  cmake: ignore files generated by CMake as run in Visual Studio
  cmake: do find Git for Windows' shell interpreter
  cmake: ensure that the `vcpkg` packages are found on Windows
  cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows
  cmake: quote the path accurately when editing `test-lib.sh`
  cmake (Windows): let the `.dll` files be found when running the tests
  cmake (Windows): complain when encountering an unknown compiler
  cmake (Windows): initialize vcpkg/build dependencies automatically
  cmake (Windows): recommend using Visual Studio's built-in CMake
    support
Junio C Hamano (1):
  hashmap_for_each_entry(): workaround MSVC's runtime check failure #3
 .gitignore                          |  1 +
 contrib/buildsystems/CMakeLists.txt | 57 ++++++++++++++++++++++-------
 hashmap.h                           |  3 +-
 3 files changed, 47 insertions(+), 14 deletions(-)
base-commit: e1cfff676549cdcd702cbac105468723ef2722f4
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-738%2Fdscho%2Fcmake-and-visual-studio-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-738/dscho/cmake-and-visual-studio-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/738
Range-diff vs v1:
  1:  ba314373e9 =  1:  ba314373e9 cmake: ignore files generated by CMake as run in Visual Studio
  2:  05b4b69fee =  2:  05b4b69fee cmake: do find Git for Windows' shell interpreter
  3:  5967822a0c =  3:  5967822a0c cmake: ensure that the `vcpkg` packages are found on Windows
  4:  efc93f1dd9 =  4:  efc93f1dd9 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on Windows
  5:  8b3500a07c =  5:  8b3500a07c cmake: quote the path accurately when editing `test-lib.sh`
  6:  bb8f122cde !  6:  88abbd9a78 cmake (Windows): let the `.dll` files are found when running the tests
     @@ Metadata
      Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
      
       ## Commit message ##
     -    cmake (Windows): let the `.dll` files are found when running the tests
     +    cmake (Windows): let the `.dll` files be found when running the tests
      
          Contrary to Unix-ish platforms, the dependencies' shared libraries are
          not usually found in one central place. In our case, since we use
  7:  dddfa3a9b4 !  7:  26ebeecb14 cmake (Windows): complain when encountering an unknown compiler
     @@ Commit message
          We have some custom handling regarding the link options, which are
          specific to each compiler.
      
     -    Therefore: let's not just continue without setting the link options when
     +    Therefore: let's not just continue without setting the link options if
          configuring for a currently unhandled compiler, but error out.
      
     -    Note: for some reason, the `invalidcontinue.obj` trick seems not to work
     -    in this developer's hands when building Git in Debug mode: the assertion
     -    dialog that is supposed to be suppressed still pops up, complaining
     -    about the `entry` variable being uninitialized when it is used in
     -    `config.c`'s line 1961.
     -
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
       ## contrib/buildsystems/CMakeLists.txt ##
  8:  3a07bd4916 =  8:  3587ee5e8d cmake (Windows): initialize vcpkg/build dependencies automatically
  9:  f07e421666 !  9:  68a7d984ec cmake (Windows): recommend using Visual Studio's built-in CMake support
     @@ Commit message
          configuration in CMake manually (does not matter whether using the
          command-line or CMake's GUI).
      
     +    While at it, recommend using `contrib/buildsystems/out/` as build
     +    directory also in the part that talks about running CMake manually.
     +
     +    Helped-by: Junio C Hamano <gitster@pobox.com>
          Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
      
       ## contrib/buildsystems/CMakeLists.txt ##
     @@ contrib/buildsystems/CMakeLists.txt
       
      -Instructions to run CMake:
      +Instructions how to use this in Visual Studio:
     -+
     + 
     +-cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
     +-Eg.
     +-From the root of git source tree
     +-	`cmake contrib/buildsystems/ `
     +-This will build the git binaries at the root
      +Open the worktree as a folder. Visual Studio 2019 and later will detect
      +the CMake configuration automatically and set everything up for you,
      +ready to build. You can then run the tests in `t/` via a regular Git Bash.
     -+
     -+Note: Visual Studio also has the option of opening the CMake configuration
     + 
     +-For out of source builds, say build in 'git/git-build/'
     +-	`mkdir git-build;cd git-build; cmake ../contrib/buildsystems/`
     +-This will build the git binaries in git-build directory
     ++Note: Visual Studio also has the option of opening `CMakeLists.txt`
      +directly; Using this option, Visual Studio will not find the source code,
      +though, therefore the `File>Open>Folder...` option is preferred.
      +
      +Instructions to run CMake manually:
     ++
     ++    mkdir -p contrib/buildsystems/out
     ++    cd contrib/buildsystems/out
     ++    cmake ../ -DCMAKE_BUILD_TYPE=Release
     ++
     ++This will build the git binaries in contrib/buildsystems/out
     ++directory (our top-level .gitignore file knows to ignore contents of
     ++this directory).
       
     - cmake `relative-path-to-CMakeLists.txt` -DCMAKE_BUILD_TYPE=Release
     - Eg.
     + Possible build configurations(-DCMAKE_BUILD_TYPE) with corresponding
     + compiler flags
 10:  dc46d39611 <  -:  ---------- hashmap_for_each_entry(): work around MSVC's run-time check failure #3
  -:  ---------- > 10:  152705bbc6 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3
-- 
gitgitgadget
Previous: Johannes Schindelin via GitGitGadgetNext: Johannes Schindelin via GitGitGadget
Message 29 of 70 in “CMake and Visual Studio”
  1. 00/10 CMake and Visual StudioJohannes Schindelin via GitGitGadget, Sep 25, 2020
  2. 01/10 cmake: ignore files generated by CMake as run in Visual StudioJohannes Schindelin via GitGitGadget, Sep 25, 2020
  3. 02/10 cmake: do find Git for Windows' shell interpreterJohannes Schindelin via GitGitGadget, Sep 25, 2020
  4. Sibi SiddharthanSep 25, 2020
  5. Johannes SchindelinSep 26, 2020
  6. Đoàn Trần Công DanhSep 27, 2020
  7. Johannes SchindelinSep 28, 2020
  8. Đoàn Trần Công DanhSep 29, 2020
  9. Johannes SchindelinSep 29, 2020
  10. 03/10 cmake: ensure that the `vcpkg` packages are found on WindowsJohannes Schindelin via GitGitGadget, Sep 25, 2020
  11. 07/10 cmake (Windows): complain when encountering an unknown compilerJohannes Schindelin via GitGitGadget, Sep 25, 2020
  12. Sibi SiddharthanSep 25, 2020
  13. Johannes SchindelinSep 26, 2020
  14. 06/10 cmake (Windows): let the `.dll` files are found when running the testsJohannes Schindelin via GitGitGadget, Sep 25, 2020
  15. Eric SunshineSep 25, 2020
  16. Johannes SchindelinSep 26, 2020
  17. 05/10 cmake: quote the path accurately when editing `test-lib.sh`Johannes Schindelin via GitGitGadget, Sep 25, 2020
  18. 08/10 cmake (Windows): initialize vcpkg/build dependencies automaticallyJohannes Schindelin via GitGitGadget, Sep 25, 2020
  19. Sibi SiddharthanSep 30, 2020
  20. Johannes SchindelinSep 30, 2020
  21. 09/10 cmake (Windows): recommend using Visual Studio's built-in CMake supportJohannes Schindelin via GitGitGadget, Sep 25, 2020
  22. Junio C HamanoSep 25, 2020
  23. Johannes SchindelinSep 26, 2020
  24. 10/10 hashmap_for_each_entry(): work around MSVC's run-time check failure #3Johannes Schindelin via GitGitGadget, Sep 25, 2020
  25. Junio C HamanoSep 25, 2020
  26. Junio C HamanoSep 26, 2020
  27. Johannes SchindelinSep 26, 2020
  28. 04/10 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on WindowsJohannes Schindelin via GitGitGadget, Sep 25, 2020
  29. 00/10 CMake and Visual StudioJohannes Schindelin via GitGitGadget, Sep 26, 2020
  30. 01/10 cmake: ignore files generated by CMake as run in Visual StudioJohannes Schindelin via GitGitGadget, Sep 26, 2020
  31. 05/10 cmake: quote the path accurately when editing `test-lib.sh`Johannes Schindelin via GitGitGadget, Sep 26, 2020
  32. 03/10 cmake: ensure that the `vcpkg` packages are found on WindowsJohannes Schindelin via GitGitGadget, Sep 26, 2020
  33. 04/10 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on WindowsJohannes Schindelin via GitGitGadget, Sep 26, 2020
  34. 02/10 cmake: do find Git for Windows' shell interpreterJohannes Schindelin via GitGitGadget, Sep 26, 2020
  35. Øystein WalleSep 28, 2020
  36. Johannes SchindelinSep 28, 2020
  37. 10/10 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3Junio C Hamano via GitGitGadget, Sep 26, 2020
  38. 09/10 cmake (Windows): recommend using Visual Studio's built-in CMake supportJohannes Schindelin via GitGitGadget, Sep 26, 2020
  39. 08/10 cmake (Windows): initialize vcpkg/build dependencies automaticallyJohannes Schindelin via GitGitGadget, Sep 26, 2020
  40. 06/10 cmake (Windows): let the `.dll` files be found when running the testsJohannes Schindelin via GitGitGadget, Sep 26, 2020
  41. 07/10 cmake (Windows): complain when encountering an unknown compilerJohannes Schindelin via GitGitGadget, Sep 26, 2020
  42. 00/11 CMake and Visual StudioJohannes Schindelin via GitGitGadget, Sep 28, 2020
  43. 01/11 cmake: ignore files generated by CMake as run in Visual StudioJohannes Schindelin via GitGitGadget, Sep 28, 2020
  44. 03/11 cmake: ensure that the `vcpkg` packages are found on WindowsJohannes Schindelin via GitGitGadget, Sep 28, 2020
  45. 02/11 cmake: do find Git for Windows' shell interpreterJohannes Schindelin via GitGitGadget, Sep 28, 2020
  46. 05/11 cmake: quote the path accurately when editing `test-lib.sh`Johannes Schindelin via GitGitGadget, Sep 28, 2020
  47. 04/11 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on WindowsJohannes Schindelin via GitGitGadget, Sep 28, 2020
  48. 09/11 cmake (Windows): recommend using Visual Studio's built-in CMake supportJohannes Schindelin via GitGitGadget, Sep 28, 2020
  49. 10/11 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3Junio C Hamano via GitGitGadget, Sep 28, 2020
  50. 06/11 cmake (Windows): let the `.dll` files be found when running the testsJohannes Schindelin via GitGitGadget, Sep 28, 2020
  51. 07/11 cmake (Windows): complain when encountering an unknown compilerJohannes Schindelin via GitGitGadget, Sep 28, 2020
  52. 11/11 cmake: fix typo in message when `msgfmt` was not foundJohannes Schindelin via GitGitGadget, Sep 28, 2020
  53. Junio C HamanoSep 28, 2020
  54. Johannes SchindelinSep 29, 2020
  55. 08/11 cmake (Windows): initialize vcpkg/build dependencies automaticallyJohannes Schindelin via GitGitGadget, Sep 28, 2020
  56. Sibi SiddharthanSep 29, 2020
  57. Johannes SchindelinSep 29, 2020
  58. 00/10 CMake and Visual StudioJohannes Schindelin via GitGitGadget, Sep 30, 2020
  59. 05/10 cmake: quote the path accurately when editing `test-lib.sh`Johannes Schindelin via GitGitGadget, Sep 30, 2020
  60. 04/10 cmake: fall back to using `vcpkg`'s `msgfmt.exe` on WindowsJohannes Schindelin via GitGitGadget, Sep 30, 2020
  61. 06/10 cmake (Windows): let the `.dll` files be found when running the testsJohannes Schindelin via GitGitGadget, Sep 30, 2020
  62. 07/10 cmake (Windows): complain when encountering an unknown compilerJohannes Schindelin via GitGitGadget, Sep 30, 2020
  63. 08/10 cmake (Windows): initialize vcpkg/build dependencies automaticallyJohannes Schindelin via GitGitGadget, Sep 30, 2020
  64. Johannes SchindelinSep 30, 2020
  65. Junio C HamanoSep 30, 2020
  66. 09/10 cmake (Windows): recommend using Visual Studio's built-in CMake supportJohannes Schindelin via GitGitGadget, Sep 30, 2020
  67. 10/10 hashmap_for_each_entry(): workaround MSVC's runtime check failure #3Junio C Hamano via GitGitGadget, Sep 30, 2020
  68. 02/10 cmake: do find Git for Windows' shell interpreterJohannes Schindelin via GitGitGadget, Sep 30, 2020
  69. 03/10 cmake: ensure that the `vcpkg` packages are found on WindowsJohannes Schindelin via GitGitGadget, Sep 30, 2020
  70. 01/10 cmake: ignore files generated by CMake as run in Visual StudioJohannes Schindelin via GitGitGadget, Sep 30, 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.