How to bind SDL2 with CMake?

I used .cmake files from https://github.com/brendan-w/collector/tree/master/cmake and I put them in the same directory as my CMakeLists.txt, then I used the code:

set(CMAKE_MODULE_PATH FindSDL2.cmake FindSDL2_image.cmake)
find_package(SDL2 REQUIRED)

but I get an error:

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.
+4
source share

Source: https://habr.com/ru/post/1627872/


All Articles