[cmake-developers] pkg-config like mode for cmake ?

Brad King brad.king at kitware.com
Mon Mar 15 10:06:23 EDT 2010


Alexander Neundorf wrote:
> Like 
> $ cmake --findpackage Foo --libs 
> would basically execute a 
> find_package(Foo NO_MODULE)
> then see which imported libraries have been executed, and then print the 
> linker flags to link these libraries.
> For the include dirs one would have to rely on these variables named properly 
> FOO_INCLUDES, FOO_INCLUDE_DIRS, FOO_INCLUDE_DIR or FOO_INCLUDE, probably in 
> this order.
> 
> What do you think ?

It's an interesting idea, but I think it will be *very* difficult
to implement robustly.  As Eric pointed out, the generator name is
needed to know the proper flags.  It is much more than that though.
CMake's library linking analysis is quite advanced and uses a lot
of information about the target to be linked.

The approach requires CMake to be installed on the build machine
already anyway.  Therefore I think it is simpler to do this on a
per-package basis for specific projects.  They can write simple
helper .cmake programs that do the find_package and print things
out as necessary for the specific use case.

Even if the general feature is possible I think it is necessary to
do this intermediate approach first.  If a pattern begins to emerge
from the case-specific solutions then we can consider generalizing
it.

-Brad



More information about the cmake-developers mailing list