cmake链接boost

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# boost
if(MSVC)
# vs会自动链接
else()
link_directories("/usr/locate/boost") # BOOST 安装位置
find_package(Boost COMPONENTS json system filesystem program_options locale json REQUIRED)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
MESSAGE( STATUS "Boost_INCLUDE_DIRS = ${Boost_INCLUDE_DIRS}.")
MESSAGE( STATUS "Boost_LIBRARIES = ${Boost_LIBRARIES}.")
MESSAGE( STATUS "Boost_LIB_VERSION = ${Boost_LIB_VERSION}.")
target_link_libraries (${PROJECT_NAME} PRIVATE ${Boost_LIBRARIES})
endif()
endif()