[CMake] packaging configuration files
Brad King
brad.king at kitware.com
Wed Nov 11 11:05:59 EST 2009
James C. Sutherland wrote:
> 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?
In this example:
# Library
add_library(foo foo.c)
target_link_libraries(foo m)
install(TARGETS foo DESTINATION lib EXPORT FooLib)
install(EXPORT FooLib DESTINATION lib/FooLib)
the FooLib.cmake file will provide the dependency on 'm'.
In an application:
# App
include(.../lib/FooLib/FooLib.cmake)
add_executable(bar bar.c)
target_link_libraries(bar foo)
The link line for 'bar' will contain
-o bar ... /path/to/lib/libfoo.a -lm ...
-Brad
More information about the CMake
mailing list