我正在尝试在我的项目上运行 cmake,该项目过去在 Mac 上运行得很好。
在我的 CMakeLists.txt 中,我有:
find_package(gtest 所需配置)
当我运行 cmake 时,我看到:
CMake Error at CMakeLists.txt:123 (find_package):
Could not find a package configuration file provided by "gtest" with any of
the following names:
gtestConfig.cmake
gtest-config.cmake
Add the installation prefix of "gtest" to CMAKE_PREFIX_PATH or set
"gtest_DIR" to a directory containing one of the above files. If "gtest"
provides a separate development package or SDK, be sure it has been
installed.
-- Configuring incomplete, errors occurred!
我已在 /usr/include/gtest
中构建了源代码并将其安装到 /usr/lib/
中。
最佳答案
调用时find_package
,包的名称区分大小写。与 GTest 相对应的包的正确名称是“GTest”。
大小写不正确的包名称有时可能会起作用(例如,使用不区分大小写的文件系统,或者如果包由 <lower-case-name>-config.cmake
文件描述)。但最好不要依赖这些功能,并使用其文档中注明的包名称。
关于ubuntu - cmake 在 ubuntu 18.10 中找不到 gtest 1.8,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54272250/