CMake (with dependencies)¶
If your project uses external packages (i.e. has command
you need to patch it first so these packages can be found in the Hunter root
directory instead of the standard one:
hunter_add_package(Foo) call one package will be found in the
standard location and another one in the Hunter root directory. The found
packages may conflict with each other.
Consider the next example: Project
Roo is not aware about Hunter custom
locations. It’s just using regular
# Roo/CMakeLists.txt find_package(ZLIB)
Bar depends on
Roo. Both packages are downloaded by
# Bar/CMakeLists.txt hunter_add_package(Roo) find_package(Roo) hunter_add_package(ZLIB) find_package(ZLIB)
To fix this issue you need to patch project
Roo so it will use
ZLIB from Hunter.
In terms of CMake code it means adding
(see First Step):
# Roo/CMakeLists.txt include("cmake/HunterGate.cmake") HunterGate(...) hunter_add_package(ZLIB) find_package(ZLIB CONFIG REQUIRED)
Note that now the main project
Bar and the hunter dependency
HunterGate command. The URL and SHA1 of the
HunterGate command my not match.
In this case the URL and SHA1 of the main project
Bar are used for both
HunterGate commands. The user does not need to manage them manually.
The same is true for sub-projects added by