title: CMake: Target links to transitive dependency target but the target was not found
body: <p>I have a simple cmake setup between two projects, a library project and an executable project. The library project I want to be installed on the system (Linux container), and the executable project I want to link with the library package after finding it with find_package(XXX CONFIG). I successfully build and install the library project just fine, however, when I configure the executable project I get an error in the vein of</p>
  <blockquote>
  <p>CMake Error at MyExecutable/CMakeLists.txt:35 (add_executable):
  Target &quot;MyExecutable&quot; links to target &quot;CUDA::toolkit&quot; but the target was
  not found.  Perhaps a find_package() call is missing for an IMPORTED
  target, or an ALIAS target is missing?</p>
  </blockquote>
  <p>CUDA::toolkit is a PRIVATE target linked to the library project.</p>
  <p>The CMakeLists.txt for the library project looks like this</p>
  <pre><code>add_library(SiftCuda ${SOURCES} ${CUDA_KERNELS})
  target_link_libraries(MyLibrary PRIVATE
      CUDA::cudart
      CUDA::cublas
  )
  
  set_target_properties(MyLibrary PROPERTIES 
      PUBLIC_HEADER &quot;${HEADERS}&quot; 
      CUDA_SEPARABLE_COMPILATION ON
  )
  
  target_include_directories(MyLibrary PUBLIC
      $&lt;BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include&gt;  
      $&lt;INSTALL_INTERFACE:include/MyLibrary&gt;
  )
  
  target_compile_features(MyLibrary PUBLIC 
      cxx_std_11
  )
  
  # Alias library
  add_library(MyLibrary::MyLibrary ALIAS MyLibrary)
  
  ###### Installation  #####
  include(GNUInstallDirs)
  
  # Install library
  install(TARGETS MyLibrary
      EXPORT MyLibraryConfig
      PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/MyLibrary
  )
  
  # For exposing internal configuration of the package
  export(
      TARGETS MyLibrary
      NAMESPACE MyLibrary::
      FILE &quot;${CMAKE_CURRENT_BINARY_DIR}/MyLibraryConfig.cmake&quot;
  )
  
  # Install exports
  install(EXPORT MyLibraryConfig
      DESTINATION &quot;${CMAKE_INSTALL_LIBDIR}/cmake/MyLibrary&quot;
      NAMESPACE MyLibrary::
  )
  </code></pre>
  <p>The CMakeLists.txt for the executable looks like this</p>
  <pre><code>find_package(MyLibrary CONFIG)
  add_executable(MyExe
      ${SOURCES}
  )
  
  target_link_libraries(MyExe PUBLIC
      MyLibrary::MyLibrary
  )
  </code></pre>
  <p>I get the feeling that linking MyExe to the CUDA targets would resolve this issue, however, doing so seems incorrect as I usually don't have to be aware of transitive dependencies for libraries I use.</p>