How to specify gcc flags (CXXFLAGS) particularly for a specific module?

a 夏天 提交于 2019-12-05 04:07:06

Although @drahnr's answer is correct for vanilla waf, it won't work with NS-3's build system, which is apparently what OP wants. To add CXXFLAGS to an NS-3 program, you can add them to the build object instead of in the configuration stage.

For example:

def build(bld):   
    obj = bld.create_ns3_program('my_app', ['core', 'other-dependencies'])
    obj.source = 'MyApplication.cpp'
    obj.cxxflags = ['-std=c++11']
drahnr

According to the waf book 1.7.8, section 10.1.1 and 10.1.2

    bld.shlib(source='main.c',
            target='myshlib',
            cflags       = ['-O2', '-Wall'], 
            cxxflags     = ['-O3', '-std=c++0x'],
            use          = 'myobjects')

    bld.objects(source='ip4.c',
            cflags       = ['-O2', '-Wall'], 
            cxxflags     = ['-std=somethingelse'],
            target       = 'myobjects')

Note #1 - this code is composed of the 2 examples provided in the wafbook and not tested at all.

Note #2 - you may need to make waf aware of 'myobjects' generated or they may not be used to build 'myshlib', as waf indexes all files before building.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!