To make it short, over the last months I wrote a set of Conan scripts to help manage build and integration for various libs, among them Ogre 1.12.5 and CEGUI 0.8. Now, while still perfectible, they're at a stage other people could be using them.
I'm posting here in the hope other may find my work useful. Most of what I've done so far is accessible on Github: https://github.com/KonradNoTantoo?tab=repositories
I've been working on a small C++ project that uses Ogre on my spare time. Over the years, I had many integration issues, some of them with Ogre, some of them with other libs. In particular, upgrading or changing build chains or OS always feels like a huge pain. Moreover, upgrading library versions can also become time-consuming. It's often not only a problem of updating my own project, but as much of figuring out how various dependencies and their dependencies interact.
Binary incompatibilities always happen with pre-built binaries distributed through the web. Rebuilding everything from source is time-consuming and not always easily reproducible on a slightly different setup.
Conan offers an agnostic build and dependency management system. For each project, Conan permits easily distributing a "build recipe", that is a relatively short python script that aims to be common accros compiler, OS and CPU architecture. My current recipe for Ogre is around 150 lines of well spaced python. Conan provides painless Debug/Release build management. Last but not least, Conan recipe integrate well with free (to use) continuous integration plqtforms like Travis and Appveyor and binary distribution platforms like Bintray and Artifactory.
How it works
To start, when working with only one system and compiler, it's easier to think of Conan as a binary distribution tool like Debian's apt or Redhat's yum. However, it can do more than that: It can handle binary packages for a whole bunch of OS and compiler versions. And if you need a library for some setup that's not readily available online, the library's Conan recipe can be used to build from source.
Conan recipe for a project contain rules to build from source. Conan integrates well with CMake and a bunch of other build chains. For example, the recipe linked above for Ogre declares a bunch of dependencies, fetches Ogre 1.12.5 sources from Github, injects a few lines into Ogre's CMakeLists.txt then delegates to CMake for configuration, build and install.
Once a build is finished, its resulting packaged binaries can be associated to the original recipe on a remote Conan repository. Anyone with the same build environment can then reuse that same package. When building on a CI platform, the result is automatically pushed to a specified Conan repository.
Those same CI platforms can detect each new push to Github and trigger a build from there. When all goes well, a single git push with the right tag or on the right branch can generate everything needed to release and distribute a library.
For library developers
For developers, it also means that each non-released push triggers a build on a bunch of different platforms, giving some security that the current changes break nothing for a platform not readily available to that developer.
The recipe can also incorporate unit tests (very easily if they're already integrated into CMake's CTest) and usually performs a build test to ensure a produced library links well on all CI platforms.
For library users
Conan is pretty easy to learn for users: go see their docs.
At the beginning, Conan consumes a conanfile.txt the same way CMake consumes a CMakeLists.txt.
Code: Select all
[requires] ogre3d/1.12.5@utopia/testing ogre-procedural/0.3.200322@utopia/testing zlib/1.2.11@conan/stable gtest/1.8.1 [options] ogre:with_cg=True [generators] cmake
- Include a short text file named conanfile.txt,
- Pass it to conan install command to generate a conanbuildinfo.cmake file containing CMake code (that enables finding all headers and liking against libs of all those dependency)
- Include two lines of code at the top of their CMakeLists.txt;
Code: Select all
Utopia is my current repository on Bintray that hosts packages generated by Travis (Linux/gcc) and Appveyor (Windows/Visual Studio).
Once Conan is installed, you can make it aware of my binary repository using the following command line:
Code: Select all
conan remote add utopia https://api.bintray.com/conan/konradnotantoo/utopia
I don't yet consider those recipes I wrote to be stable. I'm still a beginner with Conan. I'm more than willing to offer support in this thread or through Github issues for anyone who wants to reuse my work, has questions or needs help.
My current recipe only support a subset of options available to build Ogre. In the future, I'd like to be able to add support for Apple and Android builds, if feasible. Any help, of course, would be welcome.
Hopefully, this all will help others who, like me, would like to minimize tedious integration work, liberating some time for other tasks.