[CMake] packaging configuration files
James C. Sutherland
James.Sutherland at utah.edu
Tue Nov 10 15:30:51 EST 2009
Brad, thanks for the feedback. See comments below.
On Nov 10, 2009, at 11:30 AM, Brad King wrote:
> 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)?
>
Yes.
>> 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.
Thanks. To be clear, it only works if I use
set( ExprLib_LIBRARIES @TPL_LIBRARIES@ )
because otherwise I have no way of propagating the dependents of ExprLib downstream. It is true that CMake will add the ExprLib library as a "target" that can be used internally in downstream projects, but the other third-party libraries that ExprLib requires can only be propagated "manually" - right?
More information about the CMake
mailing list