Urho3D source as dependency

Hi ,
What is the best practice to add Urho3D source to existing project as dependency ?
Is there any mechanics to add it to my existing project using Cmake.
This works if Urho3d is already compiled : urho3d.github.io/documentation/1 … brary.html
In my case it will be more convenient to have it as a dependency in my Xcode project, but properly generated with Cmake.

Instead of making “Urho3D source” as dependency, you should be able to make the “Urho3D project” (generated by our CMake build scripts as usual) as dependency in your project. I have setup exactly just like that in my Android project using Eclipse IDE. When Urho3D project’s source code has changed, the IDE knows that it has to first build the Urho3D project before building my own project. I believe you can perform a similar setup in Xcode. Actually I believe you can do it much easier there, start by dragging Urho3D project into your own project in the “project navigator”. HTH.

I was hoping for Cmake solution. Because I am using the macros and FinUrho3D cmake module most of the paths include headers and libraries are hard-coded. I don’t want to end up tweaking an Xcode project outside of Cmake it is not practical for multiplatform projects. For now I have two projects opened one Xcode with Urho3D and another with my project and I am just setting URHO3D_HOME to the path of Urho3d.

Perhaps I didn’t make myself clear. Both Urho3D project and your own dependent project can be generated by the existing CMake build scripts as per normal. To the IDE, it really does not matter how your project files are actually generated, whether it is created by the IDE itself or generated somewhere else. A project is a project. I know for the fact that both Eclipse IDE and Xcode IDE support the feature of setting up one project as dependency of another project. Now one just needs to read on the IDE guide on how to set it up. Your project may depend on Urho3D and any other external libraries that you build from source yourself, whether they use CMake generator or not. The IDE also does not care about that. In short, you don’t need to alter the existing CMake build scripts to achieve what you want to do. However, you are right about the need to tweak the generated Xcode project for this to work. The second you drag and drop things in the Xcode, your Xcode project start to divert from the original generated one. There is no way to prevent that. It is also not practical to enhance our build scripts so that it support this setup, even when it is possible.

Thanks weitjong,

Ideal solution for me would be to add this to my Cmake project. Although it seems more complicated as it doesn’t work out of the box. I was hoping that someone with more knowledge of the Cmake structure of Urho3D can help.
Otherwise I can do it myself but it can take me a lot longer.
I am hoping to use it like this in my test project:

It seems you are more CMake die-hard than I am :wink: . If you really insist on CMake-only solution for this dependency setup then there are two possibilities I can think of:
[li] Try to use ExternalProject_Add() macro. Note, however, that the unit of inclusion here is still at project level and not at source level as you want. This may also not be what you want because it now configures/generates/builds Urho3D project on the fly as part of your own project build time. In order to be able to build for multiple-platforms correctly, you need to also pass the relevant build options to the ExternalProject_Add(). I have never tried this myself.[/li]
[li] Use the Urho3D project itself as if your own project. After cloning, nuke all the samples and replace it with your own app subdirectory. The samples used to be and therefore now your app also naturally already setup to depend on Urho3D library by the existing CMake build scripts without needing to be tweaked too much.[/li][/ol]

Thanks a lot I will try the first one :slight_smile: