[CMake] How does binary link with static library?

Jong-young Park eminency at gmail.com
Mon Mar 5 00:00:42 EST 2007


Dear all.
Thanks for replying before.

I have 1 more question.

With your help, I can make both(shared & static) libraries.

However, in my bin/ directories, target must link with static library.

for example, there two directories.

bin/
  bin.c
lib/
  libmy.a
  libmy.so

I wanna make binary like following :
  "gcc -o bin bin.c ../lib/libmy.a -lpthread -lcrypt"


For this, I make CMakeLists.txt like following :
...
LINK_DIRECTORIES(../lib)
LINK_LIBRARIES(crypt pthread my)
ADD_EXECUTABLE(bin bin.c)
...

But that is linked with shared library.
LINK_LIBRARIES command doesn't have 'static' option, I think...

So, I try like this :
...
LINK_LIBRARIES(crypt pthread)
ADD_EXECUTABLE(bin bin.c ../lib/libmy.a)
...


It doesn't work...:(

Can I link statically with specific library?
Maybe, must I use cmake properties?

Thanks for reading.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://public.kitware.com/pipermail/cmake/attachments/20070305/4bee3ada/attachment.htm


More information about the CMake mailing list