title: propagate dependencies to header-only ExternalProject with cmake
body: <p>I'm trying to build a header-only library using CMake (<a href="https://github.com/Microsoft/GSL" rel="nofollow">Microsoft/GSL</a>), in such a way that I can use variables like <code>GSL_INCLUDE_DIRS</code> and <code>GSL_LIBRARIES</code> to link to the target and propagate the appropriate dependencies.</p>
  
  <p>The project I'm working on has a TON of sub-directories, and all the external projects are built in their own sub-directories, hence why the variables are important.</p>
  
  <p>I'm using CMake 3.2.3</p>
  
  <p>Typically (for a library with an actual .lib or .a) I'd do something like:</p>
  
  <pre><code>SET(TARGET_NAME gsl)
  
  include(ExternalProject)
  ExternalProject_Add(
      ${TARGET_NAME}-ext
      URL "http://target/url"
      CONFIGURE_COMMAND ""
      BUILD_COMMAND ""
      INSTALL_COMMAND ""
  )   # download/unzip the header-only project
  
  # Specify include dir
  SET(${TARGET_NAME}_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/include CACHE STRING "${TARGET_NAME} include directory")
  
  # Library
  add_library(${TARGET_NAME} SHARED IMPORTED GLOBAL)
  SET_TARGET_PROPERTIES(${TARGET_NAME} PROPERTIES 
      IMPORTED_LOCATION "some/path/to/some/lib"
  )
  add_dependencies(${TARGET_NAME} ${TARGET_NAME}-ext)
  SET(${TARGET_NAME}_LIBRARIES ${TARGET_NAME} CACHE STRING "${TARGET_NAME} library location")
  
  MARK_AS_ADVANCED(${TARGET_NAME_UPPER}_DIR ${TARGET_NAME_UPPER}_INCLUDE_DIRS ${TARGET_NAME_UPPER}_LIBRARIES)
  </code></pre>
  
  <p>The problem here is that the header-only library has no lib to set the imported path for, so I can't use an <code>IMPORTED</code> library. If I don't use a library at all, then I can't set the dependencies in other modules on GSL without building (i.e. downloading/unzipping) <em>every single time</em>, which I don't want to do. a <code>custom_target</code> would have the same problem, so that's a no-go.</p>
  
  <p>I think what I want is an interface library, something like</p>
  
  <pre><code>add_library(${TARGET_NAME} INTERFACE)
  add_dependencies(${TARGET_NAME} ${TARGET_NAME}-ext)
  </code></pre>
  
  <p>but then cmake complains that</p>
  
  <blockquote>
    <p>CMake Error at 3rdParty/gsl/CMakeLists.txt:33 (add_dependencies):
      add_dependencies Cannot add target-level dependencies to INTERFACE library
      target "gsl".</p>
  </blockquote>
  
  <p>Is there someway I can use the interface library (or something) to propagate the dependency on the external project?</p>