title: Is it possible to call a custom CMake function when library is linked?
body: <p>Let's say I have a library <code>A</code> and a project <code>B</code> which uses <code>A</code>.</p>
  <pre><code>project(libA)
  
  function(calledWhenLink target)
      message(STATUS Hi ${target}) # Should print &quot;Hi exeB&quot;
  endfunction()
  
  add_library(libA INTERFACE)
  </code></pre>
  <pre><code>project(exeB)
  
  find_package(A REQUIRED)
  target_link_library(exeB libA)
  </code></pre>
  <p>Is it possible to automatically call <code>calledWhenLink()</code> when the executable links to the library ?</p>
  <p><strong>Reasoning</strong>: As said in a comment, the original problem is that VTK needs to call CMake vtk_module_autoinit. My library uses VTK, and it seems better for all the samples to automatically call this when linked to the lib instead of copy paste the code in each CMakeLists. The problem is that vtk_module_autoinit is not working when called with the lib target instead ot the exe in my tests.</p>