[CMake] Relinking static libs

Jean Lepropre jean.lepropre at star-apic.com
Wed Apr 9 11:13:48 EDT 2008


Hi Bill,

Is it the same thing if static lib is built by CMake?

Cheers,
Jean.


Message: 2
Date: Wed, 09 Apr 2008 08:35:17 -0400
From: Bill Hoffman <bill.hoffman at kitware.com>
Subject: Re: [CMake] Relinking static libs
To: Ilya Shvetsov <chvetsov at kranx.com>
Cc: "cmake at cmake.org" <cmake at cmake.org>
Message-ID: <47FCB805.30309 at kitware.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed

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.

-Bill


More information about the CMake mailing list