[CMake] building executable from static libs / rpath
Brad King
brad.king at kitware.com
Wed May 3 10:22:44 EDT 2006
Christian Lang wrote:
> Then link them together into an executable:
>
> ADD_EXECUTABLE(exe ...)
> TARGET_LINK_LIBRARIES(exe ${START_WHOLE_ARCHIVE} ${SOURCE_LIBS}
> ${END_WHOLE_ARCHIVE} ${LIBS})
>
> where SOURCE_LIBS are the static libs built in step one and LIBS are
> some shared libs. (START_WHOLE_ARCHIVE is "-Wl,--whole-archive" on
> linux, END_WHOLE_ARCHIVE "-Wl,--no-whole-archive").
It's not clear whether you are saying this works or asking how to get it
to work.
> As LIBS are shared libs, the corresponding directories appear in the
> rpath, which is desired. But SOURCE_LIBS are static libs, and their
> directories (located somewhere in my home-direcetory) appear in the
> rpath too - which is not desired. How can I avoid this?
For the executable in the build tree you have the choice of either the
current rpath or no rpath at all (set the SKIP_BUILD_RPATH property).
For the executable in the install tree you can set the rpath by setting
the INSTALL_RPATH target property on the executable. Take a look at the
documentation of SET_TARGET_PROPERTIES for details.
-Brad
More information about the CMake
mailing list