[CMake] Relink on library rebuild dilema

Sebastian Schaetz seb.schaetz at gmail.com
Mon Nov 29 04:00:24 EST 2010


Bill Hoffman <bill.hoffman at ...> writes:

> No need for all the complication...
> 
> If you already know where the library is going to be:
> 
>   ${CMAKE_CURRENT_BINARY_DIR}/kernels/libkernel_executable.a
> 
> Then link directly to the full path:
> 
> target_link_libraries(main_target
>   ${CMAKE_CURRENT_BINARY_DIR}/kernels/libkernel_executable.a)
> 
> Now the makefiles will depend on that file and it will relink when that 
> .a changes.   This is why link_directories/*link_libraries without a 
> full path to the library is almost always a bad idea...

Sure enough, that works also! I have tried it before but did not realize that if
I want the target depend on a file instead of another target, not only do I have
to specify the full path but also the full filename so "libkernel_executable.a"
is necessary instead of "kernel_executable". In the latter case CMake seems to
believe this is another target, tries to build it and fails. Now it makes
perfect sense, thanks for the help, my problem is solved.



More information about the CMake mailing list