[CMake] How to export headers

Michael Surette mjsurette at gmail.com
Thu Mar 11 18:25:54 EST 2010


I am installing a library with the following code

export(TARGETS mylib
    APPEND FILE mylibConfig.cmake
)
install(TARGETS mylib
    EXPORT mylib-install
    DESTINATION ${PREFIX_LIB}
)

where mylib has been previously been added as a library.

I am also installing a directory of headers as follows

install(DIRECTORY ${MYLIB_BINARY_DIR}/mylib
    DESTINATION include
    USE_SOURCE_PERMISSIONS
    )

This installs everything where I want, but I would like to export the 
headers as mylib_headers so that I can later do

find_package(mylib NO_MODULE)
include_directories(${mylib_headers})

Where ${mylib_headers} resolves to ${CMAKE_INSTALL_PREFIX}/include of my 
library install.

How do I do this with CMake 2.6?

Thank you.

Mike



More information about the CMake mailing list