Page 1 of 1

[Solved] CMake Ogre project

Posted: Sun Feb 10, 2019 6:21 am
by saintnick
https://ogrecave.github.io/ogre/api/latest/setup.html

Manual mentions using CMake for your project. I could only find an outdated cmake tutorial on the wiki. Can anyone post an updated one for a the basic tutorials in the manual? I tried updating the wiki link http://wiki.ogre3d.org/Building+Your+Pr ... With+CMake but got error:

Code: Select all

CMakeLists.txt:24

  when parsing string

    $ENV{

  syntax error, unexpected $end, expecting } (5)

Re: CMake Ogre project

Posted: Wed Feb 13, 2019 8:24 am
by CollegeDropout
saintnick wrote:
Sun Feb 10, 2019 6:21 am
https://ogrecave.github.io/ogre/api/latest/setup.html

Manual mentions using CMake for your project. I could only find an outdated cmake tutorial on the wiki. Can anyone post an updated one for a the basic tutorials in the manual? I tried updating the wiki link http://wiki.ogre3d.org/Building+Your+Pr ... With+CMake but got error:

Code: Select all

CMakeLists.txt:24

  when parsing string

    $ENV{

  syntax error, unexpected $end, expecting } (5)
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!