title: Dealing with nested cmake projects using FetchContent_
body: <p>I am looking to automate the compilation of a given c++ library (in this case, cpprestsdk). I am looking to build the library using cmake.
  Like many other projects, this has dependencies. Namely, it requires OpenSSL, Boost, ZLIB and websocketpp.</p>
  
  <p>I'm looking for a way in which I can provide a CMakeLists file that will fetch and build all of the prerequisites and allow cpprestsdk to build without necessarily having the libraries pre-installed on a computer.</p>
  
  <p>The way I am fetching cpprestsdk is as follows:</p>
  
  <pre><code>FetchContent_Declare(cpprestsdk
                      GIT_REPOSITORY https://github.com/microsoft/cpprestsdk.git
                      GIT_TAG        master)
  FetchContent_GetProperties(cpprestsdk)
  if(NOT cpprestsdk_POPULATED)
      FetchContent_Populate(cpprestsdk)
      add_subdirectory(${cpprestsdk_SOURCE_DIR} ${cpprestsdk_BINARY_DIR})
  endif()
  </code></pre>
  
  <p>Of course, since this does not populate it's own dependencies, it will not be able to build. Although websocketpp has an embedded release, it is only used if not found. For this reason, I will use it as an example.</p>
  
  <pre><code>FetchContent_Declare(websocketpp
                      GIT_REPOSITORY https://github.com/zaphoyd/websocketpp.git
                      GIT_TAG        master
                      )
  
  FetchContent_GetProperties(websocketpp)
  
  if(NOT websocketpp_POPULATED)
      FetchContent_Populate(websocketpp)
      add_subdirectory(${cpprestsdk_SOURCE_DIR} ${cpprestsdk_BINARY_DIR})
  endif()
  </code></pre>
  
  <p>This will fetch websocketpp, but as it is only the configure stage, nothing will be built. For this reason, cpprestsdk will not be able to find the dependency and instead fallback to the embedded release.</p>
  
  <p>My question is therefore: Is there any way I can force a build after fetching a package? Or remove the library requirement during the configure stage? I think this may be possible using ExternalProject instead, however I'm not too sure how I would set that up either.</p>