如何在CMakeLists.txt中添加Boost库? [英] How do you add Boost libraries in CMakeLists.txt?
本文介绍了如何在CMakeLists.txt中添加Boost库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要将Boost库添加到我的CMakeLists.txt中.您如何做或如何添加?
I need to add Boost libraries into my CMakeLists.txt. How do you do it or how do you add it?
推荐答案
将其放在您的CMakeLists.txt
文件中(如果需要,可以将任何选项从OFF更改为ON):
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()
很显然,您需要将所需的库放在我放置*boost libraries here*
的位置.例如,如果您使用filesystem
和regex
库,则应编写:
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)
这篇关于如何在CMakeLists.txt中添加Boost库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文