CMake: Redundant linking when modifying shared libraries

It turns out that the answer lies in the LINK_DEPENDS_NO_SHARED property. In my example, all that is needed is to add the following line to the Demo/CMakeLists.txt file:

set_target_properties(helloDemo PROPERTIES LINK_DEPENDS_NO_SHARED true)

This will prevent helloDemo from being relinked when one of its dependencies updates - if that dependency is a shared library.

On a more complex system, where some libs are also dependent on other libs, it can be useful to add this setting to their configuration as well.

Thanks to Craig Scott of the CMake mailing list for his help, archived at this link.

Tags:

C++

Cmake