Lets say I have two CMake projects - an ExternalProject E and my current project P. E provides two ways to interface with it - It creates a pkg-config file and .cmake file. I wish to use either of these two options to for using E in P.
In P's build, I need to achieve the following steps:
- Build E
- Install E. This step would create pkg-config files (
E.pc) or CMake exported targets file (ETargets.cmake) - Use
E.pcorETargets.cmakein P for including E's headers and linking against E's libraries.
I couldn't get my build to work with following options:
include(ETargets.cmake)in P's CMakeLists.txt. This doesn't work sinceETargets.cmakeis not present at configure time.- I didn't find a way to extract information in E.pc from CMakeLists.txt in CMake's documentation.
add_custom_commandandadd_custom_targetroute detailed here for dealing with generated files. This might/might not work, but either way it will introduce lot of boiler plate in my build.
Only solutions I can find are
- Install E manually and then use
.cmakeor.pcfiles in P (detailed in answers here). - Manually scavenging through directory installed by E to find required libraries. (detailed here).
Both the solutions outsource some work to outside of CMake build hence are not satisfactory.