Export sets with targets in subdirectory

I am attempting to install my project foo which has a dependency bar which is included as a git submodule and consumed in my cmake project via add_subdirectory(bar). bar is a library that is intended to be consumed via add_subdirectory or via a system installation and find_project(bar). However, during the generate step I get the following error:

CMake Error in src/CMakeLists.txt:
export called with target "foo" which requires target "bar" that is not in any export set.

My installation-relevant CMake lines are:

include(GNUInstallDirs)
install( TARGETS foo EXPORT fooTargets
  ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
  RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(EXPORT fooTargets FILE foo-targets.cmake DESTINATION share/cmake/foo)

the ‘bar’ library includes installation instructions similar to foo, just swapping foo for bar.

I would like to keep the installations of foo and bar separate, as bar has its own dependencies that are consumed from system installations via find_package or find_dependency and I would like to avoid having to copy bar’s find_dependency calls in bar-config.cmake into foo-config.cmake.

That should be possible. It just seems that the bar subproject is missing/skipping an install(EXPORT) for the export set it uses.