Код: Выделить всё
[requires]
boost/1.86.0
[generators]
CMakeDeps
CMakeToolchain
[options]
boost/*:shared=True
boost/*:magic_autolink=False
boost/*:fPIC=True
boost/*:multithreading=True
boost/*:system_use_utf8=True
Далее в моем CMakeLists.txt:
Код: Выделить всё
# add to CMAKE_PREFIX_PATH the "conancmake" generated directory
list(PREPEND CMAKE_PREFIX_PATH ${CONAN_CMAKE_OUTPUT_DIR})
if(WIN32)
# disable autolink as conan builds without "autolink-special naming"
# regardless to "magic_autolink" is True or False
add_definitions(-DBOOST_ALL_NO_LIB)
endif()
# if I try to use "COMPONENTS filesystem", CMake says it doesn't find it
# also conan docs doesn't specify it explicitly (weather it is correct or not)
find_package(Boost REQUIRED)
# adding all the files to build shared library
add_library(MyDLL SHARED ${mydll_src})
# I verified that Boost_INCLUDE_DIRS is set correctly and it does point
# to the include dir in conan repository
target_include_directories(MyDLL PRIVATE ${Boost_INCLUDE_DIRS})
# Based on the docs, I'm linking using boost::boost.
# I have also tried Boost::filesystem (which is set) and it doesn't work
target_link_libraries(MyDLL PRIVATE boost::boost)
# to set dependencies, I have made sure "boost_Boost_filesystem_DEPS_TARGET" is set
add_dependencies(MyDLL boost_Boost_filesystem_DEPS_TARGET)
Код: Выделить всё
error LNK2019: unresolved external symbol "void __cdecl boost::filesystem::detail::path_traits::convert(char const *,char const *,class std::basic_string &,class std::codecvt const *)" (?convert@path_traits@detail@filesystem@boost@@YAXPEBD0AEAV?$basic_string@_WU?$char_traits@_W@std@@V?$allocator@_W@2@@std@@PEBV?$codecvt@_WDU_Mbstatet@@@6@@Z) referenced in function "public: void __cdecl boost::filesystem::path::assign_op::operator()(char const *,char const *,class std::codecvt const *)const " (??$?RD@assign_op@path@filesystem@boost@@QEBAXPEBD0PEBV?$codecvt@_WDU_Mbstatet@@@std@@@Z)
Код: Выделить всё
target_link_directories(MyDLL PRIVATE ${boost_LIB_DIRS_RELEASE})
target_link_libraries(MyDLL PRIVATE "boost_filesystem.lib")
Подробнее здесь: https://stackoverflow.com/questions/791 ... -correctly