'CMake could not find SDL2

I want to add this library to my project. However, it does not come with pre-compiled files. It asks me to build the library myself with cmake, which I am not familiar with. One of its dependencies is SDL2. So I download the sdl2 development libraries folder. In cmake, I click configure and choose the generator. After a couple of seconds processing, a window pops up showing the error: Error in configuration process project files may be invalid

And this is what the log screen shows:

The C compiler identification is MSVC 18.0.40629.0
The CXX compiler identification is MSVC 18.0.40629.0
Check for working C compiler using: Visual Studio 12 2013
Check for working C compiler using: Visual Studio 12 2013 -- works
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working CXX compiler using: Visual Studio 12 2013
Check for working CXX compiler using: Visual Studio 12 2013 -- works
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Detecting CXX compile features
Detecting CXX compile features - done
CMake Error at C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:148 (message): Could NOT find SDL2 (missing: SDL2_INCLUDE_DIR SDL2_LIBRARY)
Call Stack (most recent call first):

C:/Program Files (x86)/CMake/share/cmake-3.4/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE) cmake/FindSDL2.cmake:18 (FIND_PACKAGE_HANDLE_STANDARD_ARGS) CMakeLists.txt:30 (FIND_PACKAGE)

Configuring incomplete, errors occurred!
See also "E:/game dev/libraries/libSDL2pp-master/build/CMakeFiles/CMakeOutput.log".

Could anyone tell me what to do? I am not sure that I am doing the right thing. Thank you.



Solution 1:[1]

cmake doesn't come with a module for finding sdl2 by default. That's most likely the reason why you provided your own in cmake/FindSDL2.cmake. As you are on windows, it is most likely that you have to set an environment variable to point to the sdl2 installation directory (but this is really something that depends on the FindSDL2.cmake that you use).

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Martin Gerhardy