[CMake] Relinking static libs

Ilya Shvetsov chvetsov at kranx.com
Wed Apr 9 10:49:04 EDT 2008


> You must use a FULL path to the library or CMake will not know what  
> depend information to add.  If you have:
> add_executable(foo foo.c)
> link_directories(foobar)
> target_link_libraries(foo A B C)
>
> And A, B and C are libraries in the foobar directory that are not built  
> by CMake, then there will be no depends on the external libraries as  
> CMake does not know where they are.
>
> The correct thing to do would be:
>
> find_library(ALIB A)
> find_library(BLIB B)
> find_library(CLIB C)
> target_link_libraries(foo "${ALIB}" "${BLIB}" "${CLIB}")
>
> Then CMake will have the full path to A,B, and C, and if one of them  
> changes foo will be relinked.
>
Thanks. It works now.

-- 
Ilya Shvetsov
KranX Productions


More information about the CMake mailing list