[CMake] How to export headers

Michael Wild themiwi at gmail.com
Fri Mar 12 00:55:00 EST 2010


On 12. Mar, 2010, at 24:25 , Michael Surette wrote:

> 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

Don't APPEND the stuff to mylibConfig.cmake, but write it e.g. to mylibLibraries.cmake and INCLUDE() that in your mylibConfig.cmake. The latter you create from a mylibConfig.cmake.in where you configure all the paths, including MYLIB_INCLUDE_DIR.


HTH

Michael


More information about the CMake mailing list