[CMake] packaging configuration files

Brad King brad.king at kitware.com
Tue Nov 10 13:30:07 EST 2009


James C. Sutherland wrote:
> The library I am building pulls in several other libraries (MPI, BLAS, 
> Boost, etc).  I would like any down-stream apps that use my library to 
> automatically be able to include any appropriate header files and link 
> to appropriate third-party libraries that were included in my library.

Ah, I see the difference.  I was thinking about link dependencies of
libraries that you build.  You were talking about package-level deps.

> I have the following in my Config file:
> 
> --------------- <snip> ---------------
> set( ExprLib_FOUND 1 )

This is not necessary.  The find_package command automatically sets
this when it locates the config file.

> set( ExprLib_INCLUDE_DIR @ExprLib_INCLUDE@ )
> 
> set( ExprLib_TPL_INCLUDE_DIRS @TPL_INCLUDE_DIRS@ )

This looks fine.  Currently we have no builtin way to express
usage requirements.  Automatic dependency propagation only works
for linking.

> include( @CMAKE_INSTALL_PREFIX@/lib/expression/ExprLib.cmake )

Is ExprLib.cmake produced bin install(EXPORT)?

> set( ExprLib_LIBRARIES
>    @CMAKE_INSTALL_PREFIX@/lib/expression/@ExprInstallLib@
>    @TPL_LIBRARIES@
>    )

This should not be needed.  Applications that did

   find_package(ExprLib)

should be able to do

   target_link_libraries(myapp ExprLib)

and get all the dependencies automatically.  The install(EXPORT)
command should have put the necessary information in ExprLib.cmake
(or one of the files it includes).  It defines an IMPORTED target
called "ExprLib" and sets properties that tell CMake how to link
to it.

-Brad


More information about the CMake mailing list