你如何添加Boost库中的CMakeLists.txt [英] How do you add boost libraries in CMakeLists.txt

查看:710
本文介绍了你如何添加Boost库中的CMakeLists.txt的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要Boost库添加到我的CMakeLists.txt。你怎么做还是怎么做增加吗?

I need to add boost libraries into my CMakeLists.txt. How do you do it or how do add it?

推荐答案

将这个在的CMakeLists.txt 文件(从关更改任何选项。如果你想)

Put this in your CMakeLists.txt file (change any options from OFF to ON if you want):

set(Boost_USE_STATIC_LIBS OFF) 
set(Boost_USE_MULTITHREADED ON)  
set(Boost_USE_STATIC_RUNTIME OFF) 
find_package(Boost 1.45.0 COMPONENTS *boost libraries here*) 

if(Boost_FOUND)
    include_directories(${Boost_INCLUDE_DIRS}) 
    add_executable(progname file1.cxx file2.cxx) 
    target_link_libraries(progname ${Boost_LIBRARIES})
endif()

显然,你需要把你想去的地方,我把 *提振这里* 库的库。例如,如果你使用文件系统正则表达式库,你会写:

Obviously you need to put the libraries you want where I put *boost libraries here*. For example, if you're using the filesystem and regex library you'd write:

find_package(Boost 1.45.0 COMPONENTS filesystem regex)

这篇关于你如何添加Boost库中的CMakeLists.txt的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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