One of the possible ways to prepare your dependencies from the source is to use CMake's built-in FetchContent module. It will download your dependencies and then build them for you as a regular target.
The feature arrived in CMake 3.11. It's a replacement for the ExternalProject module, which had many flaws. One of them was that it cloned the external repository during build time, so CMake couldn't reason about the targets that the external project defined, as well as about their dependencies. This made many projects resort to manually defining the include directories and library paths of such external targets and ignoring their required interface compilation flags and dependencies completely. Ouch. FetchContent doesn't have such issues, so it's recommended you use it instead.