簡體   English   中英

CMake 找不到升壓 Python

[英]CMake can not find Boost Python

我正在嘗試使用 CMake 3.17.5 構建 3d 派對應用程序。

我已經通過 vcpkg(在 Windows 上)安裝了 boost。 我檢查了 vcpkg 安裝了 boost-python。

我在 CMake GUI 中收到以下錯誤:

CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:164 (message):
  Could NOT find Boost (missing: python) (found version "1.75.0")
Call Stack (most recent call first):
  C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindPackageHandleStandardArgs.cmake:445 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files (x86)/CMake/share/cmake-3.17/Modules/FindBoost.cmake:2166 (find_package_handle_standard_args)
  cmake/modules/FindUSDMonolithic.cmake:71 (find_package)
  cmake/defaults/Packages.cmake:34 (find_package)
  CMakeLists.txt:11 (include)

我嘗試將 CMAKE_TOOLCHAIN_FILE 設置為 vcpkg.cmake 但它沒有幫助。

注意:在我將 Boost_INCLUDE_DIR 設置為 vcpkg/installed/x64-windows/include/ 后,CMake 確實找到了提升,但它仍然有這個奇怪的錯誤。 如果不設置這個變量 CMake 根本找不到提升,錯誤是不同的

您應該首先找到 Python:

find_package(Python3 REQUIRED COMPONENTS Development)
target_include_directories(MyTarget SYSTEM PRIVATE ${Python3_INCLUDE_DIRS})

find_package(Boost REQUIRED COMPONENTS python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})
target_link_libraries(MyTarget PRIVATE Boost::python${Python3_VERSION_MAJOR}${Python3_VERSION_MINOR})

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM