[CMake] How to relink executables when depdent library got changed ?
Michael Wild
themiwi at gmail.com
Thu Jun 11 10:43:27 EDT 2009
On 11.06.2009, at 15:44, Bill Hoffman <bill.hoffman at kitware.com> wrote:
> Chih-pin Wu wrote:
>> Hi all:
>> I'm working on an embedded platform and building integrated
>> software as multimedia CE devices. And I am just started trying to
>> introduce CMake to replace my legacy environment constructed by
>> many hand-written gnu styled makefiles.
>> I have many components which is cross referred to each other very
>> complicatedly, and it really helps a lot when I started to migrate
>> to CMake with the benefit of automatic dependency checking.
>> However, my order of building is
>> i) build lots of libraries, called components
>> ii) then build final executable, called application, linking with
>> libraries
>> I really felt comfort when I modified some header files in the
>> component directory, and makefiles generated by CMake automatically
>> found it, rebuild all dependent source files as well as the
>> libraries.
>> However I could not make my final executable link those libraries
>> automatically when libraries got changed.
>> I used TARGET_LINK_LIBRARIES to enumerate linking libraries, also
>> ADD_DEPENDENCIES with these libraries.
>> But I still can't make it relink to a executable when those
>> libraries got changed, no matter it's rebuilt by makefile or
>> replaced by some newer revision.
>
> Can you post some of your cmake code? This should work. I suspect
> that you are not using full paths to libraries in
> target_link_libraries. add_dependencies should not be needed.
>
> -Bill
>
Actually, of your libraries are CMake targets themselves, everything
should work out of the box. I.e.:
add_library( comp1 file1.c file2.c )
add_executable( gadget file3.c file4.c )
target_link_libraries( gadget comp1 )
should create the library comp1 and the executable gadget, linking it
with the comp1 library. All with automatic dependency tracking.
HTH
Michael
More information about the CMake
mailing list