Link Ogre with CEGUI (Ogre Basic Tutorial 7) using cmake

I am currently playing with the awesome graphic rendering library Ogre, and going through all the tutorials.

In the Basic Tutorial 7, you will also have to use the CEGUI library, to add a nice GUI in your 3D rendering.

First of all, you will have to download the latest version of CEGUI (currently the 0.7.6), and go through the usual

./configure && make -j8 && sudo make install

process.

Once it has been successfully built and installed, you will have to change your CMakeList.txt to handle those modifications.
Find the bold existing code in your CMakeList.txt and apply those changes:

set(OGRE_LIBRARIES ${OGRE_LIBRARIES} ${Boost_LIBRARIES}
endif()

find_package(CEGUI REQUIRED)
if(NOT CEGUI_FOUND)
message(SEND_ERROR "Failed to find CEGUI.")
endif()

find_package(CEGUIOGRE REQUIRED)
if(NOT CEGUIOGRE_FOUND)
message(SEND_ERROR "Failed to find CEGUIOGRE.")
endif()

set(HDRS
	./BaseApplication.h

////////////////////////////////////////////////////

include_directories( ${OIS_INCLUDE_DIRS}
${OGRE_INCLUDE_DIRS}
${OGRE_SAMPLES_INCLUDEPATH}
${CEGUI_INCLUDE_DIRS}
${CEGUIOGRE_INCLUDE_DIRS}
)

And replace

target_link_libraries(OgreApp ${OGRE_LIBRARIES} ${OIS_LIBRARIES})

by

target_link_libraries(OgreApp ${OGRE_LIBRARIES} ${OIS_LIBRARIES} ${CEGUI_LIBRARY} ${CEGUIOGRE_LIBRARY_OPTIMIZED})

 

Once you are done with that, you will have to actually own the invoked scripts (find CEGUI and CEGUIOGRE).

You can find them here, and copy them where you installed Ogre (usually in /usr/local/lib/OGRE/cmake/), so that cmake-gui will find them quite easily.
If you don’t want them all, only CompareVersionStrings.cmake, HandleLibraryTypes.cmake, DetermineVersion.cmake, FindCEGUIOGRE.cmake, FindCEGUI.cmake and FindPackageHandleAdvancedArgs.cmake are necessary for our current concern.

Now run your cmake-gui, generate your Makefiles and you can finally compile the Basic Tutorial 7 !

Great thanks to this thread and sumwars !