When I talk to people about the CMake build system, they like the fact that it generates native project files for the tools you already use (which makes possible to use distributed compiling, debugging, etc). Next to that, Visual Studio and autotools users complain about bootstrapping not being possible.

If you are using Visual C++, solutions probably work fine for you and it is a fact they work out of the box with VC++. However, do not even try to move to another platform (Linux, Mac…) or another compiler on Windows because it will not work.

If you use autotools, you generate the configure script on your development machine and your users just run it to prepare makefiles. Only a Bourne-compatible shell is required when trying to build. Moving to Windows, particularly Visual C++ will be quite hard.

CMake is in my opinion one of the best build-systems out there but there is one problem: you need to have CMake in order to build a CMake-based project.

Now add third-party dependencies, which probably use a different build-system, to the mix and suddenly building your software has become time-consuming and complex. In terms of money, that translates to lost revenue because there is a high probability people evaluating your software will give up before they even have something to test.

Nokia solves this by distributing Qt binaries for the most popular compilers (MSVC2005, MSVC2008, MinGW). But there is always someone using a different compiler: MSVC2010, a different flavor of MinGW, Embarcadero C++ Builder

KDE on Windows solves this by having its own “meta-buildsystem” called emerge, which is written in Python, which adds a dependency on Python when you want to build.

Can’t we do better? Can we get all the advantages of CMake yet not depend on CMake being available?

Yes, we can. I tried to do that for Wt and implemented it in the form of winstng. It’s a small batch file for Windows and a Bash shell script (for Unix; I didn’t manage to remove one bashism) which automagically download, build (if needed) and install CMake, all the third-party dependencies, build them, and then download Wt and install it. Everything ends up in a self-contained location which you can move around*. And you do not need administrator permissions. Tested on Windows, Linux and Mac.

*For now that’s only true on Windows, on Unix platforms I have not removed the rpath for some libraries which use build systems other than CMake (namely, OpenSSL).

BTW, if you are at FOSDEM, there is a Wt talk on Sunday, 14.30-15.15: The next desktop is the browser.

5 Thoughts on “Bootstrap your CMake project

  1. Maybe for cmake (at least on Linux) it would be good enough to simply wget the binary package from cmake.org, untar it to any place you like, and use it from there ?
    I never had problems with the binary packages provided by Kitware, that’s also the purpose of these packages, they should just work on any Linux box.

    Alex

  2. Pingback: Tweets that mention Bootstrap your CMake project « elpauer -- Topsy.com

  3. @Alex

    The idea here is to be able to bootstrap on any platform, not only on Linux. Currently winstng works on Windows, Linux, Mac and FreeBSD (maybe more, but those are the ones I’ve tested).

    Sure, you could test for the platform (uname -s on Unix-like) and try to download prebuilt binaries but that requires correctly finding out the platform, and still building in case Kitware does not provide the binaries: Linux x64 (which is quite extended these days), FreeBSD, etc

  4. How can it be hard to require a cmake installation? If people cannot even do that, they should not even dare to install a compiler. Why do all developers think that users of their software are totally dumb? Hint: they are not. And installing cmake is nothing that they will have trouble with.
    As you said, autotools require a shell. But you always have to pollute the source tree (ever wondered about the .cvsignore and .gitignore) because they cannot do without. Building from VCS or a “prepared” version also differs. Many autotools projects cannot be correctly compiled out-of-source (sadly, that’s a fact). And I don’t need to say anything about the horrors of libtool and general GNU idiotism. Been there, done that, and please no more. Trying the fight of boot-strapping just means that you cannot let go of the GNUism of your past. Just do it, let go…

  5. You are my aspiration , I possess few web logs and rarely run out from to post .

Leave a Reply

Your email address will not be published. Required fields are marked *

 

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Post Navigation