I don't know what version of Ogre you're using, but here is the CMakeLists.txt that I used to make a project for Ogre 1.11.5:
Code: Select all
cmake_minimum_required (VERSION 2.8)
project (ogreproject)
set(OGRE_DIR C:/coding/OgrePlayground/CMake)
# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS Bites RTShaderSystem)
# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})
add_executable(ogreproj src/ogreproj.cpp)
target_link_libraries(ogreproj ${OGRE_LIBRARIES})
target_include_directories(ogreproj PUBLIC headers PUBLIC src)
You probably want to change yours up a bit from mine:
cmake_minimum_required (VERSION 2.8)
project ([PROJECT NAME])
set(OGRE_DIR [PATH TO THE SDK'S CMAKE FOLDER])
# specify which version and components you need
find_package(OGRE 1.11 REQUIRED COMPONENTS Bites RTShaderSystem)
# copy resource.cfg next to our binaries where OGRE looks for it
file(COPY ${OGRE_CONFIG_DIR}/resources.cfg DESTINATION ${CMAKE_BINARY_DIR})
add_executable([PROJECT NAME] [PATH TO PROJECT SOURCE FILE])
target_link_libraries([PROJECT NAME] ${OGRE_LIBRARIES})
target_include_directories([PROJECT NAME] PUBLIC headers PUBLIC src)
Note: For the target_include_directories bit, PUBLIC headers and PUBLIC src are just folders I put my things in, your directories could be different.
put PUBLIC or PRIVATE behind directory names you want to include.
Once you made your cmakelists file, use either the cmake command line tool or the gui tool to generate to a folder of your choice. If you're on windows and using visual studio, cmake will automatically create a visual studio solution for you. Do not create a project in visual studio first. Just let cmake generate your project for you. When you load it up, all the dependencies should be set and you should be good to go provided you built "ALL_BUILD" and "INSTALL" (to build the sdk) inside of Ogre's solution.
I hope this helps!