title: How do I link SDL2 using CMake?
body: <p>I used the <code>.cmake</code> files from <a href="https://github.com/brendan-w/collector/tree/master/cmake" rel="nofollow noreferrer">https://github.com/brendan-w/collector/tree/master/cmake</a>, and I put them in the same directory as my CMakeLists.txt, then I used the code:</p>
  
  <pre><code>set(CMAKE_MODULE_PATH FindSDL2.cmake FindSDL2_image.cmake)
  find_package(SDL2 REQUIRED)
  </code></pre>
  
  <p>but I'm getting the error:</p>
  
  <pre><code>CMake Error at CMakeLists.txt:26 (find_package):
    By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
    asked CMake to find a package configuration file provided by "SDL2", but
    CMake did not find one.
  
    Could not find a package configuration file provided by "SDL2" with any of
    the following names:
  
      SDL2Config.cmake
      sdl2-config.cmake
  
    Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
    "SDL2_DIR" to a directory containing one of the above files.  If "SDL2"
    provides a separate development package or SDK, be sure it has been
    installed.
  </code></pre>