crossbario / autobahn-cpp

WAMP for C++ in Boost/Asio
https://crossbar.io/autobahn
Boost Software License 1.0
251 stars 104 forks source link

Add support for installing dependencies using a conanfile #214

Closed robinlinden closed 3 years ago

robinlinden commented 3 years ago

This is mainly in preparation of the Windows CI (and to make building and testing autobahn_cpp on systems without everything installed more convenient).

Usage:

mkdir -p build && cd build
conan install ..
# Make sure CMake searches in the current for the Findx.cmake-files that inject the conan libraries.
cmake .. -DCMAKE_PREFIX_PATH=`pwd` -DCMAKE_MODULE_PATH=`pwd`
make -j

If you don't already have conan installed and set up, you can do so by doing

pip install conan
conan profile new default --detect
# You'll probably get weird linker errors if you use new gcc and don't do this.
# At least conan warns you about it.
conan profile update settings.compiler.libcxx=libstdc++11 default
oberstet commented 3 years ago

this is interesting! I wasn't aware of https://conan.io/ and https://conan.io/center/

so just to understand the motivation of adding conan to the ci: this is to get easy access to autobahncpp dependencies for building tests during a ci run, right? conan is not for releasing autobahncpp itself, since obviously autobahncpp is a header only, heavily templated library which needs to be compiled together with an app with no separate binary package ..

which is cool of course .. seems like conan is a new thing that has gained wide use in no time in the c++ communities

oberstet commented 3 years ago

ok, had a look at openssl and boost on conan center .. not sure I understand: boost is mostly headers only. right, there are some binary shared libs being built as well, and for those I would understand a binary package distribution site. however, there is a "headers only confiuration" as well :

Bildschirmfoto von 2020-10-03 14-05-06

similar for websocketpp ... which is pure headers-only .. how does this work? why a binary pkgs site for a headers only lib?

Bildschirmfoto von 2020-10-03 14-08-31

robinlinden commented 3 years ago

Yeah, the motivation for this is to be able to build and test autobahn_cpp without installing system dependencies or manually trying to build the dependencies (not trivial for e.g. libc++ clang boost or openssl for VC++). You could also use it to push autobahn_cpp to conan if you wanted, but that's just an extra and not something I was thinking about. :P It would let users depend on autobahn_cpp by just adding one line in their conanfile.txt and letting conan find and download everything we depend on here.

Boost can be used as both header-only or linked against, depending on which subset of it you're using. Most recipes on there have some options that allow you to specify what you want. E.g. websocketpp allows you to pick between standalone asio or boost asio: https://github.com/conan-io/conan-center-index/blob/master/recipes/websocketpp/all/conanfile.py#L22-L28

The reason some header-only libraries are on there is to allow you to pull in their dependencies at the same time by letting conan handle the transitive dependencies. You can't use websocketpp without also depending on openssl, zlib, and either asio or boost, and conan handles that for you (see https://github.com/conan-io/conan-center-index/blob/master/recipes/websocketpp/all/conanfile.py#L22-L28 again)

Edit: If the dependencies don't exist pushed to conan-center, the recipes for the library contain instructions for building them too, so when I run conan install on e.g. an old boost version with a clang libc++ profile, it downloads the sources and sets up a b2 build for me, so I don't have to debug why it doesn't find my system libraries. :D Very convenient.

oberstet commented 3 years ago

It would let users depend on autobahn_cpp by just adding one line in their conanfile.txt and letting conan find and download everything we depend on here. ... The reason some header-only libraries are on there is to allow you to pull in their dependencies at the same time by letting conan handle the transitive dependencies.

ok, yeah, that makes sense!

IOW: once a header-only lib has (optional) binary deps in its transitive set of deps, it makes sense to put it on conan.

so lets publish autobahn-cpp to conan https://conan.io/center/. seems like we need to "Join the Early Access Program" https://github.com/conan-io/conan-center-index/blob/master/docs/how_to_add_packages.md and then

mmh. no clue=) would https://github.com/conan-io/conan-center-index/tree/master/recipes/websocketpp be a good example to look at / steal from for what we need with autobahn?