【问题标题】:vcpkg cmake does not find botanvcpkg cmake 找不到植物
【发布时间】:2019-02-04 11:29:58
【问题描述】:

我使用 vcpkg 作为我的包管理器,按照示例使用 sqlite 构建 example 非常容易。

之后我成功安装了botan并尝试使用 find_package(botan REQUIRED) 如示例 here 所示。 但是不幸的是,这不起作用,并且生成退出并出现错误

CMake Error at vcpkg/scripts/buildsystems/vcpkg.cmake:247 (_find_package):
  By not providing "Findbotan.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "botan", but
  CMake did not find one.

  Could not find a package configuration file provided by "botan" with any of
  the following names:

    botanConfig.cmake
    botan-config.cmake

  Add the installation prefix of "botan" to CMAKE_PREFIX_PATH or set
  "botan_DIR" to a directory containing one of the above files.  If "botan"
  provides a separate development package or SDK, be sure it has been
  installed.
Call Stack (most recent call first):
  CMakeLists.txt:4 (find_package

CMakeLists.txt 如下所示

cmake_minimum_required(VERSION 3.0)
project(botanTest)

find_package(botan REQUIRED)

add_executable(main main.cpp)
target_link_libraries(main botan)

有没有办法使用 cmake 和 vcpkg 构建依赖于 botan 的应用程序?如果不是cmake,如何将botan用作vcpkg包?硬编码位置不是一个可行的解决方案。

感谢四位的帮助。

【问题讨论】:

  • 使用 powershell 和 vcpkg 安装 botan,无需 cmake。 IDE是VC2017?
  • @seccpur 如果可能的话,我想使用 CMake 来在不同的平台上编译它。我安装了botan,但是CMake没有找到它。
  • vcpkg 现在可以安装 botan,但 find_package(botan REQUIRED) 仍然失败并出现同样的错误

标签: c++ cmake botan vcpkg


【解决方案1】:

vcpkg 不为构建和安装的 Botan 提供配置文件。

您要么必须在 CMake 项目中直接使用 find_path() 和 find_library(),要么编写一个 FindBotan.cmake 文件,该文件将通过 find_package() 调用找到。在这个 FindBotan.cmake 中,您仍然需要使用 find_path() 和 find_library() 以及 Find 模块中出现的其他一些常用样板。

如果你在互联网上搜索,你已经可以找到一些版本的 FindBotan.cmake,但没有一个是官方的。

【讨论】: