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.
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. HTH, David On Fri, Oct 15, 2010 at 7:00 AM, Daniel Pfeifer <dan...@pfeifer-mail.de>wrote: > Hi, > > This question has been asked quite a few times, but never satisfactorily > answerded before: How do I install a bunch of headers preserving > directory structure? The following snippet > > > set(HEADERS header1.h dir/header2.h) > > install(FILES ${HEADERS} DESTINATION include) > > puts both files inside the same directory. The structure is not > preserved. The following workaround does the trick: > > > foreach(HEADER HEADERS) > > string(REGEX MATCH "(.*)[/\\]" DIR ${HEADER}) > > install(FILES ${HEADER} DESTINATION include/${DIR}) > > endforeach(HEADER HEADERS) > > However, I consider this as a workaround, not as a solution! > > It gets more complicated as soon as I want to build frameworks on mac, > > > set_target_properties(my_lib PROPERTIES PUBLIC_HEADER ${HEADERS}) > > again puts both files inside the same directory, ignoring structure. > Here the workaround is even less a solution, if this is really the only > way: <http://www.cmake.org/pipermail/cmake/2008-June/022378.html> > > Hasn't this been considered before? The public wiki shows two use cases > of cmake frameworks, but neither of them puts headers into a directory > hierarchy. <http://www.cmake.org/Wiki/CMake:MacOSX_Frameworks> > > cheers, Daniel > > > _______________________________________________ > Powered by www.kitware.com > > Visit other Kitware open-source projects at > http://www.kitware.com/opensource/opensource.html > > Please keep messages on-topic and check the CMake FAQ at: > http://www.cmake.org/Wiki/CMake_FAQ > > Follow this link to subscribe/unsubscribe: > http://www.cmake.org/mailman/listinfo/cmake >
_______________________________________________ Powered by www.kitware.com Visit other Kitware open-source projects at http://www.kitware.com/opensource/opensource.html Please keep messages on-topic and check the CMake FAQ at: http://www.cmake.org/Wiki/CMake_FAQ Follow this link to subscribe/unsubscribe: http://www.cmake.org/mailman/listinfo/cmake