title: cmake install library and development files as separate components using PUBLIC_HEADER
body: <p>I wish to create two packages one containing a shared library and the other containing the headers for use by development.</p>
  
  <p>A solution that works is:</p>
  
  <pre><code>INSTALL(TARGETS mylib
    COMPONENT core
    LIBRARY DESTINATION ${LIBDIR}
  )
  INSTALL (
      DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
      COMPONENT devel
      DESTINATION ${INCLUDEDIR}
      FILES_MATCHING PATTERN "*.h")
  </code></pre>
  
  <p>However CMake also has a "PUBLIC_HEADER" destination.
  Such that you can do something like:</p>
  
  <pre><code>INSTALL(TARGETS mylib
    LIBRARY DESTINATION ${LIBDIR}
    PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
  )
  </code></pre>
  
  <p>I can't seem to get this to work. Nothing is installed to ${INCLUDEDIR} even if header files are explicitly added to ADD_LIBRARY(). Can someone point to an example of how this is supposed to work?</p>
  
  <p>Another issue with this is that I want the library and the headers in different packages so ideally I want:</p>
  
  <pre><code>INSTALL(TARGETS mylib
    COMPONENT core
    LIBRARY DESTINATION ${LIBDIR}
  )
  INSTALL(TARGETS mylib
    COMPONENT devel
    PUBLIC_HEADER DESTINATION ${INCLUDEDIR}
  )
  </code></pre>
  
  <p>But PUBLIC_HEADER seems to require LIBRARY DESTINATION is set.
  Is there a way to do this?
  Are there any advantages of PUBLIC_HEADER over install DIRECTORY anyway?</p>