如何知道 CMakeLists 的库变量名称?

How to know library variable names for CMakeLists?(如何知道 CMakeLists 的库变量名称?)
本文介绍了如何知道 CMakeLists 的库变量名称?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

当使用 CMakeLists 编译 OpenGL 项目时,我有以下行来链接 glut 和 gl:

When using CMakeLists to compile an OpenGL project, I have the following line to link glut and gl:

target_link_libraries(my_exe ${OPENGL_gl_LIBRARY} ${GLUT_LIBRARIES})

我查找了如何将 glut 和 gl 与 CMake 联系起来,所以我发现我可以使用 ${OPENGL_gl_LIBRARY} 和 ${GLUT_LIBRARIES}.但是我怎么知道要使用的变量呢?我习惯于只执行 ${THELIBRARY_LIBRARES},但在 gl 的情况下,它更改为将gl"添加到变量名称中.如果不使用谷歌搜索(对于我想使用的任何库),我怎么知道呢?

I looked up how to link glut and gl with CMake so I saw that I could use ${OPENGL_gl_LIBRARY} and ${GLUT_LIBRARIES}. But how would I know the variables to use otherwise? I am used to just doing ${THELIBRARY_LIBRARES}, but in the case of gl, it changed to adding that "gl" into the variable name. How would I know that without googling it (for any library I want to use)?

推荐答案

那些变量是通过 find_package(XXX) 调用获得的.

Those variables are obtained via find_package(XXX) calls.

此类调用被重定向,依赖于库,要么到 FindXXX.cmake 脚本(随 CMake 提供或包含在使用它的项目中)或 XXXConfig.cmake 脚本(与库本身一起提供).

Such calls are redirected, depended from the library, either to FindXXX.cmake script (shipped with CMake or contained in the project which uses it) or to XXXConfig.cmake script (shipped with the library itself).

因此,要确定有意义的变量名称,您需要查阅适当的脚本.通常,脚本的接口(输入-输出变量)在脚本开头的注释中描述.

So, for determine meaningful variable's names you need to consult appropriate script. Usually, interface of the script (input-output variables) is described in comments at the beginning of the script.

CMake 附带的 FindXXX.cmake 脚本的文档可以在 关于模块的 CMake 文档页面.

Documentation for FindXXX.cmake scripts shipped with CMake may be read in CMake documentation pages about modules.

这篇关于如何知道 CMakeLists 的库变量名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

OpenGL transforming objects with multiple rotations of Different axis(OpenGL 变换不同轴多次旋转的对象)
GLFW first responder error(GLFW 第一响应者错误)
SOIL not linking correctly(SOIL 连接不正确)
Core profile vs version string? Only getting GLSL 1.3/OGL 3.0 in mesa 10.0.1(核心配置文件与版本字符串?在 mesa 10.0.1 中只获得 GLSL 1.3/OGL 3.0)
What is the range of OpenGL texture ID?(OpenGL 纹理 ID 的范围是多少?)
How taxing are OpenGL glDrawElements() calls compared to basic logic code?(与基本逻辑代码相比,OpenGL glDrawElements() 调用的繁重程度如何?)