在生成和安装后,cmake find_package无法找到glfw [英] cmake find_package cannot locate glfw after build and install

查看:285
本文介绍了在生成和安装后,cmake find_package无法找到glfw的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用cmake的find_package函数来查找glfw3的安装,但我不确定我是否了解说明.我已经下载了glfw3,并按照说明进行了构建.

I'm trying to use cmake's find_package function to find the installation of glfw3 and I'm not quite sure I'm understanding the instructions. I've download glfw3 and followed the instructions for building.

下载src,移至根目录,然后运行 cmake ..

downloaded the src, went to the root, and ran cmake ..

然后,我在Visual Studio中打开主要解决方案 glfw.sln .我建立了解决方案,一切似乎都正常.我可以看到在何处创建了lib以及所有内容.在我自己的cmake项目中,当我使用 find_package(需要glfw3)时,我收到此错误:

Then I open the main solution glfw.sln in visual studio. I built the solution and everything seemed to build fine. I can see where the lib was created and everything. In my own cmake project, when I use find_package(glfw3 REQUIRED) I receive this error:

By not providing "Findglfw.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "glfw", but
CMake did not find one.

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

glfwConfig.cmake
glfw-config.cmake

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

给我的印象是,一旦我运行并安装了另一个cmake库(该库将包含在glfw3等其他项目中),它将在任何调用cmake的地方都可以找到glfw3config.cmake.有什么理由不发生这种情况吗?包含* config.cmake的文件夹通常在哪里?

I was under the impression that once I ran and installed another cmake library that it was to be included in other projects like glfw3, it would install a glfw3config.cmake somewhere where any call to cmake can find it. Is there a reason why that is not happening? Where is this folder that contains the *config.cmake normally located?

推荐答案

这可能是因为您构建了 gflw3 ,但没有执行与Windows/Visual Studio等效的 make install ,因此不会将工件部署到 cmake 知道要寻找的位置.

This is probably because you built gflw3 but didn't do the Windows/Visual Studio equivalent of make install so the artifacts are not deployed to a location which cmake knows to look for.

在调用 glfw3 cmake 时,应使用 -DCMAKE_INSTALL_PREFIX = 传递适当的目录,然后在 -DCMAKE_PREFIX_PATH =中引用它用于您自己的项目.基本上:

You should pass a suitable directory with -DCMAKE_INSTALL_PREFIX= when invoking cmake for glfw3 and then reference it in -DCMAKE_PREFIX_PATH= for your own project. Basically:

  1. gflw3 项目配置为在以下位置运行 cmake 时,使用 -DCMAKE_INSTALL_PREFIX = C:/Users/me/gflw3 将其输出工件安装到哪里.它.
  2. 构建 gflw3 &部署/安装.
  3. 告诉您自己的项目,以在运行 -DCMAKE_PREFIX_PATH = C:/Users/me/gflw3 在 C:/Users/me/gflw3 中查找内容> cmake .
  1. Configure your gflw3 project where to install its output artifacts with -DCMAKE_INSTALL_PREFIX=C:/Users/me/gflw3 when running cmake for it.
  2. Build gflw3 & deploy/install it.
  3. Tell your own project to look for things in C:/Users/me/gflw3 with -DCMAKE_PREFIX_PATH=C:/Users/me/gflw3 when running cmake for it.

这篇关于在生成和安装后,cmake find_package无法找到glfw的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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