# Is there a guide on how to configure CMake with MinGW/MSYS and git on Windows?

**URL:** https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563
**Category:** Usage
**Tags:** os:windows
**Created:** [March 19, 2026, 11:16am UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563 "2026-03-19T11:16:00Z")
**Posts on this page:** 11
**Page:** 1

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 19, 2026, 11:16am UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/1 "2026-03-19T11:16:00Z")

</div>

Hi all,

I am a maintainer of a library (OpenXLSX) and have recently augmented the CMake configuration to auto-pull dependencies via find\_package or FetchContent from their source repositories, instead of including a copy of the dependencies with our own library.

I have been asking one of our Windows users to test a new configuration for me, and it seems to be non-trivial to get git working for FetchContent.

On their configuration, CMake complains about not finding git.

As this is a generic “getting started” problem:

Is there a comprehensive guide on installing CMake on Windows so that integration with git is working & commands like FetchContent can be used?

I have no access to a Windows test system, so I can’t trial & error a solution for this.

Any help is appreciated so I can instruct our users on how to prepare their CMake for building OpenXLSX.

Cheers!

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [March 19, 2026, 6:28pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/2 "2026-03-19T18:28:04Z")

</div>

Do you mean building under `MinGW/MSYS` or working under windows with `git for windows`?

See [Using CMake in MSYS2 - MSYS2](https://www.msys2.org/docs/cmake/)

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 19, 2026, 8:39pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/3 "2026-03-19T20:39:48Z")

</div>

With you phrasing this as an “or” question - are you saying that CMake on Windows runs without MinGW?

My question, reduced to the simplest form is:

“How do Windows users install CMake so that it can build projects whose CMake configuration invokes FetchContent commands?”

with the implication being that - as per the observed errors - FetchContent uses git in the background, and CMake in the install that my user reported a test from, does not “find” git.

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [March 19, 2026, 9:04pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/4 "2026-03-19T21:04:53Z")

</div>

That depends on what they want todo?

What is your build system and what os target system?

And what is the toolchain you want to use?

---

<div class="post-metadata">

### Author: ![ClausKlein](https://discourse.cmake.org/user_avatar/discourse.cmake.org/clausklein/32/352_2.png) [@ClausKlein](https://discourse.cmake.org/u/ClausKlein)
#### Post date: [March 19, 2026, 9:20pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/5 "2026-03-19T21:20:52Z")

</div>

The key is to use a _consistent MinGW environment_, not MSYS or Git Bash.

Install via MSYS2:

- `mingw-w64-x86_64-cmake`

- `mingw-w64-x86_64-toolchain`

- `git`

Then run everything from the **MinGW64 shell** :

```auto
cmake -G Ninja ..
cmake --build .

```

`FetchContent` works out of the box as long as Git is available in PATH.

Avoid mixing MSYS, MinGW, and Git Bash—they use different environments and will break detection.

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 19, 2026, 9:48pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/6 "2026-03-19T21:48:33Z")

</div>

Your last bullet list sounds like what I am looking for, and reasonably to the point.  
Regarding your prior comment: I don’t understand the question about the build system - it’s CMake, hence me posting here 🙂 The target system for Windows users is the system on which the build is taking place, i.e. also Windows.

For the toolchain: I would assume both work, gcc/g++ or MSVC, but I have no experience with MSVC (nor do I intend to ever touch it), so let’s focus on g++ for starters.

I will see if one of our users can test the installation sequence you proposed:

- install MSYS2
- via MSYS2, install
  - `mingw-w64-x86_64-cmake`
  - `mingw-w64-x86_64-toolchain`
  - `git`

- run cmake from the mingw64 shell (without ninja, which I assume you wrote as an example)

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 20, 2026, 8:42am UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/7 "2026-03-20T08:42:41Z")

</div>

@ClausKlein another suggestion I got from a C++ chat group is to use the windows package manager like so:

winget install -e --id Kitware.CMake  
winget install -e --id Git.Git

Should that work as well?

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [March 20, 2026, 10:17am UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/8 "2026-03-20T10:17:54Z")

</div>

For MSYS you need a cmake built for MSYS as the MSYS eco system uses a special path mapping internally

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 20, 2026, 12:07pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/9 "2026-03-20T12:07:11Z")

</div>

Duly noted. Is your comment in reference to MSYS2 as well, as suggested by Claus?

---

<div class="post-metadata">

### Author: ![hsattler](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/h/59ef9b/32.png) [@hsattler](https://discourse.cmake.org/u/hsattler)
#### Post date: [March 20, 2026, 3:55pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/10 "2026-03-20T15:55:02Z")

</div>

Yes, as Claus already noted in his instructions

---

<div class="post-metadata">

### Author: ![Lars](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/l/74df32/32.png) [@Lars](https://discourse.cmake.org/u/Lars)
#### Post date: [March 21, 2026, 7:38pm UTC](https://discourse.cmake.org/t/is-there-a-guide-on-how-to-configure-cmake-with-mingw-msys-and-git-on-windows/15563/11 "2026-03-21T19:38:53Z")

</div>

Okay, so here is the list of steps that I _actually_ needed and for which I needed to do some digging.

It would be really nice if you could include these (with optional build systems MSYS, mingw and Ninja) into the documentation:

**Install MSYS2:**

In a Powershell (run as Administrator): run `winget install --id MSYS2.MSYS2 -e`  
→ After performing this step, the “MSYS2 MSYS shell” and the “MSYS2 MinGW 64-bit shell” should be accessible from the Start Menu

In MSYS2 MSYS shell: run `pacman -Syu`  
The previous instruction might require a close & reopen of the MSYS2 MSYS shell

In MSYS2 MSYS shell: run `pacman -Su`

**Install development toolchain:**  
 In MSYS2 MinGW 64‑bit shell: run `pacman -S --needed base-devel mingw-w64-x86_64-toolchain`

**Install `cmake` & `git` in MSYS2 environment:**

In MSYS2 MinGW 64‑bit shell: run `pacman -S --needed mingw-w64-x86_64-cmake mingw-w64-x86_64-git`  
 _(optional)_ In MSYS2 MinGW 64‑bit shell: run `pacman -S --needed mingw-w64-x86_64-ninja`

\*\*  
Verify installation:\*\*  
 In MSYS2 MinGW 64‑bit shell: verify versions of `git`, `cmake`, `gcc`, `g++`

`git --version; cmake --version; gcc --version; g++ --version`

Build your project:

```auto
cd project/
mkdir build; cd build

```

Then:

```auto
cmake .. -G "MSYS Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel

```

or

```auto
cmake .. -G "MinGW Makefiles" -DCMAKE_BUILD_TYPE=Release
cmake --build . --parallel

```

or

```auto
cmake .. -G "Ninja" -DCMAKE_BUILD_TYPE=Release
ninja

```
