Link the static versions of the Boost libraries using CMake

前端 未结 2 1620
醉话见心
醉话见心 2021-01-30 13:44

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. Wha

2条回答
  •  爱一瞬间的悲伤
    2021-01-30 14:06

    Here is a full example of CMAKEFILE

    cmake_minimum_required(VERSION 3.15)
    project(your_project)
    set(Boost_USE_STATIC_LIBS   ON)
    find_package(Boost 1.70 COMPONENTS program_options REQUIRED)
    set(CMAKE_CXX_STANDARD 14)   
    add_executable(your_project main.cpp)
    target_link_libraries(rconpp Boost::program_options)
    

    references:

    cmake documents about BOOST

提交回复
热议问题