[CMake] Using find_package() portably?
Johannes Zarl-Zierl
johannes.zarl-zierl at jku.at
Tue Nov 21 05:44:35 EST 2017
Hi,
I thought you might want some context for the suggestions:
On Dienstag, 21. November 2017 11:45:43 CET Konstantin Tokarev wrote:
> 1) add instruction how to install dependencies
This is what many/most projects do, and it works reasonably well.
Advantages:
- You don't clutter your project with dependencies
- People on each platform already know how to install dependencies
- You don't complicate things for package maintainers
Disadvantages:
- No automatic dependency resolution
> 2) use hand-made script or more complex solution to automate dependency
> installation, or
Hand-made scripts are often a maintenance nightmare and hard to get right for
all platforms. The One True Way(TM) would be a so-called "super-build", i.e. a
CMake project that uses external_project() to build your project along with
its dependencies.
> 3) avoid using find_package() st all
That's the first time I've heard that suggestion. I'm not sure if this will
ease your pain ;-)
4) Shipping the dependency with your project (not using external_project)
This can sometimes be useful, but you should carefully consider the
implications beforehand to see if it's worth it for your project. As a rule of
thumb: don't do this if the dependency is readily available and/or big.
Cheers,
Johannes
More information about the CMake
mailing list