<div dir="ltr">2017-12-04 23:17 GMT+01:00 Saad Khattak <span dir="ltr"><<a href="mailto:saadrustam@gmail.com" target="_blank">saadrustam@gmail.com</a>></span>:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Hi,<div><br></div><div>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.</div><div><br></div><div>I am adding (and installing) the library like this:</div><div><br></div><div>add_library(myLib INTERFACE)</div><div>target_include_directories(<wbr>myLib INTERFACE</div><div>    $<BUILD_INTERFACE:${CMAKE_<wbr>CURRENT_SOURCE_DIR}/include><br>    $<INSTALL_INTERFACE:include/><br>    )<br><br>and then installing like this:<br><br>install(TARGETS myLib EXPORT myLib_targets INCLUDES DESTINATION include)</div><div>install(EXPORT myLib_targets DESTINATION "lib/cmake")<br></div><div>install(FILES ${MY_HEADERS} DESTINATION "include/")<br></div><div><br></div><div>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.</div><div><br></div><div>Ultimately, I would like to use the "find_package" command on the interface library from another CMake project.</div></div></blockquote><div><br></div><div>install(EXPORT myLib_targets ,..) will produce myLib_targets.cmake file if I remember correctly from the top of my head. Just rename it to "install(EXPORT mylib-config ...)" or create a new config file named "myLib-config.cmake" and include cmake script produced by the export in there.</div><div><br></div><div>You'll probably also want to create a version file with something like this:</div><div><br></div><div>include(CMakePackageConfigHelpers)<br>write_basic_package_version_file("mylib-config-version.cmake"<br>  VERSION ${myLib_VERSION}<br>  COMPATIBILITY SameMajorVersion<br>)<br>install(FILES "${CMAKE_CURRENT_BINARY_DIR}/mylib-config-version.cmake"<br>  DESTINATION lib/cmake<br>)<br><br></div></div>Hope this helps.</div><div class="gmail_extra"><br></div><div class="gmail_extra">Regards,</div><div class="gmail_extra">Domen<br></div></div>