[CMake] building executable from static libs / rpath

Christian Lang christian.lang at uni-bielefeld.de
Tue May 2 11:08:39 EDT 2006


Hi,

this is what I want to do:

First build some static libs in subdirectories:

FOREACH(dir ${SOURCE_DIRS})
  ADD_SUBDIRECTORY(${dir})
ENDFOREACH(dir)

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").

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?

Thanks,
Christian



More information about the CMake mailing list