# Bootstrap-ability of CMake

**URL:** https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999
**Category:** Development
**Created:** [September 18, 2023, 5:15pm UTC](https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999 "2023-09-18T17:15:37Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![friendlyanon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/friendlyanon/32/970_2.png) [@friendlyanon](https://discourse.cmake.org/u/friendlyanon)
#### Post date: [September 18, 2023, 5:15pm UTC](https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999/1 "2023-09-18T17:15:38Z")

</div>

I had the idea that since CMake is pretty fundamental software at this point, would it be worth to take a look at the bootstrap-ability of the project?

Right now, the way to build from scratch is to setup a POSIX environment and run the `bootstrap` script. This is very bad considering that today CMake cannot be bootstrapped on systems like Windows.

I did take a thorough look at the `bootstrap` script and it’s not all that complicated. Would it be worth an attempt to rewrite it into a C++11 source file? Since 3.10, CMake requires a C++11 compatible compiler and I think C++11 on its own would be quite capable.

Since CMake also vendors projects that it needs to build, this would leave CMake with only a dependency of Ninja (or make), a C++ compiler and/or a C compiler, which would make it easier to build on all platforms.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [September 18, 2023, 5:37pm UTC](https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999/2 "2023-09-18T17:37:45Z")

</div>

CMake can already be bootstrapped on Windows using the MSYS environment. The resulting CMake is not just a quasi-POSIX executable, it can actually generate Visual Studio solutions and other Windows-specific things. The MSYS bootstrap isn’t as straightforward to do as a full POSIX bootstrap, but we have several nightly jobs that do it.

---

<div class="post-metadata">

### Author: ![kyle.edwards](https://discourse.cmake.org/letter_avatar_proxy/v4/letter/k/65b543/32.png) [@kyle.edwards](https://discourse.cmake.org/u/kyle.edwards)
#### Post date: [September 18, 2023, 5:51pm UTC](https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999/3 "2023-09-18T17:51:33Z")

</div>

> [@friendlyanon](#):
>
> and I think C++11 on its own would be quite capable.

Anything that bootstraps CMake has to be able to spawn a new process, and C++11 provides no such API. We recently migrated all of our process-spawning stuff to libuv, but building libuv requires building more than one file… at which point we are back to writing a shell script to bootstrap the initial executable.

---

<div class="post-metadata">

### Author: ![friendlyanon](https://discourse.cmake.org/user_avatar/discourse.cmake.org/friendlyanon/32/970_2.png) [@friendlyanon](https://discourse.cmake.org/u/friendlyanon)
#### Post date: [September 18, 2023, 10:04pm UTC](https://discourse.cmake.org/t/bootstrap-ability-of-cmake/8999/4 "2023-09-18T22:04:42Z")

</div>

I find it inconvenient to require even MSYS on Windows personally. I think CMake should just be buildable with MSVC toolchain on its own.

> [@kyle.edwards](#):
>
> Anything that bootstraps CMake has to be able to spawn a new process

The bootstrap script does really simple and serial command running, sometimes capturing output. That’s a really small amount of platform specific code that would need to be implemented in the bootstrap C++ file.
