Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cmake vs waf for C++ project

I found similar topic: What are the differences between Autotools, Cmake and Scons? , but my question is a little bit other and I think the answers could be other too.

I found a lot of articles telling that waf is unstalbe (API changes), is not yet ready for production etc (but all of these articles are 2 or 3 years old).

Which of these build tools should be used if I want to:

  • create big C++ (11) project - lets say a complex compiler
  • use with LLVM
  • be sure it will be flexible and simple to use
  • be sure it will be fast enought
  • compile under all standard platforms (the base platform is Linux, but I want to compile under Windows and MacOSX also)

Reading a lot of articles I found out Cmake and waf the "best" tools available, but I have no expirence with them and it is really hard to find out any comparison, which is not very biased (like comparison of the scons author) and not very old.really

like image 270
Wojciech Danilo Avatar asked Jan 09 '13 01:01

Wojciech Danilo


2 Answers

waf covers nearly all your requirements ...

  • API change: not a problem as waf shall be included in the source tarball (<100Ko)

  • big project: you can split your configuration in subdirectories (the contexts could be inherited). I've worked on projects with more than 10k files in C/C++/fortran77/fortran90/python/Cython including documentation in doxygen/sphinx.

  • flexibility and easyness: you can add extra modules en python (http://code.google.com/p/waf/wiki/AddingNewToolsToWaf)

  • fast: the tasks could be run in parallel: http://www.retropaganda.info/~bohan/work/psycle/branches/bohan/wonderbuild/benchmarks/time.xml

  • multi plat-form: you can run Waf everywhere python is available, that includes Windows and MacOs. Waf is compatible with mscvc, gcc, icc, and other compilers. You can produce visual/eclipse projects.

... but waf seems to have an issue with llvm: http://code.google.com/p/waf/issues/detail?id=1252

EDIT: as said by Wojciech Danilo, LLVM issue has been fixed

like image 121
alain Avatar answered Oct 22 '22 09:10

alain


I'm currently using CMake for my own language implementation via C++11 and LLVM.

I like CMake for it's easy to use syntax. LLVM can be loaded with an easy 'load_package' command. After that you can use all the headers and libraries you need. CMake lets child scripts inherit variables from parent scripts. So you do not need to set variables and load packages in every sub directory.

The C++11 support depends on your compiler you want to use. All in all CMake is just a layout to create your 'real' build script.

When you're using make you can use make's --jobs=N to speed up compilation on multicore-platforms. On Windows you could generate Visual Studio 2012-project files and use Microsoft's build system and use their build-jobs to speed up the compilation process. You should always create a subfolder for build-files (myproject/build or something). This way you keep your source tree clean (cd build; cmake ..; cd ..).

I can't speak for all the other tools out there.

like image 20
bash0r Avatar answered Oct 22 '22 09:10

bash0r