[CMake] packaging configuration files

James C. Sutherland James.Sutherland at utah.edu
Mon Nov 9 14:13:49 EST 2009


On Nov 9, 2009, at 12:00 PM, Brad King wrote:

> James C. Sutherland wrote:
>>> However, I just discovered that this is a deprecated feature, and  
>>> that
>>>    install(EXPORT...)
>>> should be used instead.
>
> Good, it is much more modern and more powerful.
>
>>> However, it is not clear to me how to incorporate dependencies  
>>> when using the install(EXPORT) approach.  Are we now supposed to  
>>> do this manually, or am I missing something?
>
> The myproj-targets.cmake file that install(EXPORT) puts in the
> install tree should already have all the dependencies (actually
> that file includes a per-configuration file which defines all
> the libraries).  See this page for details:
>
>  http://www.cmake.org/Wiki/CMake_2.6_Notes
>
>> I think that I have this figured out now.  I am collecting the  
>> library dependencies and shoving them into the Config file that  
>> find_package() uses.  This seems to work just fine.
>
> What are you putting in the Config?  Typically the <pkg>Config.cmake
> file should just include the file produced by install(EXPORT).
>
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.

I have the following in my Config file:

--------------- <snip> ---------------
set( ExprLib_FOUND 1 )

set( ExprLib_INCLUDE_DIR @ExprLib_INCLUDE@ )

set( ExprLib_TPL_INCLUDE_DIRS @TPL_INCLUDE_DIRS@ )

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

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

Above, TPL_INCLUDE_DIRS is a set of paths for all libraries that are  
required by this one, and TPL_LIBRARIES is a list of fully qualified  
libraries.  I am advertising a set of include directories and fully  
qualified libraries to be propagated downstream to any project that  
wants to use it.

Is there a better way to accomplish this?


More information about the CMake mailing list