我正在尝试从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文件中找到的地方,它给出了smiler错误。请我建议一个出路,我非常需要在cmake中加载这个项目。感谢。
这是第119行,其中错误消息指向
find_package(Glib 2.28 REQUIRED)
include_directories(${Glib_INCLUDE_DIRS})
list(APPEND LIBS ${Glib_LIBRARIES})
add_definitions(${Glib_DEFINITIONS})
答案 0 :(得分:0)
当您在CMake文件中调用find_package(MyPackage)
时,它会尝试在其系统路径(我的Ubuntu框中为FindMyPackage.cmake
)或您指定的目录中找到/usr/share/cmake-2.8/Modules
配置作为CMAKE_MODULE_PATH
)。
您的问题的解决方案是为源树中的模块创建一个目录(例如CMakeModules
),将一个FindGlib.cmake
文件放入其中,您可以使用Google找到该文件,然后添加
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/CMakeModules)
在实际致电CMakeLists.txt
之前,在find_package
中。
(您的问题与Eclipse生成器无关,您可以从问题标题中删除它。)