How to know library variable names for CMakeLists?(如何知道 CMakeLists 的库变量名称?)
问题描述
当使用 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 的库变量名称?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何知道 CMakeLists 的库变量名称?
基础教程推荐
- 在 C++ 中循环遍历所有 Lua 全局变量 2021-01-01
- 管理共享内存应该分配多少内存?(助推) 2022-12-07
- 如何“在 Finder 中显示"或“在资源管理器中显 2021-01-01
- 如何使图像调整大小以在 Qt 中缩放? 2021-01-01
- 为什么语句不能出现在命名空间范围内? 2021-01-01
- 为 C/C++ 中的项目的 makefile 生成依赖项 2022-01-01
- 如何在不破坏 vtbl 的情况下做相当于 memset(this, ...) 的操作? 2022-01-01
- 使用从字符串中提取的参数调用函数 2022-01-01
- Windows Media Foundation 录制音频 2021-01-01
- 从 std::cin 读取密码 2021-01-01