When building C++ code using the waf build system, can I choose a specific C++ compiler command?
While it is possible to run something like "CXX=g++-4.9 waf configure", or to get the same effect by setting os.environ['CXX'] in the wscript file, is there a 'proper' way of doing this?
i.e. What is the waf equivalent of setting the CXX variable in a Makefile.
Waf is a Python-based framework for configuring, compiling and installing applications. Here are perhaps the most important features of Waf: Automatic build order: the build order is computed from input and output files, among others. Automatic dependencies: tasks to execute are detected by hashing files and commands.
It's a little bit odd how little documentation I've found on this topic. I made do by setting the environment variable in the configure
function, as you mention in your question.
Here's a small example for the curious:
import os
def options(opt):
opt.load('wak.tools')
opt.load('compiler_cxx')
def configure(conf):
conf.load('wak.tools')
conf.env.CXX = "g++-4.9" # default compiler
if os.environ['CXX']: # Pull in the compiler
conf.env.CXX = os.environ['CXX'] # override default
# Additional setup of variables
conf.load('compiler_cxx') # Will use the compiler from the environment path
def build(bld):
bld.program(
target='test',
includes='include',
source='src/main.cpp')
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With