c++ 为库中的单个文件添加包含路径

vsdwdz23  于 2022-12-05  发布在  其他
关注(0)|答案(2)|浏览(123)

我正在构建一个库,其中 * 一个文件 * 需要一个额外的包含路径。有没有办法调整包含路径以编译单个文件?

bld(features="cxx cxxshlib",
         source=[so, many, files, from an ant_glob],
         includes=[Some path that's really only needed for one interface file])

我对基于use的解决方案也很满意。

hiz5n14c

hiz5n14c1#

我认为大多数解决方案将是更多行代码,而不仅仅是单独编译一个文件。

b4lqfgs4

b4lqfgs42#

您需要使用objects编译特定文件,然后使用use编译结果。
大概是这样的:

def build(bld):
    # build the specfifc object
    bld.objects(source="foo.cpp", includess="path/to/directory", target="foo")
    # build the library and include that object file using 'use='
    bld.stlib(source='bla.cpp blu.cpp', includes="this/path that/path", target='mylibrary', use='foo')

相关问题