6

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.

Amit Moscovich
  • 2,858
  • 1
  • 21
  • 12

1 Answers1

1

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')
neuro
  • 14,948
  • 3
  • 36
  • 59
pingul
  • 3,351
  • 3
  • 25
  • 43