A
A
argutin2014-11-09 13:07:12
C++ / C#
argutin, 2014-11-09 13:07:12

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

2 answer(s)
T
tsarevfs, 2014-11-09
@tsarevfs

You took a script that can find sdl. Did you install SDL itself ?

N
NovaSurfer, 2017-01-08
@NovaSurfer

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 question

Ask a Question

731 491 924 answers to any question