13

After using Scala's Simple Build Tool (SBT) and loving it, I'm working on a C++ project that makes extensive use of CMake. The CMake files are quite complicated, and it's painful to modify them, or to even understand them. In contrast, I've found SBT configs for even large projects to be readable, I think due to static typing and immutability.

Are there any efforts to bring SBT-style goodness to C++?

YSC
  • 38,212
  • 9
  • 96
  • 149
emchristiansen
  • 3,550
  • 3
  • 26
  • 40
  • 1
    related http://stackoverflow.com/questions/1581250/maven-like-build-tool-for-c – om-nom-nom Sep 12 '12 at 22:51
  • What does it mean for a build system to be typesafe? You're looking for something that detects ODR violations? Have a look at Microsoft [`detect_mismatch` pragma](http://msdn.microsoft.com/en-us/library/ee956429.aspx) and the `/d1reportSingleClassLayoutXXX` compiler switch – Ben Voigt Sep 13 '12 at 02:39
  • 2
    @BenVoigt In SBT, you write your build files in Scala. Thus the build file are compiled and inconsistencies due to type errors or code constraints (through implicits for instance) are detected. In contrast, SCons (for instance) uses a dynamic languages and errors are reported only when the buggy declarations are evaluated. – paradigmatic Sep 13 '12 at 07:03
  • If you like SBT then I see nothing stopping you from using SBT with command line compiler steps. So you would have a set of SBT statements that would be used to generate a compiler command line with the appropriate arguments and then execute the compiler command line. This is what any of the various versions of make as well as Ant and other types of scripting languages used for build tools do. As far as I know, SBT would just be another platform to use in creating the compiler command lines and executing them. – Richard Chambers Sep 15 '12 at 03:03
  • If to look at http://en.wikipedia.org/wiki/List_of_build_automation_software there are endless ongoing efforts to make cosmic amounts of build tools for any taste. Lot of things can build C++. SBT seems to be "racist" (builds only Scala and Java). So what is your question again? – Öö Tiib Sep 15 '12 at 17:54
  • @RichardChambers, it does indeed appear SBT could be extended to handle C++. However, there was no mention of existing efforts. See this related question I posted to the SBT mailing list: https://groups.google.com/d/msg/simple-build-tool/xcwTZUvVJdo/27fyIWnlZ2oJ – emchristiansen Sep 16 '12 at 01:30
  • @ÖöTiib, I'm looking for specific features: type safety and (ideally) immutability. – emchristiansen Sep 16 '12 at 01:36
  • There are many build tools that can handle C++ and using an IDE like Eclipse CDT often generate make files for your, when you've set up your projects right. For complex multi-platform systems you might consider SCons and SConsolidator (http://sconsolidator.com ) if you use it with Eclipse CDT. SConsolidator was built by one of my stutents. – PeterSom Sep 16 '12 at 09:26
  • Actually SBT isn't type safe. There're a lot of possible errors which aren't detected at runtime. For example you can mention incorrect version of a dependency. – Konstantin Solomatov Sep 18 '12 at 18:15
  • @PeterSom, it looks like SCons is written in Python, so I'm guessing there's not a lot of type safety there. Correct me if I'm wrong. – emchristiansen Sep 20 '12 at 23:02
  • @KonstantinSolomatov, type safety is a continuum. For example, SBT is much more type safe than CMake. – emchristiansen Sep 20 '12 at 23:04

2 Answers2

5

With SCons you have the type safety of Python - therefore just a dynamic, run-time type safety. Anything else is dependent on your IDE (i.e., static code analysis). Therefore, I think SBT has its advantages because you have Scala's compile-time type safety.

But for C/C++ I think SCons is much better suited (I'm the author of SConsolidator - so I might be biased). It has built-in scanners to detect include dependencies and builders to generate object files, static and shared libraries - all things which SBT does not have at the moment - at least as far as I know.

Michael Rueegg
  • 765
  • 4
  • 13
  • Versus CMake, where it appears everything is a string, the run time type safety of Python is indeed superior. However, I'm interested in _static_ type safety, such as one gets from SBT. For this reason I cannot accept this answer (though I did +1 it). – emchristiansen Sep 29 '12 at 15:47
  • I extensively used [Waf](http://code.google.com/p/waf/), another Python based build system shipped with [NS-3](http://www.nsnam.org/) some time ago, and it was everything except "safe". I've experienced a wide range of linking and runtime problems because of it. Whenever a major modification to the structure of classes was in progress, the best option was always to launch a `./waf clean` to "avoid problems". – Avio Oct 09 '12 at 12:08
0

I am working with boost for a long time and I love it so much, so maybe I am exaggerating this, but you should see boost.build it's very easy and work with for really large projects (like boost itself).

fncomp
  • 6,040
  • 3
  • 33
  • 42
BigBoss
  • 6,904
  • 2
  • 23
  • 38
  • Can you, please, add information on how it does enforce type-safety? I've quickly skeemed through the docs, and haven't found an answer. – om-nom-nom Oct 09 '12 at 20:08