[CMake] Avoiding a relink

Brad King brad.king at kitware.com
Mon Mar 2 09:04:34 EST 2009


Philip Lowman wrote:
> On Fri, Feb 27, 2009 at 5:24 PM, Brad King <brad.king at kitware.com 
>     Try removing an object file from a shared library, rebuild just that
>     library,
>     and then run the executable (which still exists).  It will break at
>     runtime,
>     but if you try relinking the executable it will fail at build time
>     and the
>     executable will not exist anymore.
> 
> 
> Good point, although this could also be handled by forcing a relink 
> against the .so when adding or removing files from add_library().

One can create the same case just by removing one symbol from the .cpp file
of one object file.  CMake would have no knowledge of this.

>     Also, it is possible that the executable's source files do manual extern
>     declarations instead of including header files.  Then the shared library
>     API can change and break the executable at runtime too.
> 
> 
> You make a good point about the extern case.  Although I've never used 
> this technique before I'm sure there is source code out here that does it.
> 
> So, is the idea worth logging as a feature request as an opt-in 
> behavior?  It does seem like it would only be something CMake could 
> easily control with the Makefile generator.  On the whole I could see 
> this being very useful for projects that have lots of shared libraries 
> or plugins, however.

Sure.  I do not expect the implementation in the Makefile generators to
be hard. The question is what interface we should provide to enable it.
That can be discussed in the issue tracker.

-Brad


More information about the CMake mailing list