cmake 在 ubuntu 18.10 中找不到 gtest 1.8

cmake can't find gtest 1.8 in ubuntu 18.10

我正在尝试 运行 cmake 我曾经在 Mac.

上运行良好的项目

在我的 CMakeLists.txt 我有:

find_package(gtest REQUIRED CONFIG)

当我 运行 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 文件描述)。但最好不要依赖这些功能,并使用其文档中注明的包名称。