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 的库变量名称?


基础教程推荐
- 常量变量在标题中不起作用 2021-01-01
- 我有静态或动态 boost 库吗? 2021-01-01
- 如何在 C++ 中初始化静态常量成员? 2022-01-01
- 在 C++ 中计算滚动/移动平均值 2021-01-01
- 这个宏可以转换成函数吗? 2022-01-01
- 如何将 std::pair 的排序 std::list 转换为 std::map 2022-01-01
- 如何通过C程序打开命令提示符Cmd 2022-12-09
- 如何检查GTK+3.0中的小部件类型? 2022-11-30
- C++结构和函数声明。为什么它不能编译? 2022-11-07
- 静态库、静态链接动态库和动态链接动态库的 .lib 文件里面是什么? 2021-01-01