Auden Yoo
Auden Yoo

Reputation: 1

CMake unable to find SDL2 (Windows)

The problem is every time I try to generate CMake find_package fails, and I get the error:

1> [CMake] CMake Error at C:\Users\themo\source\repos\SDL_Fun\CMakeLists.txt:6 (find_package):
1> [CMake]   By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has
1> [CMake]   asked CMake to find a package configuration file provided by "SDL2", but
1> [CMake]   CMake did not find one.
1> [CMake] 
1> [CMake]   Could not find a package configuration file provided by "SDL2" with any of
1> [CMake]   the following names:
1> [CMake] 
1> [CMake]     SDL2Config.cmake
1> [CMake]     sdl2-config.cmake
1> [CMake] 
1> [CMake]   Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set
1> [CMake]   "SDL2_DIR" to a directory containing one of the above files.  If "SDL2"
1> [CMake]   provides a separate development package or SDK, be sure it has been
1> [CMake]   installed.
1> [CMake] 
1> [CMake] 
1> [CMake] -- Configuring incomplete, errors occurred!

with the code:

# CMakeList.txt : Top-level CMake project file, do global configuration
# and include sub-projects here.
#
cmake_minimum_required (VERSION 3.8)

find_package(SDL2 REQUIRED)

# Enable Hot Reload for MSVC compilers if supported.
if (POLICY CMP0141)
cmake_policy(SET CMP0141 NEW)
set(CMAKE_MSVC_DEBUG_INFORMATION_FORMAT"$<IF:$<AND:$<C_COMPILER_ID:MSVC>,$<CXX_COMPILER_ID:MSVC>>,$<$<CO NFIG:Debug,RelWithDebInfo>:EditAndContinue>,$<$<CONFIG:Debug,RelWithDebInfo>:ProgramDatabase>>")
endif()

project ("SDL_Fun")

# Include sub-projects.
add_subdirectory ("SDL_Fun")

I tried changing the CMAKE_MODULE_PATH to the SDL2 cmake sdl2-config.cmake file and I have tried specifying the command argument -DCMAKE_PREFIX_PATH=C:\Developer\sdks\SDL2-devel-2.32.0-VC\SDL2-2.32.0.

Upvotes: -1

Views: 25

Answers (0)

Related Questions