[CMake] Build/Link with static libs
Christian Lang
christian.lang at uni-bielefeld.de
Tue May 2 09:17:36 EDT 2006
Hi,
>Christian Lang wrote:
>
>
>>Alexander Neundorf schrieb:
>>
>>Hi,
>>
>>my first problem is solved: To link against "foo/libbar.a", the link
>>line options "-Lfoo -lbar" are produced. This works. But what if for
>>some reason I do not want to use it this way, but want to directly
>>specify "foo/libbar.a" at the link line (as I tried in the first place)?
>>Is this possible?
>>
>>
>
>You can specify the full path to libbar.a
>
>
Ok, but if I specify - for instance - "/path/foo/libbar.a"
(TARGET_LINK_LIBRARIES), cmake transforms it to "-L/path/foo -lbar" at
the link line ...
>>Regarding my second problem, I simply do not know how to tell cmake to
>>first build the static libs by recursing into the subdirs and then build
>>the main target by linking them together (at the top-level-dir)...
>>
>>
>
>ADD_SUBDIRECTORY(shared_lib1)
>ADD_SUBDITECTORY(shared_lib2)
>ADD_SUB...
>
>ADD_EXECUTABLE(exe ...)
>TARGET_LINK_LIBRARIES(exe shared_lib1 shared_lib2 ....)
>
>
Thank you, this works as long as there is at least one source file given
here: ADD_EXECUTABLE(exe sourefile1 ...). But in my project there are no
additional sourcefiles. "exe" consists of the static libs built in the
subdirectories only. And I do not want to use a "dummy" sourcefile. What
can I do?
Thanks,
Christian
More information about the CMake
mailing list