[CMake] linking to arbitrary libraries in linux.

Alexander Neundorf a.neundorf-work at gmx.net
Thu Feb 28 18:33:00 EST 2008


On Thursday 28 February 2008, Christopher Harvey wrote:
> Hi,
> Before I ask my question I want to clarify what I mean by an "arbitrary
> library". There are libraries that are registered in the system and you
> can link to them like so:
> target_link_library(targetName GL SDL pq)
> and they get sent to the linker int the form:
> -lGL -lSDL -lpq
> that fine, but I have a file in the form libName.a and I compiled it
> from source and it's not in the /usr/lib directory. It's just sitting in
> my project directory. how can I tell cmake not to turn
> target_link_libraries(targetName libName.a) into -lName, but keep the
> original so the linker can find it?

target_link_libraries(targetName /full/path/to/libName.a)

should do everything required.
If the library is in the same project as cmake, the target name for the 
library is enough:
target_link_libraries(targetName Name)

Alex



More information about the CMake mailing list