Answer the question
In order to leave comments, you need to log in
Connect SDL2 in Cmake?
Hello, I wanted to try to write something on sdl2, I downloaded a new ide from jetbrains (сlion), cmake is used by default, I can’t cope with it. As I understand it, sdl2 needs a separate module, I took it from
here . I try to do it find_package(SDL2 REQUIRED)
, swears
Error:Could NOT find SDL2 (missing: SDL2_LIBRARY SDL2_INCLUDE_DIR)
. What does he want?
Answer the question
In order to leave comments, you need to log in
Use the .cmake scripts from this repository by placing them in the cmake folder of your project.
Add to your CMakeLists.txt
set(SDL2_PATH "C:\\SDL2-2.0.5\\x86_64-w64-mingw32") # ПУТЬ К ВАШЕЙ SDL БИБЛИОТЕКЕ
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${ИМЯ_ПРОЕКТА_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})
target_link_libraries(ИМЯ_ПРОЕКТА ${SDL2_LIBRARY}
${SDL2_IMAGE_LIBRARIES}
${SDL2_TTF_LIBRARIES})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question