[CMake] Install header dir hierarchy with PUBLIC_HEADER

Gavin Beatty gavinbeatty at gmail.com
Sun Jun 22 08:45:40 EDT 2008


I cannot figure out how to install headers in a directory hierarchy
using Mac Frameworks and PUBLIC_HEADER without this awful kludge.

What I have at the moment is:
<CMakeLists_extract>

set(FLAT_HDRS )
list(APPEND FLAT_HDRS
Flat.hpp
)
set(SRCS )
list(APPEND SRCS
Src.cpp
)
add_library(MyTarget SHARED "${SRCS}" )
set_target_properties(MyTarget
                      PROPERTIES    FRAMEWORK               TRUE
                                    PUBLIC_HEADER           "${FLAT_HDRS}"
)
# install the framework and headers
install(TARGETS                                 MyTarget
        FRAMEWORK           DESTINATION         ${FRAMEWORK_DIR}
        RUNTIME             DESTINATION         ${RUNTIME_DIR}
        LIBRARY             DESTINATION         ${LIBRARY_DIR}
        ARCHIVE             DESTINATION         ${ARCHIVE_DIR}
        PUBLIC_HEADER       DESTINATION         ${HEADER_DIR}
)
# reset the target PUBLIC_HEADER property
set(DIR_HDRS )
list(APPEND DIR_HDRS
Dir/NonFlat.hpp
)
set_target_properties(MyTarget
                      PROPERTIES    PUBLIC_HEADER           "${DIR_HDRS}"
)
# MUST _repeat_ all other target stuff like LIBRARY etc...
install(TARGETS                                 MyTarget
        FRAMEWORK           DESTINATION         ${FRAMEWORK_DIR}
        RUNTIME             DESTINATION         ${RUNTIME_DIR}
        LIBRARY             DESTINATION         ${LIBRARY_DIR}
        ARCHIVE             DESTINATION         ${ARCHIVE_DIR}
        PUBLIC_HEADER       DESTINATION         ${HEADER_DIR}/Dir
)

</CMakeLists_extract>

If it hurts, stop doing it? Shall I discontinue using PUBLIC_HEADER?

-- 
Gavin Beatty

SEMPER UBI SUB UBI
GPG Fingerprint: 354D 9E9C 5C66 EDF4 E7D9 0EC5 6A7A C55D 49DD 695F


More information about the CMake mailing list