Finding local external libraries with Waf

拥有回忆 提交于 2019-12-04 19:15:45
Matt Clarkson

There is read_shlib and read_stlib that you can use.

You could possibly use it like so:

bld.read_shlib('opengl32', paths='external/blah')

The solution that I've found and am currently using is to do:

cfg.env.LIBPATH.append(os.path.join(os.getcwd(), "external_lib_dir")
cfg.env.INCLUDES.append(os.path.join(os.getcwd(), "external_includes_dir")

and then, searching for a library can be as simple as:

# OpenGL
if not cfg.check_cxx(uselib_store='GL', uselib='CORE TEST', mandatory=False, lib='GL'):
    cfg.check_cxx(uselib_store='GL', uselib='CORE TEST', mandatory=True, lib='opengl32')

The first line will do a check that works on most linux systems, set as non-mandatory so that it doesnt fail, and the second line will do a check that works on windows, set as mandatory so that both failing causes a configuration failure.

This way works pretty well for me, and can be made a bit more robust if necessary (adding detection for osx frameworks or something like that), but if anyone knows of an even better way, let me know!

EDIT: Obviously, you probably won't be keeping OpenGL in a directory local to your project, but changing it to work with other libraries isn't too bad.

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