Specify C++ compiler in waf
Asked Answered
R

1

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.

Recall answered 20/2, 2015 at 1:34 Comment(0)
S
2

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')
Subtlety answered 13/11, 2017 at 20:6 Comment(1)
I added a default compiler as the OP askedProber

© 2022 - 2024 — McMap. All rights reserved.