cmake vs waf for C++ project
Asked Answered
C

2

12

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

Crispi answered 9/1, 2013 at 1:1 Comment(0)
G
16

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

Gujral answered 12/3, 2013 at 16:30 Comment(2)
No, it has no issue - I have managed to solve it and I've just added the solution to the topic :)Crispi
Additional I have found out that Waf is far more flexible than cmake and it is really easy to use. We have build on top of it our custom build system and it works great!Crispi
F
4

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.

Franciscafranciscan answered 9/1, 2013 at 3:28 Comment(1)
When we migrated to cmake; it was a pretty painful to learn. The documentation -- though improving --was confusion. The macro based language make reading cmake a nightmare (till you train your eyes) but all of it was worth it in the end. I haven't use waf but thinking of giving it a go for other projects. Its tempting since its python based.Nephro

© 2022 - 2024 — McMap. All rights reserved.