[CMake] Should configuration package files define module package variables?
Johannes Zarl-Zierl
johannes.zarl-zierl at jku.at
Mon Aug 28 06:37:54 EDT 2017
Hi,
On Freitag, 25. August 2017 11:21:50 CEST Robert Dailey wrote:
> However, what I'm wondering is even though the import targets should
> contain all information about include directories, libraries, etc,
> should I still define the typical Foo_INCLUDE_DIRS, Foo_LIBRARIES
> variables?
This depends very much on the target audience of your config.cmake file. My
personal opinion is that you can skip those variables entirely for new
projects. (Somebody please correct me if I'm wrong!)
> It seems like Module packages are being deprecated
> in favor of Config packages, because it puts the responsibility of
> maintaining find package logic on the upstream maintainer (config
> package) instead of on CMake (module packages it ships with).
Yes. This has been the case since cmake 2.8 or so. A general rule of thumb for
module vs. config:
If you are the upstream: create a config package.
If the upstream is somebody else, but uses cmake: submit a patch and get them
to provide a config package.
If the upstream does not use cmake: they can still provide a config package.
If all else fails: add a module to your project to find the upstream library.
Cheers,
Johannes
P.S.: And yes: creating a config package has a steep learning curve. Link [2]
has all the information you need, but it is hardly a nice tutorial...
More information about the CMake
mailing list