I know this is another question like "where is my boost???, but it is still not clear for me... I'm newbie at Boost and Cmake. I'm trying to build simple demo from Boost tutorial (serialization lib required) with Cmake using this script:
cmake_minimum_required(VERSION 2.8)
project(serialization)
add_executable(serializer main.cpp)
set(BOOST_ROOT "C:/Dev/Source/boost/boost_1_73_0")
set(BOOST_INCLUDEDIR "C:/Dev/Source/boost/boost_1_73_0")
set(BOOST_LIBRARYDIR "C:/Dev/Source/boost/boost_1_73_0/stage/lib")
set(Boost_USE_STATIC_LIBS ON)
set(Boost_USE_MULTITHREADED ON)
set(Boost_DEBUG 1)
find_package(Boost 1.73.0 REQUIRED COMPONENTS serialization)
if(Boost_FOUND)
include_directories(${Boost_INCLUDE_DIRS})
target_link_libraries(serializer ${Boost_LIBRARIES})
endif()
Cmake output looks like:
[build] -- [ C:/Dev/Source/...cmake:1489 ] Boost_USE_STATIC_LIBS = "ON"
...
[build] -- [ C:/Dev/Source/...cmake:1524 ] BOOST_ROOT = "C:/Dev/Source/boost/boost_1_73_0"
[build] -- [ C:/Dev/Source/...cmake:1525 ] ENV{BOOST_ROOT} = <unset>
...
[build] -- [ C:/Dev/Source/...cmake:1526 ] BOOST_INCLUDEDIR = "C:/Dev/Source/boost/boost_1_73_0"
[build] -- [ C:/Dev/Source/...cmake:1526 ] ENV{BOOST_INCLUDEDIR} = <unset>
...
[build] -- [ C:/Dev/Source/...cmake:1528 ] BOOST_LIBRARYDIR = "C:/Dev/Source/boost/boost_1_73_0/stage/lib"
[build] -- [ C:/Dev/Source/...cmake:1529 ] ENV{BOOST_LIBRARYDIR} = <unset>
...
[build] -- [ C:/Dev/Source/...cmake:2045 ] Searching for SERIALIZATION_LIBRARY_RELEASE: libboost_serialization-mgw8-mt-1_73;...;libboost_serialization-mt-s
[build] -- [ C:/Dev/Source/...cmake:2100 ] Searching for SERIALIZATION_LIBRARY_DEBUG: libboost_serialization-mgw8-mt-d-1_73;...;libboost_serialization-mt-s-d
...
[build] CMake Error at C:/Dev/Source/...cmake:164 (message):
[build] Could NOT find Boost (missing: serialization) (found suitable version
[build] "1.73.0", minimum required is "1.73.0")
so it seems like Cmake can find required libraries but something goes wrong. And if I don't specify COMPONENTS
explicitly, Cmake finds Boost but build process fails with many undefined reference to boost::...
errors. So is there a way to fix these problems?