Could not find a package,configuration file provided by "G2O" ,G2OConfig.cmake,g2o-config.cmake

 因为项目需要使用到g2o,所以自己从git上面clone下来,

git clone https://github.com/RainerKuemmerle/g2o.git

然后:

cd g2o

mkdir build

cd build

cmake ..

make -j4

 编译完成,并在CMakeLists.txt使用g2o:

set(G2O_DIR ..)

find_package(….

但是后面报这个错误:

CMake Error at CMakeLists.txt:11(find_package):
By not providing “FindG2O.cmake” in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by “G2O”, but
CMake did not find one.

Could not find a package configuration file provided by “G2O” with any of
the following names:

G2OConfig.cmake
g2o-config.cmake

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

— Configuring incomplete, errors occurred!

 

其实是我链接的g2o错误了,应该这样:

LIST( APPEND CMAKE_MODULE_PATH /XXX/g2o/cmake_modules )
SET( G2O_ROOT /home/xxx/g2o )
FIND_PACKAGE( G2O REQUIRED )
然后就可以啦。
点赞