I'm struggling to understand how to run cmake on windows to clone a project that uses SDL2

This is my first time using cmake, I cloned a project form github on my linux Virtual boxes, and ran the appropriate commands and it worked wonderfully.

Problem is, when I try to use Visual studio on windows, everything goes south.

I first clone the repo:

https://github.com/JacobEckroth/BetterChess.git:

and then mkdir a build folder, cd into it and input cmake .
I get this error:

name@DESKTOP-G8CSCPT MINGW64 ~/source/repos/BetterChess/build (main)
$ cmake …
– Building for: Visual Studio 17 2022
– Selecting Windows SDK version 10.0.19041.0 to target Windows 10.0.19042.
– The C compiler identification is MSVC 19.31.31104.0
– The CXX compiler identification is MSVC 19.31.31104.0
– Detecting C compiler ABI info
– Detecting C compiler ABI info - done
– Check for working C compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
– Detecting C compile features
– Detecting C compile features - done
– Detecting CXX compiler ABI info
– Detecting CXX compiler ABI info - done
– Check for working CXX compiler: C:/Program Files/Microsoft Visual Studio/2022/Professional/VC/Tools/MSVC/14.31.31103/bin/Hostx64/x64/cl.exe - skipped
– Detecting CXX compile features
– Detecting CXX compile features - done
CMake Error at C:/Users/name/cmake-3.23.0-windows-x86_64/cmake-3.23.0-windows-x86_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
Call Stack (most recent call first):
C:/Users/name/cmake-3.23.0-windows-x86_64/cmake-3.23.0-windows-x86_64/share/cmake-3.23/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
cmake/FindSDL2.cmake:313 (FIND_PACKAGE_HANDLE_STANDARD_ARGS)
CMakeLists.txt:4 (find_package)

– Configuring incomplete, errors occurred!
See also “C:/Users/name/source/repos/BetterChess/build/CMakeFiles/CMakeOutput.log”.
See also “C:/Users/name/source/repos/BetterChess/build/CMakeFiles/CMakeError.log”.

How do I fix this?, I have SDL2 in my machine, and able to use it vs and make projects with it, but when cloning repos, It doesn’t work.

image

Here is an image of the gui version of the errror.

You probably have to help CMake find SDL2 if it isn’t in a “typical” location. SDL2_PATH looks promising; can you try setting it to the SDL2 installation prefix? If that doesn’t work, making a new SDL2_ROOT variable with that value may work better.