7

I installed Ogre3D 1.8.1 (the source package) on Ubuntu 12.04 and everything went fine (I managed to run some samples on the Ogre interface). However, I hit a problem while I was compiling an external project (that one) that needed the OpenCV, ArUco and Ogre librarys. When I run the CMake of the project, I receive the following:

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

Could not find a package configuration file provided by "OGRE" with any of
the following names:

OGREConfig.cmake
ogre-config.cmake

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


-- Configuring incomplete, errors occurred!

I know where the FindOGRE.cmake is, it's in the /usr/local/lib/OGRE/cmake, but I don't know how to say to CMake to look for that folder and fix this problem.

4 Answers4

6

You just need to use the -D command line option along with the CMAKE_MODULE_PATH variable:

cmake . -DCMAKE_MODULE_PATH=/usr/local/lib/OGRE/cmake
Fraser
  • 74,704
  • 20
  • 238
  • 215
  • I tried the -D command, as you said, but I still hit the same problem. I also tried use the CMake-gui. I filled the CMAKE_INSTALL_PREFIX with the /usr/local/lib/OGRE/cmake path, and the OGRE_DIR with the ogre installation folder. Is that right? Even so, occurs the same error. – WevertonApolinário Apr 13 '13 at 22:45
  • Well, the `CMAKE_INSTALL_PREFIX` is where you will install your current project to if you do `make install`, so it's not really relevant here. `CMAKE_MODULE_PATH` is a list of directories where CMake checks for "FindXXX.cmake" files when you use `find_package`. Finally, setting `OGRE_DIR` (or `CMAKE_PREFIX_PATH`) to the ogre installation dir would need a file called OGREConfig.cmake or ogre-config.cmake to exist. One of these would exist if ogre provided them (they are generated via `install(export...)`). This is really what *should* be provided by ogre rather than FindOGRE.cmake I think. – Fraser Apr 15 '13 at 07:20
  • Hi. I am using "Linux Mint 14". And the trick is find the cmake ogre files. In my system, the command line for cmake is `cmake . -DCMAKE_MODULE_PATH=/usr/share/OGRE/cmake/modules/` . – tres.14159 Feb 09 '14 at 20:49
2

Just for the record, an alternative solution would be to add the module path directly in the CMakeLists.txt. For example (tested on Debian 9):

set(CMAKE_MODULE_PATH "/usr/share/OGRE/cmake/modules/;${CMAKE_MODULE_PATH}")

Just make sure to add the line before find_package is called.

fmtt
  • 33
  • 6
1

For me, it only works to set the following in CMakeLists.txt before find_package:

set(OGRE_DIR /usr/share/OGRE/build/sdk/CMake)

Note that the CMake directory is the one containing OGREConfig.cmake. For some reason, my CMake ignores CMAKE_MODULE_PATH.

Maybe, of some help for someone

IceFire
  • 4,016
  • 2
  • 31
  • 51
0

For me, this solution work on manjaro:

set(CMAKE_MODULE_PATH "/usr/lib/OGRE/cmake;${CMAKE_MODULE_PATH}")
find_package(OGRE QUIET)

if (OGRE_FOUND)
    include_directories( ${ogre_INCLUDE_DIR})
    link_directories(${OGRE_LIBRARIES})
    message(STATUS "OGRE: FOUND")
else()
    message(STATUS "OGRE: NOT FOUND")
endif()
Bensuperpc
  • 1,275
  • 1
  • 14
  • 21