Or you can export ExternalLib directly from the build tree.
export(TARGETS ExternalLib FILE
"${PROJECT_BINARY_DIR}/ExternalLibTargets.cmake")
configure_file("${PROJECT_SOURCE_DIR}/ExternalLibConfig.cmake"
"${PROJECT_BINARY_DIR}/ExternalLibConfig.cmake")
export(PACKAGE ExternalLib)
with
Hello,
I have a project *ExternalLib* that uses CMake to build its libraries. I
then have my own project (separate from the external library) that needs to
include ExternalLib's headers and link with its libraries. ExternalLib does
not have a find_package module.
Since ExternalLib is also built
1. There is a (semi-)automatic way: you can export the targets of
ExternalLib with install(EXPORT...) from its CMakeLists.txt. In the
simplest cases you can use the generated export file as a config module:
install(TARGETS ... EXPORT externallib ...)
install(EXPORT externallib FILE