title: How could one install dependencies using CMake?
body: <p>I have been trying to figure out the best way to handle dependencies in my C++ projects. For smaller libraries, like <code>fmt</code>, it is not too difficult to just add the following:</p>
  <pre><code>include(FetchContent)
  FetchContent_Declare(FormatLib
    GIT_REPOSITORY &quot;https://github.com/...&quot;
    GIT_TAG &quot;...&quot;
  )
  FetchContent_MakeAvailable(FormatLib)
  </code></pre>
  <p>However, it is undesirable to have the project downloaded into the build directory every time with larger dependencies, for example, the Vulkan Loader which depends on other things.
  What I would like would be the ability to do something like, before or at configure time of my main project, to download, configure, build and install a library system wide. I do not know if this is a feature possible with CMake but any help would be appreciated.</p>
  <p>I also know that the <code>ExternalProject</code> module has existed in CMake for a long time now, and would be perfect for what I want, I think... if I were able to use it to install a library <em>before</em> I would then call <code>find_package</code> inside the same <code>CMakeLists.txt</code></p>
  <p>I purchased and read a considerable amount of the &quot;Professional CMake 8th Edition&quot; but still don't know if such a feature or technique exists in CMake.</p>
  <p>I should clarify that I don't need the Vulkan loader, I was just giving an example. In the case of the Vulkan loader, if you have the SDK already installed, you can use the built in <code>find_package</code> command. My question is whether there's a way to populate such a library before hand. There are specific libraries that I haven't been able to find using package managers such as Conan and it seems like the best possible solution would be to actually just pull the source straight from an online git repo, build and install.</p>
  <p>So in conclusion, what I would like to be able to do is the following: Write a CMakeLists.txt that details all the dependencies of a project, possibly searches for the dependencies using <code>find_package</code>, if they're not found, it installs them system wide so that from there on out, every build of said project or similar project on the system has access to the package installed.</p>
  <p>Any advice, insight or suggestions on how I can mitigate this problem or even how my desired development strategy is flawed would be appreciated.</p>