I’m building using ExternalProject_Add. This will export a cmake file. Now I want to include that cmake file to import the targets. How can that be done? E.g. adding include requires the file to exist in the configure step.
You cannot use the products of an
ExternalProject call within the same project that contains that
ExternalProject_add call. You’ll need sibling
ExternalProject calls with the appropriate dependencies.
Building external projects and importing them is quite some work with cmake. It would be good to use exported targets and import them. Can this be done by ExternalProject_Add_Step?
add_step adds code to be run at build time, but anything right after the call in the CMake code is still in the configure step.
It sounds like you probably want
FetchContent instead. @craig.scott
FetchContent can use exported install targets.
FetchContent does the download as part of configure step? Or can I use git submodules with
FetchContent is good if you have control of the project being fetched, but my case is for 3pp sw.
I’m not that familiar with
FetchContent, but yes, I believe that downloads are done during the configure step. I think you can use it with git submodules too. I do know people use it for third party software, but the project does need to be “sane” and have some semblance of support for being embedded in another project.
If that doesn’t work, you’ll probably need to use a “superbuild” setup where your third party and own project(s) are all built using
ExternalProject and find each other via