The best way to preserve structure is to layout the source directory exactly as you want it, and then use a single install(DIRECTORY command. If it's not in your source tree exactly as you want it, you could add a custom build step to arrange such a directory in your build tree, and then use install(DIRECTORY on that.<br>
<br><div>An alternative would be to group headers that go together using variables, one per destination directory, and then have one install(FILES rule for each separate destination directory.<br><div><br></div><div><br><div>
HTH,</div><div>David</div><div><br></div><div><br><div class="gmail_quote">On Fri, Oct 15, 2010 at 7:00 AM, Daniel Pfeifer <span dir="ltr"><<a href="mailto:daniel@pfeifer-mail.de">daniel@pfeifer-mail.de</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
<br>
This question has been asked quite a few times, but never satisfactorily<br>
answerded before: How do I install a bunch of headers preserving<br>
directory structure? The following snippet<br>
<br>
> set(HEADERS header1.h dir/header2.h)<br>
> install(FILES ${HEADERS} DESTINATION include)<br>
<br>
puts both files inside the same directory. The structure is not<br>
preserved. The following workaround does the trick:<br>
<br>
> foreach(HEADER HEADERS)<br>
> string(REGEX MATCH "(.*)[/\\]" DIR ${HEADER})<br>
> install(FILES ${HEADER} DESTINATION include/${DIR})<br>
> endforeach(HEADER HEADERS)<br>
<br>
However, I consider this as a workaround, not as a solution!<br>
<br>
It gets more complicated as soon as I want to build frameworks on mac,<br>
<br>
> set_target_properties(my_lib PROPERTIES PUBLIC_HEADER ${HEADERS})<br>
<br>
again puts both files inside the same directory, ignoring structure.<br>
Here the workaround is even less a solution, if this is really the only<br>
way: <<a href="http://www.cmake.org/pipermail/cmake/2008-June/022378.html" target="_blank">http://www.cmake.org/pipermail/cmake/2008-June/022378.html</a>><br>
<br>
Hasn't this been considered before? The public wiki shows two use cases<br>
of cmake frameworks, but neither of them puts headers into a directory<br>
hierarchy. <<a href="http://www.cmake.org/Wiki/CMake:MacOSX_Frameworks" target="_blank">http://www.cmake.org/Wiki/CMake:MacOSX_Frameworks</a>><br>
<br>
cheers, Daniel<br>
<br>
<br>
_______________________________________________<br>
Powered by <a href="http://www.kitware.com" target="_blank">www.kitware.com</a><br>
<br>
Visit other Kitware open-source projects at <a href="http://www.kitware.com/opensource/opensource.html" target="_blank">http://www.kitware.com/opensource/opensource.html</a><br>
<br>
Please keep messages on-topic and check the CMake FAQ at: <a href="http://www.cmake.org/Wiki/CMake_FAQ" target="_blank">http://www.cmake.org/Wiki/CMake_FAQ</a><br>
<br>
Follow this link to subscribe/unsubscribe:<br>
<a href="http://www.cmake.org/mailman/listinfo/cmake" target="_blank">http://www.cmake.org/mailman/listinfo/cmake</a><br>
</blockquote></div><br></div></div></div>