0

我正在尝试从 cmake 项目创建一个 eclipse 项目。我使用了以下命令

cmake -G "Eclipse CDT4 - Unix Makefiles" ./`

它给出了以下错误

CMake Error at CMakeLists.txt:119 (find_package):
  By not providing "FindGlib.cmake" in CMAKE_MODULE_PATH this project has
  asked CMake to find a package configuration file provided by "Glib", but
  CMake did not find one.

  Could not find a package configuration file provided by "Glib" (requested
  version 2.28) with any of the following names:

    GlibConfig.cmake
    glib-config.cmake

  Add the installation prefix of "Glib" to CMAKE_PREFIX_PATH or set
  "Glib_DIR" to a directory containing one of the above files.  If "Glib"
  provides a separate development package or SDK, be sure it has been
  installed.


-- Configuring incomplete, errors occurred!

我已经安装了 glib。实际上它无法解决我猜的路径。在 cmake 文件中的任何地方 find ,它都会给出微笑错误。请我建议一个出路,我非常需要在cmake中加载这个项目。谢谢。

这是错误消息指向的第 119 行

    find_package(Glib 2.28 REQUIRED)
include_directories(${Glib_INCLUDE_DIRS})
list(APPEND LIBS ${Glib_LIBRARIES})
add_definitions(${Glib_DEFINITIONS})
4

1 回答 1

0

当您调用find_package(MyPackage)CMake 文件时,它会尝试FindMyPackage.cmake在其系统路径(/usr/share/cmake-2.8/Modules在我的 Ubuntu 机器上)或您指定为的目录中查找配置CMAKE_MODULE_PATH

您的问题的解决方案是在源代码树中为模块创建一个目录(例如CMakeModules),在其中放入一个FindGlib.cmake您可以使用 Google 找到的文件,然后添加

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)

在你CMakeLists.txt实际调用之前find_package

(您的问题与 Eclipse 生成器无关,您可以将其从问题的标题中删除)。

于 2013-04-30T05:46:34.230 回答