Introduce VCPKG manager for build dependencies
I would like to introduce VCPKG manager which will help to download and build third-party libraries on all popular platforms (Win/Linux/MacOS). There were several impediments which were previously blocked this, but everything was successfully solved. Last one issue was with AvroCpp library with segfault crashes on Linux. The problem was in the package itself, I've recently published new version with fixes (PR).
One of alternatives for VCPKG manager - Conan, which is also very well known, but currently it does not contain all necessary libraries for Open-ETP-server.
Advantages of VCPKG usage:
- Easy add/upgrade libraries.
- No needs to change CI scripts when added/upgraded library.
- Cross-platform build of libraries is supported by package manager (easiest way to support different platforms).
- Will allow to avoid interferences with system installed libraries for different projects.
- Will help new developers to speed-up get first build on any platform (currently it's quite difficult quest).
- Less code in the repository, reduce complexity of CMake files (can be removed support
OPEN_ETP_SERVER_3RDPARTY_DIR
). - In future, Open-ETP libraries can be published to VCPKG manager (when there will be such needs, for example when there will be other related projects which will consume ETP protocol).
Disadvantages:
- Build on CI can take a bit longer time (due to the need to build 'boost' library instead of just installing dev package)
I've created branch with VCPKG manifest file and 'CMakeSettings.json' (for make it easier to get started with Win/VS). There are no changes in the existing CMake scripts, just need to pass VCPKG toolchain.
Versions of libraries described in the "vcpkg.json" are tied to VCPKG "builtin-baseline" (hash of commit) with several overrides. For get more info about VCPKG manifest mode please go to this guideline.
How to build
At first, need to clone VCPKG and run bootstrap script:
git clone https://github.com/microsoft/vcpkg
./vcpkg/bootstrap-vcpkg.sh
More details about setup for different platforms on official quick start guideline
After this, Open-ETP-server can be built, need to go directory with Open-ETP-server sources and execute:
cmake -G "Ninja" -B build -DCMAKE_TOOLCHAIN_FILE=~/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_FEATURE_FLAGS=versions -DCMAKE_BUILD_TYPE=Debug
cmake --build build
[Please correct path to installed VCPKG]
On Windows platform, you can just use "Open folder" feature in the Visual Studio for start work (will be used "CMakeSettings.json" that contains all necessary configuration for build). Just one action that is needed - add environment variable "VCPKG_ROOT" with path to installed VCPKG (e.g. "c:\vcpkg"), don't forget to restart Visual Studio. The file "CMakeSettings.json" also contains configuration for remote build on Linux, follow this instruction if it needed for you.
ToDo:
- Update documentation √
- Use VCPKG for build inside Docker container (MR: !69 (merged)) √
- Use binary caching for optimize build speed on CI (MR: !75 (merged)) √
- Remove from CMake support of getting third-party libraries from
OPEN_ETP_SERVER_3RDPARTY_DIR
(MR: !77 (merged)) √
I'm not proposing to remove all build ways straightaway, I think that better to keep both ways for first time.
Of course I've built/tested it on multiple platforms (Windows/Linux), but probably not deep enough (just run tests and executed simple scenarios).
@bosquet @deny, could you take a look and let me know if you have any issues or objections.