Bootstrap-ability of CMake

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.

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.

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.

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

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.