如何使用vcpkg信息提供给CMake? [英] How to feed CMake with vcpkg information?

查看:165
本文介绍了如何使用vcpkg信息提供给CMake?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我已经使用 vcpkg 安装了一些库,并且该库有很多依赖关系(例如 cgal ).现在,我想使用 CMake 针对这些库编译一些程序.

Suppose I have installed some library with vcpkg and it's numerous dependencied (say cgal). Now I want to compile some program against these libraries with CMake.

我应该如何告诉 CMake 我已下载的所有库的所有位置?包括我已经安装的主库?我在 CMake 中只有一个设置,称为源目录",它将指向我的代码.库的设置在哪里?

How should I tell CMake about all locations of all libraries I have downloaded? Including main library I have installed? I have only one setting in CMake, called "source directory" which will point to my code. Where are settings for libraries?

D:\Users\ThirdPartyDesign\CGAL-5.0-examples\CGAL-5.0\examples\Triangulation_2
λ env | grep CMAKE
CMAKE_TOOLCHAIN_FILE=D:\Users\ThirdPartyDesign\vcpkg\scripts\buildsystems\vcpkg.cmake



D:\Users\ThirdPartyDesign\CGAL-5.0-examples\CGAL-5.0\examples\Triangulation_2
λ cmake .
CMake Warning at CMakeLists.txt:18 (find_package):
  By not providing "FindCGAL.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "CGAL", but
  CMake did not find one.

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

    CGALConfig.cmake
    cgal-config.cmake

  Add the installation prefix of "CGAL" to CMAKE_PREFIX_PATH or set
  "CGAL_DIR" to a directory containing one of the above files.  If "CGAL"
  provides a separate development package or SDK, be sure it has been
  installed.


-- This program requires the CGAL library, and will not be compiled.
-- Configuring done
-- Generating done
-- Build files have been written to: D:/Users/ThirdPartyDesign/CGAL-5.0-examples/CGAL-5.0/examples/Triangulation_2

推荐答案

通常您需要设置; CMAKE_TOOLCHAIN_FILE VCPKG_TARGET_TRIPLET .

VCPKG_TARGET_TRIPLET 设置为您正在使用的vcpkg三元组.默认值为 x86-windows

Set VCPKG_TARGET_TRIPLET to the vcpkg triplet that you are using. The default is x86-windows

设置 CMAKE_TOOLCHAIN_FILE 指向 path_to_vcpkg \ scripts \ buildsystems \ vcpkg.cmake

然后,您可以使用cmake函数(例如 find_package )查找所需的软件包.

Then you can use cmake functions such as find_package to find the required package.

请参见 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆