Build Systems

Spack defines a number of classes which understand how to use common build systems (Makefiles, CMake, etc.). Spack package definitions can inherit these classes in order to streamline their builds.

This guide provides information specific to each particular build system. It assumes that you’ve read the Packaging Guide and expands on these ideas for each distinct build system that Spack supports:

Make-based

For reference, the Build System API docs provide a list of build systems and methods/attributes that can be overridden. If you are curious about the implementation of a particular build system, you can view the source code by running:

$ spack edit --build-system autotools

This will open up the AutotoolsPackage definition in your favorite editor. In addition, if you are working with a less common build system like QMake, SCons, or Waf, it may be useful to see examples of other packages. You can quickly find examples by running:

$ cd var/spack/repos/builtin/packages
$ grep -l QMakePackage */package.py

You can then view these packages with spack edit.

This guide is intended to supplement the Build System API docs with examples of how to override commonly used methods. It also provides rules of thumb and suggestions for package developers who are unfamiliar with a particular build system.