[CMake] Relink to shared libs

Matthew Woehlke matthew.woehlke at kitware.com
Thu Oct 25 12:56:21 EDT 2012


On 2012-10-24 10:35, DavidAllen wrote:
> I am currently looking at replacing my unix makefile (linux+gmake,
> solaris+make/gmake) and Windows VS projects, with cmake.
>
> For the makefiles I get gcc to output dependency files based on header file
> usage, using gcc options -MM -MF -MP -MT.
>
> This has worked really well for over a year. If I modify a cpp file that is
> used by the shared lib, then the executable does not re-link. If I modify a
> .h file that is used by the shared lib *and* the executable, then it WILL
> re-link.

I'm not sure that's correct behavior. What if the modification to the 
.cpp file was to remove the definition of a function declared in a 
header? Now your executable that was using that function will crash when 
you try to run it due to a missing symbol. If you had re-linked, you 
might instead get a link error letting you know something is wrong.

You could probably modify CMake to generate build rules that do not 
treat linked libraries as dependencies for a library/application link 
step, but I don't think I would consider that correct behavior.

-- 
Matthew



More information about the CMake mailing list