[CMake] Ensuring correct linkage to local target library

Clifford Yapp cliffyapp at gmail.com
Sat Sep 18 11:37:12 EDT 2010


I have a situation where there exists on some systems a library
(/lib/librt.so.1) that conflicts with the name we use for BRL-CAD's
raytracing library (also librt).  For various reasons, I can't rename
our lib - this means I have to deal with the situation where there
exists a system library with the correct name but incorrect contents.

Generally, we install into directories with a prefix (e.g.
/usr/brlcad) to avoid stomping over system libs.  However, when it
comes to defining target_link_libraries lines for our executables, I
end up with something like:

add_executable(rt ${rt_SRCS})
target_link_libraries(rt librt)

This works splendidly, particularly combined with the RPATH settings
that let me run the executables both in the build and install
locations without jumping through hoops.  However, the linker
(justifiably) is confused by the presence of the system librt file
when it is present.

Is there a way to specify my local librt to the target_link_libraries
command in such a way that avoids any chance of picking up the system
librt, but still preserves the nice properties of running executables
both in build and install directories cleanly?

Thanks for any help,
CY


More information about the CMake mailing list