[CMake] How to export headers

Michael Surette mjsurette at gmail.com
Fri Mar 12 10:53:02 EST 2010


On 03/12/2010 12:55 AM, Michael Wild wrote:
>
> 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
> _______________________________________________
> 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
>

Thanks, that sounds just too easy.

Mike




More information about the CMake mailing list