[CMake] INTERFACE libraries and <lib>-config.cmake files

Saad Khattak saadrustam at gmail.com
Mon Dec 4 17:17:23 EST 2017


Hi,

I have an interface library and I am not sure how I would get CMake to
generate the usual <lib>-config.cmake file for the library so that I can
then use "find_package" on the interface library from an external project.

I am adding (and installing) the library like this:

add_library(myLib INTERFACE)
target_include_directories(myLib INTERFACE
    $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
    $<INSTALL_INTERFACE:include/>
    )

and then installing like this:

install(TARGETS myLib EXPORT myLib_targets INCLUDES DESTINATION include)
install(EXPORT myLib_targets DESTINATION "lib/cmake")
install(FILES ${MY_HEADERS} DESTINATION "include/")

Obviously, I am doing it wrong or missing some steps as I do not see the
myLib-config.cmake file anywhere in the install folder (or the build
directory for that matter) that is usually generated when using install
commands.

Ultimately, I would like to use the "find_package" command on the interface
library from another CMake project.

Thank you,
Saad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://public.kitware.com/pipermail/cmake/attachments/20171204/e019bd67/attachment.html>


More information about the CMake mailing list