mr-edd.co.uk :: horsing around with the C++ programming language

slam

Traditionally C++ software projects have been built using make or one of its variants. However more and more people are finding that make is simply inadequate for building non-trivial pieces of software.

Slam, an acronym for Slightly Less Awful Make, allows you to describe basic C++ builds in a platform- and compiler-agnostic way. It will handle header dependencies for you automatically and has good support for multiple build variants and parallel builds.

Recent activity

Code

Clone the repository using mercurial:

> hg clone http://bitbucket.org/edd/slam

Or get a zip file of the code.

Downloads

Quick start

To create a default slamfile:

> slam -ms
slam: running version 0.2.10
slam: default slamfile created

Let's see what's inside:

> cat slamfile

#------------------------------------
# Generated by slam. Edit as needed.
#------------------------------------

# Compiles all source files with the
# 'usual' C++ filename extensions.

sources : common : *.cpp *.cxx *.c *.C *.cc *.CC

defines : debug : DEBUG
defines : release : NDEBUG

flags : common : strict iso
flags : debug : debug optimize-off
flags : release : optimize


# Object files are linked to create an
# executable called app or app.exe on
# Windows.

target : common : app
type : common : executable


# The directory for the object files
# and executable depend on the toolset
# name and the build variant.

dir : common : obj/$(toolset)/$(variant)

The default slamfile will take all C++ source files, compile them in to object files and link them in to an application. You might run the slamfile as follows:

> slam toolset=gcc variant=debug

Further reading

Comments

Kory

[09/09/2008 at 06:15:00]

Great tool!

I was building my project with slam in a matter of minutes. I do have one question, however. Is it possible to change the output directory for the target? I can’t stand having my libs & executables in the build directory. I could probably adjust the toolset’s linker & librarian settings, but a directive would be ideal.

Again, nice work!

Edd

[10/09/2008 at 20:40:00]

Hi Kory.

Unfortunately, it isn't possible to separate the location of the object files from that of the library/executable.

slam is long overdue an update, actually, so perhaps in a little while I'll add that feature. Currently I don't have a Windows machine handy, so I can't do any cross-platform tests but in a few weeks I will.

(optional)
(optional)
(required, hint)

Links can be added like [this one -> http://www.mr-edd.co.uk], to my homepage.
Phrases and blocks of code can be enclosed in {{{triple braces}}}.
Any HTML markup will be escaped.