Simple DirectMedia Layer: Difference between revisions

No edit summary
Line 7: Line 7:
I suggest including SDL2 as a git submodule so you don't need to install it.<br>
I suggest including SDL2 as a git submodule so you don't need to install it.<br>
Simply clone SDL2 into a folder such as <code>extern</code> and include the following in your CMakeLists:
Simply clone SDL2 into a folder such as <code>extern</code> and include the following in your CMakeLists:
<pre>
<syntaxhighlight lang="cmake">
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
add_subdirectory(extern/SDL EXCLUDE_FROM_ALL)
include_directories(${SDL2_BINARY_DIR}/include)
include_directories(${SDL2_BINARY_DIR}/include)
Line 13: Line 13:
# add_executable(my_app src/main.cpp)
# add_executable(my_app src/main.cpp)
target_link_libraries(my_app SDL2::SDL2-static)
target_link_libraries(my_app SDL2::SDL2-static)
</pre>
</syntaxhighlight>
Then you can include SDL in your source: <code>#include <SDL.h></code>.
Then you can include SDL in your source: <code>#include <SDL.h></code>.


==Resources==
==Resources==
* [https://lazyfoo.net/tutorials/SDL/ Lazy Foo's Beginning Game Programming v2.0]
* [https://lazyfoo.net/tutorials/SDL/ Lazy Foo's Beginning Game Programming v2.0]