title: Make an external project available for find_package CMake
body: <p>In my project I have a dependency <strong>&quot;A&quot;</strong> that has another library dependency <strong>&quot;B&quot;</strong>, I'm trying to download and install the dependency B before A in order to clear the conflict. I'm using <code>Externalproject_add</code>, <code>FetchContent_Declare</code> and <code>install</code>, but it fails.</p>
  <p>for an example</p>
  <p>I got a CMakeList.txt like:</p>
  <pre><code>FetchContent_Declare(  libpng
          GIT_REPOSITORY      https://github.com/glennrp/libpng.git
          GIT_TAG             master
          UPDATE_DISCONNECTED TRUE
          STEP_TARGETS        update
          )
  
  FetchContent_GetProperties(libpng)
  if (NOT libpng_POPULATED)
      FetchContent_Populate(libpng)
      add_subdirectory(&quot;${libpng_SOURCE_DIR}&quot; ${libpng_BINARY_DIR} EXCLUDE_FROM_ALL)
  endif()
  </code></pre>
  <p>The CMakeList.txt of this libpng has the line <code>find_package(ZLIB REQUIRED)</code> , at this point I could download and install manually the zlib, but since I'm developing a library I would like my code to take care of this dependency. Also I cannot modify the CMakeList.txt of libpng. So, I have this code but it continues to fail.</p>
  <pre><code>FetchContent_Declare(  zlib
          GIT_REPOSITORY      https://github.com/zlib-ng/zlib-ng.git
          GIT_TAG             develop
          UPDATE_DISCONNECTED TRUE
          STEP_TARGETS        update
          )
  FetchContent_GetProperties(zlib)
  if (NOT zlib_POPULATED)
      FetchContent_Populate(zlib)
      add_subdirectory(&quot;${zlib_SOURCE_DIR}&quot; ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
  endif()
  install(TARGETS zlib)
  </code></pre>
  <p>I'm still starting with CMake and I continuous learning but it's hard to find proper examples.</p>
  <p>So, How can I install a external project in order to make it available for find_package?</p>