SDL2 image on CLion By not providing "FindSDL2_image.cmake"

Answered

Hello,

I am trying to setup SDL2 packages on Clion, SDL2 image at the moment but having a hard time to do that. I tried to follow the same steps I did for installing SDL2, which is following this post, but I get this error:

CMake Error at CMakeLists.txt:13 (find_package):
By not providing "FindSDL2_IMAGE.cmake" in CMAKE_MODULE_PATH this project
has asked CMake to find a package configuration file provided by
"SDL2_IMAGE", but CMake did not find one.


Could not find a package configuration file provided by "SDL2_IMAGE" with
any of the following names:

SDL2_IMAGEConfig.cmake
sdl2_image-config.cmake

Add the installation prefix of "SDL2_IMAGE" to CMAKE_PREFIX_PATH or set
"SDL2_IMAGE_DIR" to a directory containing one of the above files. If
"SDL2_IMAGE" provides a separate development package or SDK, be sure it has
been installed.


mingw32-make.exe: *** [Makefile:195: cmake_check_build_system] Error 1

 

I take it it doesn't find "FindSDL2_image.cmake", I put it under "C:\Program Files\JetBrains\CLion 2020.2.1\bin\cmake\share\cmake-3.9\Modules".

Here's my CMakeLists.txt:

cmake_minimum_required(VERSION 3.17)
project(Demo_1)
set(CMAKE_CXX_STANDARD 14)

set(SDL2_PATH "C:\\Users\\Shizune\\Documents\\Misc\\SDL\\x86_64-w64-mingw32")
find_package(SDL2 REQUIRED)
include_directories( ${SDL2_INCLUDE_DIR})

set(SDL2_IMAGE_PATH "C:\\Users\\Shizune\\Documents\\Misc\\SLD_image\\SDL2_image-2.0.5\\x86_64-w64-mingw32")
find_package(SDL2_image REQUIRED)
include_directories( ${SDL2_IMAGE_INCLUDE_DIR})

add_executable(Demo_1 main.cpp)

target_link_libraries(Demo_1 ${SDL2_LIBRARY})
target_link_libraries(Demo_1 ${SDL2_IMAGE_LIBRARY})

Many thanks,

Florian

 

0
1 comment

Hello!

The path here was relevant for CLion 2017.3.1. CLion 2020.2.1 for sure bundles a different CMake version, not 3.9. You need to put FindSDL2_image.cmake into an existing "Modules" folder depending on what CMake is used.

0

Please sign in to leave a comment.