Issues setting up Ogre3D as an external dependency with CMake

Problems building or running the engine, queries about how to use features etc.
OgrynSquiggles
Gnoblar
Posts: 1
Joined: Sun Nov 17, 2024 11:07 pm

Issues setting up Ogre3D as an external dependency with CMake

Post by OgrynSquiggles »

Ogre Version: 14.3.1
Operating System: Windows

Alright, so I'm trying to set up a project which uses Ogre3D as a dependency and having a bit of trouble.
I have added Ogre3D as a git submodule and my project structure looks like this:

Code: Select all

externals/ogre
externals/CMakeLists.txt
CMakeLists.txt
main.cpp

My externals CMakeLists.txt

Code: Select all

# Ogre
add_subdirectory(ogre)

Root CMakeLists.txt

Code: Select all

cmake_minimum_required(VERSION 3.31)
project(OgreTestProject VERSION 0.1.0 LANGUAGES CXX)
cmake_policy(SET CMP0063 NEW)
cmake_policy(SET CMP0048 NEW)

# Add external dependencies
add_subdirectory(externals)

# Add executable
add_executable(OgreTestProject main.cpp)

# Link libraries
target_link_libraries(OgreTestProject PRIVATE OgreBites OgreMain)

# Include directories
target_include_directories(OgreTestProject PRIVATE ${OGRE_INCLUDE_DIRS} ${OGRE_SAMPLES_INCLUDEPATH})

# Set startup project for Visual Studio
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT OgreTestProject )

Now, this mostly works dandy, I am able to configure and generate a Visual Studio project from this and I am able to access the ogre.h header, but when trying to complete the tutorial by creating the application context, when building RelWithDebInfo, I am getting several LNK2005 errors (for pugixml) and a singular LNK1169 error.

I've checked the OGRE_STATIC variable, other than that I should be close to the default configuration.

I'm not incredibly particular about any sort of solution, I just want to compile Ogre3D as an external dependency in my project.
Thanks in advance for any help!

paroj
OGRE Team Member
OGRE Team Member
Posts: 2106
Joined: Sun Mar 30, 2014 2:51 pm
x 1132

Re: Issues setting up Ogre3D as an external dependency with CMake

Post by paroj »

while your approach might eventually work, the recommended way is:
https://ogrecave.github.io/ogre/api/lat ... alling-sdk

the linker errors might be related to:
https://github.com/OGRECave/ogre/issues/1303

OgrynSquiggles
Gnoblar
Posts: 1
Joined: Sun Nov 17, 2024 11:07 pm

Re: Issues setting up Ogre3D as an external dependency with CMake

Post by OgrynSquiggles »

Yep, almost got it going, manually entering the externals/ogre directory and running:

Code: Select all

cmake .
cmake --build . --config release

gives me a neat little bundle of libraries, so with your link and this:
viewtopic.php?t=82104
I'd thought I'd try to add it with externalproject_add instead

Code: Select all

ExternalProject_Add(
    Ogre3D
    SOURCE_DIR ${CMAKE_SOURCE_DIR}/externals/ogre
    BINARY_DIR ${CMAKE_BINARY_DIR}/ogre/build
    CMAKE_ARGS -DOGRE_STATIC=YES
    BUILD_COMMAND ${CMAKE_COMMAND} --build <BINARY_DIR> --config Release
    INSTALL_COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR}/ogre/build --config Release --target install
)

But no luck, this does not seem to configure nor install Ogre3D into the build directory at all.

Last edited by OgrynSquiggles on Mon Nov 18, 2024 11:43 pm, edited 1 time in total.