[CMake] more on an executable dependency on external library

Crni Gorac cgorac at gmail.com
Wed Dec 6 03:42:27 EST 2006


On 12/6/06, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Crni Gorac wrote:
> > OK, I've tried in the meantime various arrangements with
> > ADD_CUSTOM_TARGET(), but seems hard to employ it to have CMake to put
> > following simple dependency of an executable "foo" on system library
> > "libbar.a" into generated Makefile:
> > foo: /usr/local/lib/libbar.a
> >
> > There exists of course ADD_EXECUTABLE() statement for executable foo,
> > and there exists also TARGET_LINK_LIBRARIES() statement specifying
> > that "foo" should be linked with "libbar.a".  The library "libbar.a"
> > is a system-wide installed library, however let's say it changes
> > often, and it is necessary to have above dependency somehow captured
> > by CMake.  Any suggestion on how to accomplish this?
> If you link to the full path it should do what you want.
>
> target_link_libraries(foo /usr/local/lib/libbar.a)
> Of course you would not want to hard code the path to libbar.a,
> but rather use a FIND_LIBRARY(BAR bar)
> target_link_libraries(foo ${BAR})
>
> But either way if you have a full path the makefile will have
> foo:/usr/local/lib/libbar.a in it.
> (At least it will with 2.4.5)

Thanks for the clarification, adding FIND_LIBRARY() statement indeed
did the job.

Regards,
Crni


More information about the CMake mailing list