title: How to require a header-only library without binary in cmake?
body: <p>I created a header-only library, which is installed with cmake using</p>
  
  <pre><code>add_library(mylib INTERFACE)
  </code></pre>
  
  <p>and exported targets.
  This works fine, when I use <code>find_package(mylib REQUIRED)</code> and <code>target_link_library</code> in the cmake file of another library (<code>mylib2</code>), which includes the headers.</p>
  
  <p>But when I link against <code>mylib2</code> using exported targets and <code>target_link_library</code>, the generated VS files contain <code>mylib.lib</code> in the link libraries.</p>
  
  <p>When I look for the string <code>mylib.lib</code> in the generated files of all three projects, only the visual studio files contain this, none of the <code>PackageConfig</code> or <code>PackageTargets</code> files contain the filename.</p>
  
  <p>The header-library uses exported targets this in its CMakeLists.txt</p>
  
  <pre><code>add_library(mylib INTERFACE)
  target_compile_definitions(mylib INTERFACE -D_USE_MATH_DEFINES)
  target_link_libraries(mylib INTERFACE somelibraries)
  target_include_directories(mylib INTERFACE
          $&lt;INSTALL_INTERFACE:include&gt;
          $&lt;BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include&gt;
  )
  configure_package_config_file(mylibConfig.cmake.in ${CMAKE_CURRENT_BINARY_DIR}/mylibConfig.cmake INSTALL_DESTINATION ${CMAKE_INSTALL_PREFIX})
  install(TARGETS mylib EXPORT mylib-targets)
  install(EXPORT mylib-targets FILE mylibTargets.cmake DESTINATION ${CMAKE_INSTALL_PREFIX})
  install(FILES ${CMAKE_CURRENT_BINARY_DIR}/mylibConfig.cmake DESTINATION ${CMAKE_INSTALL_PREFIX})
  install(DIRECTORY ./ DESTINATION include FILES_MATCHING PATTERN "*.h")
  </code></pre>
  
  <p>The second library just uses</p>
  
  <pre><code>find_package(mylib REQUIRED)
  add_library(mylib2 source.cpp)
  target_link_libraries(mylib2 mylib)
  # some stuff to export targets, similar to the first lib
  </code></pre>
  
  <p>And the final project uses</p>
  
  <pre><code>add_binary(myproject source.cpp)
  set(LINK_LIBRARIES mylib2)
  target_link_libraries(myproject ${LINK_LIBRARIES}) # mylib2.lib is added to the project.
  
  add_binary(myproject2 source.cpp)
  target_link_libraries(myproject mylib2) # only the include paths are added.
  </code></pre>
  
  <p>The problem only happens when the libraries are set from a variable.</p>
  
  <p>At which point of the process does cmake add the library filename to the link-libraries? Shouldn't it inherit the <code>INTERFACE</code> property?</p>