title: How to build an external library downloaded with CMake FetchContent?
body: <p>I have a program that depends on an external library (SDL for example). I want CMake to take care of that dependency for me, so I was looking into <code>FetchContent</code>. As far as I understand, this module simply downloads the source code so that information on the external library is available at <em>configure time</em>. For example:</p>
  <pre><code>include(FetchContent)
  
  FetchContent_Declare(sdl
    GIT_REPOSITORY &lt;...&gt;
  )
  
  FetchContent_GetProperties(sdl)
  
  # sdl_POPULATED, sdl_SOURCE_DIR and sdl_BINARY_DIR are ready now
  
  if(NOT sdl_POPULATED)
    FetchContent_Populate(sdl)
  endif()
  </code></pre>
  <p>At some point, however, I want to build that source code and link it to my main executable. How to do it the &quot;modern CMake way&quot;?</p>