使用CMake链接Boost库的静态版本 [英] Link the static versions of the Boost libraries using CMake

查看:256
本文介绍了使用CMake链接Boost库的静态版本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在/usr/lib中拥有了boost库的静态和动态版本.现在,我希望CMake在可执行文件链接期间更喜欢静态版本.我该怎么办?

I've got both the static and the dynamic versions of the boost libraries in /usr/lib. Now I'd like CMake to prefer the static versions during the linkage of my executable. What can I do?

推荐答案

在您的CMakeLists.txt文件中:

set(Boost_USE_STATIC_LIBS   ON)
find_package(Boost REQUIRED ...)

在我有...的位置,您可以选择放置要使用的库的名称,然后在下面放置target_link_libraries(targetname ${Boost_LIBRARIES}).如果您有较新的CMake发行版,则应完全按照广告宣传的方式运行.我正是在自己的项目中以这种方式进行操作.

Where I have ..., you optionally put the names of the libraries you want to use, and then target_link_libraries(targetname ${Boost_LIBRARIES}) later below. If you have a fairly recent distribution of CMake, it should work exactly as advertised. I do it exactly this way in my own projects.

这篇关于使用CMake链接Boost库的静态版本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆