Linux/OSX | Windows |
---|---|
Example of downloading/installing dependencies using Hunter package manager.
- Set
HUNTER_ROOT
environment variable (recommended, see alternatives) - Generate project:
cmake -H. -B_builds -DHUNTER_STATUS_DEBUG=ON -DCMAKE_BUILD_TYPE=Debug
- Run build:
cmake --build _builds --config Debug
- Run test:
cd _builds && ctest -C Debug -VV
- Download starts in
HUNTER_ROOT
directory:
-- [hunter] Initializing Hunter workspace (0ccc3f3fd571676a1804723984598f9f90a4d6bc)
-- [hunter] https://github.com/ruslo/hunter/archive/v0.12.40.tar.gz
-- [hunter] -> /home/travis/.hunter/_Base/Download/Hunter/0.12.40/0ccc3f3
- After download done cmake variable
HUNTER_ROOT
set:
-- [hunter] HUNTER_ROOT: /home/travis/.hunter
- Requested package GTest will be downloaded using wrapped ExternalProject_Add command:
-- [hunter] GTEST_ROOT: /home/travis/.hunter/_Base/0ccc3f3/b874e31/3ef6df8/Install (ver.: 1.7.0-hunter-11)
- If local configuration match binary cache from server then it will be used without building from sources:
https://raw.githubusercontent.com/ingenue/hunter-cache/.../cache.sha1
-> /home/travis/.hunter/_Base/Cache/meta/.../cache.sha1
Cache HIT: GTest
https://github.com/ingenue/hunter-cache/.../da62fc35901e07d30db7a1c19b7358855978e11f.tar.bz2
-> /home/travis/.hunter/_Base/Cache/raw/da62fc35901e07d30db7a1c19b7358855978e11f.tar.bz2
Note: since cache uploaded from Travis/AppVeyor CI hence configuration will always match.
Build functionality can be extended using toolchains:
- Download toolchains archive (unix-style):
> export POLLY_VERSION="0.9.0"
> wget "https://github.com/ruslo/polly/archive/v${POLLY_VERSION}.tar.gz"
> tar xf "v${POLLY_VERSION}.tar.gz"
> export POLLY_ROOT="`pwd`/polly-${POLLY_VERSION}" # not needed in general
> export PATH="${POLLY_ROOT}/bin:${PATH}"
- Now
build.py
python3 script from${POLLY_ROOT}/bin
directory can be used to start for exampleXcode
project:
> build.py --toolchain xcode --open --nobuild --verbose
This script equivalent to:
> cmake -H. -B_builds/xcode -DHUNTER_STATUS_DEBUG=ON -DCMAKE_TOOLCHAIN_FILE=${POLLY_ROOT}/xcode.cmake -GXcode
> open _builds/xcode/HunterSimple.xcodeproj
Check GTest directories:
/home/travis/.hunter/_Base/0ccc3f3/b874e31/3ef6df8/Install # install directory
/home/travis/.hunter/_Base/Download/GTest/1.7.0-hunter-11/c6ae948/ # path to downloaded archive
.. node:: For building with `iOS`_ need to be used patched version of `CMake`_