[CMake] Preserving path information when installing headers

Owen Shepherd owen.shepherd at e43.eu
Sat May 28 10:13:19 EDT 2011


I have a project setup like this:

set(OT_HEADERS
Headers/ObjectTools/_RawFormat/COFF.h
Headers/ObjectTools/Format/COFF.h
Headers/ObjectTools/Object.h
Š
Š
)

add_library(ObjectTools SHARED ${OT_SOURCES} ${OT_HEADERS} ${OT_RESOURCES})

set_target_properties(ObjectTools PROPERTIES
VERSION 0.1.0
SOVERSION 0
RESOURCE "${OT_RESOURCES}"
PUBLIC_HEADER   "${OT_HEADERS}"
FRAMEWORK ${FRAMEWORK})

install(TARGETS ObjectTools
ARCHIVE DESTINATION lib
LIBRARY DESTINATION lib
RUNTIME DESTINATION bin
FRAMEWORK DESTINATION Library/Frameworks
BUNDLE DESTINATION Applications
PUBLIC_HEADER DESTINATION include/ObjectTools
RESOURCE DESTINATION share/ObjectTools)

As you can see, my headers are not laid out in a flat format, and worse,
some have the same file names (This is because the Format/ headers wrap the
(internal) headers in _RawFormat. The trouble I'm having is that CMake
strips all path information when installing the headers ­ resulting in the
headers being in the wrong place (and therefore the cross references being
broken).

I don't see any information in the documentation on how to avoid this from
being an issue ­ is it even possible? If its not, perhaps the next release
of CMake could include a target property to set the header prefix. Perhaps
something like

> PUBLIC_HEADER_PREFIX:
>> Specifies the prefix to be removed from headers when installing them, or
>> copying them to the Headers directory  within a Mac OS X bundle. For example,
>> if you set this value to "include/MyFramework/", and specify a public header
>> named "include/MyFramework/MyHeader.h" will be installed as "MyHeader.h"
>> relative to the include path.
>> 
An alternative option would be similar to the above, except CMake will
additionally strip the framework's (output) name when building on Mac OS X,
since the framework lookup rules will cause the framework name to be
automatically re-inserted.

Many thanks,

-- Owen Shepherd
http://www.owenshepherd.net
owen.shepherd at e43.eu (general) / oshepherd1 at shef.ac.uk (academic)


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://www.cmake.org/pipermail/cmake/attachments/20110528/e9fd1070/attachment-0001.htm>


More information about the CMake mailing list