2013-04-29 97 views
0

我想从cmake项目创建一个eclipse项目。 我用下面的命令cmake到日食的转换问题

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! 

我有巧舌如簧的安装。实际上它无法解决我猜测的路径。无论在哪里找到cmake文件,它都会给出smiler错误。请我建议一个出路,我非常需要在cmake中加载这个项目。谢谢。

这里是线119,即,错误消息指向

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

回答

0

当你在CMake的文件中调用find_package(MyPackage),它试图找到它的系统路径FindMyPackage.cmake配置(/usr/share/cmake-2.8/Modules在我的Ubuntu盒),或在您确定的目录为CMAKE_MODULE_PATH)。

到您问题的解决方法是在你的源代码树创建模块的目录(如CMakeModules),放在它FindGlib.cmake文件,你可以找到使用谷歌,并在您CMakeLists.txt添加

set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules) 

在实际致电find_package之前。 (您的问题与Eclipse生成器无关,您可以从问题的标题中删除该问题)。