如何正确构建 SOCI 库?

How do I build the SOCI library without errors?

我在构建 SOCI 库时遇到困难。

相关软件:

相关路径:

构建 SOCI 的命令是 cmake -DCMAKE_BUILD_TYPE=Debut -DSOCI_CXX11=ON -DSOCI_SHARED=ON -DWITH_BOOST=ON -DWITH_MYSQL=ON ..

这是修改后的 Boost.cmake 文件,位于 %SOCI%\cmake\dependencies\。以 ## 开头的评论解释了更改。

## commented
#set(Boost_FIND_QUIETLY TRUE)

set(Boost_USE_MULTITHREADED ON)
## commented
#find_package(Boost 1.33.1 COMPONENTS date_time)

## BEGIN inserted
set(CMAKE_INCLUDE_PATH ${CMAKE_INCLUDE_PATH} "E:/cpp/Lib/boost/boost_1_73_0")
message(STATUS "<< set CMAKE_INCLUDE_PATH >> " ${CMAKE_INCLUDE_PATH})

set(BOOST_ROOT E:/cpp/Lib/boost/boost_1_73_0)
message(STATUS "<< set BOOST_ROOT >> " ${BOOST_ROOT})

message(STATUS "<< FIND_PACKAGE >>")
FIND_PACKAGE(Boost)

message(STATUS "<< FIND_PACKAGE COMPONENTS >>")
FIND_PACKAGE(Boost COMPONENTS date_time)

message(STATUS "<< Boost_FOUND >> " ${Boost_FOUND})

message(STATUS "<< Boost_DATE_TIME_FOUND >> " ${Boost_DATE_TIME_FOUND})
## END inserted

## commented
#if (NOT Boost_DATE_TIME_FOUND)
#  find_package(Boost 1.33.1)
#endif()

set(Boost_RELEASE_VERSION
  "${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")

boost_external_report(Boost RELEASE_VERSION INCLUDE_DIR LIBRARIES)

这是相关的输出。完整输出可用 here.

-- Boost:
-- << set CMAKE_INCLUDE_PATH >> E:/cpp/Lib/boost/boost_1_73_0
-- << set BOOST_ROOT >> E:/cpp/Lib/boost/boost_1_73_0
-- << FIND_PACKAGE >>
-- << FIND_PACKAGE COMPONENTS >>
CMake Warning at E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1161 (message):
  New Boost version may have incorrect or missing dependencies and imported
  targets
Call Stack (most recent call first):
  E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1283 (_Boost_COMPONENT_DEPENDENCIES)
  E:/Apps/CMake/share/cmake-3.16/Modules/FindBoost.cmake:1921 (_Boost_MISSING_DEPENDENCIES)
  cmake/dependencies/Boost.cmake:18 (FIND_PACKAGE)
  cmake/SociDependencies.cmake:79 (include)
  CMakeLists.txt:83 (include)


-- Could NOT find Boost (missing: date_time) (found version "1.73.0")
-- << Boost_FOUND >> FALSE
-- << Boost_DATE_TIME_FOUND >> 0
-- WARNING: Boost libraries not found, some features will be disabled.

执行 msbuild.exe SOCI.sln 产生可用输出 here

谁能告诉我为什么 SOCI 无法正确构建?为什么它找不到 date_time 组件,而它肯定存在?

事实证明,我遇到的大部分错误都来自包含的单元测试。为什么?我不知道。但是,如果我忽略错误并继续,一切似乎都正常。