[CMake] Rebuild target when external library changes?
Lezz Giles
lgiles at SoapStoneNetworks.com
Tue Dec 2 17:07:32 EST 2008
I have a project set up that imports libraries, and I want to relink if those imported libraries change;
For example, in a directory I have
hellow.c
libfred.a
CMakeLists.txt
where CMakeLists.txt contains:
-----------------------------------------
LINK_DIRECTORIES(.)
ADD_EXECUTABLE(hellow hellow.c)
TARGET_LINK_LIBRARIES(hellow fred)
-----------------------------------------
I run 'cmake .'
Now if I touch hellow.c, hellow rebuilds, but if I touch libfred.a then hellow doesn't rebuild.
I've tried every method I can think of to add a dependency from the executable on the library, but I can't work out how to do it.
One trick that I have found, which is unsatisfying in many ways, is:
-------------------------------------------
INCLUDE(AddFileDependencies)
LINK_DIRECTORIES(.)
ADD_EXECUTABLE(hellow hellow.c)
ADD_FILE_DEPENDENCIES(hellow.c libfred.a)
TARGET_LINK_LIBRARIES(hellow fred)
--------------------------------------------
Can anybody help?
Thanks,
Lezz Giles
Soapstone Networks
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20081202/99ce3b61/attachment.htm>
More information about the CMake
mailing list