Using Urho with CMake as static dependency

So far, I’ve been using Urho as a dependency on my machine. I did the standard make && make install and everything works well on my both Fedora and Manjaro setups. However, now that I’m ready to package my project and make it more mature, I wanted to add Urho as an external dependency to my build, so contributors can just clone my repo and run CMake and call it a day. This will be much better for Mac and Windows contributors too.

Unfortunately, I can’t get ExternalProject_Add to work with Urho. It fails to find paths and I can’t compile it as a static dependency. I also tried with a git submodule and add_subdirectory, but had the same errors. I suspect the problem lies within the Urho standard CMakeLists.txt.

Has anyone tried to do anything similar?

Here is the test in which I use Urho3D as a static library, currently works on Windows -

Edit: Reference document - Urho3D - Documentation - Using Urho3D library
you should also need to set URHO3D_HOME -

When searching in a non-default SDK installation or when searching in any Urho3D project build tree then the actual location need to be provided via URHO3D_HOME environment variable (set in the host system) or URHO3D_HOME build option (set using -D at command line or in cmake-gui). That is, use the URHO3D_HOME to hint the build system to locate the library.

Last not least, you also need to copy/mklink CMake folder from Urho3D to the folder of your project.

I’m confused. Followed your link, where I found a message from you:

The whole Gradle + CMake + Android Studio for NDK thing is horrible. Weekend ends now, still no progress.

Were you able to make it work? If so, how?

It’s working on Windows, but not on Android.

You can use the Android NDK to generate standalone toolchain for your target arch and build Urho3D as static with the toolchain. You can do that for every arch you want to target (aarch64 and armeabi-v7a for example) and use those libraries in both windows and linux with Android Studio. That’s what I do in my project and its automated, so once I had it done its quite easy now.

Here’s a snippet of how I build it using ExternalProject_Add:

    -DURHO3D_WEBP=OFF # TODO: needs cpu-features.h
  file(MAKE_DIRECTORY ${platform_spec_path}/urho3d/src/urho3d-build/assets)

  SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/external/urho3d
  PREFIX urho3d
    # TODO: Causes error, PackageTool tries to create file in assets/ folder which doesn't exist

Hi Pencheff,

I wonder what does “use the Android NDK to generate standalone toolchain” really mean?
Could you please modify my HelloWorld project a little bit to show the way you work out on Android?