Find_package of cmake can not find boost

I have referred to this link and made a CMakeLists.txt with following data:

cmake_minimum_required(VERSION 2.8)
SET(TARGET integrity_scanner)
message("nBuilding ${TARGET}")
project (${TARGET})
if (UNIX)
    message(STATUS "Setting GCC flags")
    set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -g3 -Wall -O0")
else()
    message(STATUS "Setting MSVC flags")
    #set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /EHc-")
endif ()

include_directories ("${PROJECT_SOURCE_DIR}")

set(Boost_USE_STATIC_LIBS       ON)
set(Boost_USE_MULTITHREADED      ON)
set(Boost_USE_STATIC_RUNTIME    OFF)
set(BOOST_ROOT C:/boost_1_55_0_dyn)
find_package(Boost 1.55.0 COMPONENTS thread)

SET(SOURCE
  IntegrityScanner.cpp
)

SET(HEADERS
  IntegrityScanner.h ../BaseApplication.hpp
)

if(Boost_FOUND)
    add_definitions(-DDLL_EXPORTS)
    add_definitions(-DBOOST_ALL_DYN_LINK)

    include_directories("..\..\..\ext_library\zmq\zeromq-4.0.3\include")
    include_directories("..\..\..\ext_library\zmq\czmq\czmq-2.1.0\include")
    link_directories("..\..\..\ext_library\zmq\zeromq-4.0.3\lib\Win32\Debug")
    link_directories("..\..\..\ext_library\zmq\czmq\czmq-2.1.0\lib\Win32\DebugDLL")

    include_directories(${Boost_INCLUDE_DIRS})
    LINK_DIRECTORIES(${Boost_LIBRARY_DIRS})
    add_library(${TARGET} SHARED ${SOURCE} ${HEADERS})
    target_link_libraries(${TARGET} ${Boost_LIBRARIES} czmq libzmq)
else()
    message(STATUS "Boost_FOUND False")
endif()

Even though I have set BOOST_ROOT
, it fails and gives the Boost Found False
Message. What am I doing wrong here?

Edit: I have found that setting Boost_USE_STATIC_LIBS
to OFF
is resolving the issue. But I have to have it ON
. What could be wrong here?

Your directory structure needs to look like this:

c:/boost/boost_1_55_0

and BOOST_ROOT is an environment variable set to c:/boost

Hello, buddy!稿源:Hello, buddy! (源链) | 关于 | 阅读提示

本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 综合编程 » Find_package of cmake can not find boost

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录