Problem with project build with SDL2
I try to build project with SDL2_image, but have such error:
CMake Error at CMakeLists.txt:9 (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.
If compile project with CTRL+F5, it works fine.
I work on ubuntu 20.04, also add "FindSDL2_image.cmake" to cmake/Modules. Can someone help with it?
My CMakeList.txt :
cmake_minimum_required(VERSION 3.17)
project(POng2)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
find_package(SDL2 REQUIRED)
find_package(SDL2_image REQUIRED)
find_package(SDL2_ttf REQUIRED)
include_directories(${SDL2_INCLUDE_DIR}
${SDL2_IMAGE_INCLUDE_DIR}
${SDL2_TTF_INCLUDE_DIR})
add_executable(POng2 main.cpp Game.h Game.cpp Paddle.h Paddle.cpp Entity.h Entity.cpp Ball.h Ball.cpp Board.h Board.cpp Score.h Score.cpp)
target_link_libraries(POng2 ${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
${SDL2_TTF_LIBRARIES})
请先登录再写评论。
Hello!
>also add "FindSDL2_image.cmake" to cmake/Modules
Where exactly did you put this file? And what CLion version do you use?