find_package in external project

Is it possible to use find_package from a component that is built as an external project?

I believe find_package is executed at configure time, but the cmake files required for find_package are installed when external project is built. Want to avoid building external project at configure time.

I believe you want FetchContent, not ExternalProject. Using ExternalProject_add in the same build as add_library trying to consume those bits doesn’t work well. You can do ExternalProject_add for your code to make everything use ExternalProject as an alternative.

I thought FetchContent only downloads at configure time (i.e. no build at configure time)? For the find_package to succeed, the external software has to be built and installed.

Two ExternalProject_add with DEPENDS might work, but a bit clumsy as there is really only one external (3pp) software to be built (don’t want to build my native software as an external).

The “everything is external” is known as a “superbuild” and is basically a packaging setup in miniature. Each build is, itself, independent, but is just built as part of a larger whole. If you want find_package to work, you’ll need something like this to order the build and installation against each other.