I'm trying Ogre 2.1 just to see if I like how it works.
I found a small problem with CMake:
I have installed on my pc a version 1.9 of ogre (I'm using ubuntu 18.04 LTS so the version is been installed by apt).
As I don't want to change my installation in the root so I downloaded and compiled ogre 2.1.
I decided to create a new blank CMake project with that directory structure:
Code: Select all
project/
include/
*.hpp
src/
*.cpp
deps/
CMakeLists.txt
Now in my CMakeLists.txt I added the deps lib to the CMAKE_PREFIX_PATH and the deps/lib/OGRE/cmake directory to the CMAKE_MODULE_PATH.
Now, if I uninstall the library 1.9 and use the find_package(OGRE) command, all works perfectly, but if I do that with the 1.9 installed the FindOGRE.cmake file will find half of the library of the 2.1 and half of the 1.9! of course that is a problem at link time.
Here you can see my CMakeLists.txt:
Code: Select all
cmake_minimum_required(VERSION 3.14)
project(ogre-test)
## Options and cache variables #################################################
## appending custom cmake modules ##############################################
list(APPEND CMAKE_PREFIX_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps")
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/OGRE/cmake")
message(STATUS ${CMAKE_PREFIX_PATH})
message(STATUS ${CMAKE_MODULE_PATH})
## finding packages ############################################################
#set(OGRE_HOME "${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/")
#find_package(OGRE 2.1 REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/deps")
#find_package(OGRE 2.1 REQUIRED PATHS "${CMAKE_CURRENT_SOURCE_DIR}/deps/lib")
#find_package(OGRE 2.1 REQUIRED HINTS "${CMAKE_CURRENT_SOURCE_DIR}/deps/lib/OGRE/cmake")
find_package(OGRE 2.1 REQUIRED)
## including directories #######################################################
include_directories(${OGRE_INCLUDE_DIRS})
message(STATUS ${OGRE_LIBRARIES})
message(STATUS ${OGRE_INCLUDE_DIRS})
## Adding subdirs ##############################################################
add_compile_definitions(_DEBUG)
add_executable(test src/main.cpp)
target_link_libraries(test ${OGRE_LIBRARIES})
ogre-config.cmake or ogreConfig.cmake, that is understandable because that files does not exists under
the installation folder deps.
here the complete error:
Code: Select all
CMake Error at CMakeLists.txt:15 (find_package):
Could not find a package configuration file provided by "OGRE" (requested
version 2.1) 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.
directly the source and where I compiled it, but I don't like the idea because it forces me to
compile and build in a specific location or to create a symlink. I would like more to make my
CMakeLists.txt say something like: "allright tell me the install prefix you used to install the lib and I will use it",
without forcing the user to compile Ogre.
In all of that the real problem that I see is that the FindOGRE.cmake script is confusing the version 2.1 with the version 1.9.