diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5446d8e --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +build/ +dist/ +.cache +compile_commands.json diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..258c25d --- /dev/null +++ b/.gitmodules @@ -0,0 +1,16 @@ +[submodule "extern/SDL2/SDL"] + path = extern/SDL2/SDL + url = https://github.com/libsdl-org/SDL + branch = main +[submodule "extern/SDL2/SDL_image"] + path = extern/SDL2/SDL_image + url = https://github.com/libsdl-org/SDL_image + branch = main +[submodule "extern/SDL2/SDL_ttf"] + path = extern/SDL2/SDL_ttf + url = https://github.com/libsdl-org/SDL_ttf + branch = main +[submodule "extern/SDL2/SDL_mixer"] + path = extern/SDL2/SDL_mixer + url = https://github.com/libsdl-org/SDL_mixer + branch = main diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..e15da8a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,45 @@ +cmake_minimum_required(VERSION 3.10) + +project(Engine) + +# VARIABLES +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +set(BUILD_SHARED_LIBS ON) + +if(CMAKE_HOST_WIN32) + # Export both *.lib and *.dll on Windows + set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON) +endif() + +set(CMAKE_INSTALL_BINDIR bin) +set(CMAKE_INSTALL_LIBDIR lib) +set(CMAKE_INSTALL_INCLUDEDIR include) +set(CMAKE_INSTALL_RPATH "$ORIGIN;$ORIGIN/../lib") + +# TARGETS +add_library(${PROJECT_NAME} SHARED src/engine.c) + +target_include_directories(${PROJECT_NAME} PUBLIC + include + extern/SDL2/SDL/include + extern/SDL2/SDL_mixer/include + extern/SDL2/SDL_image + extern/SDL2/SDL_ttf +) +target_link_libraries(${PROJECT_NAME} PUBLIC + SDL2 + SDL2_image + SDL2_mixer + SDL2_ttf +) + +install(TARGETS ${PROJECT_NAME} + CONFIGURATIONS Release + RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} + ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR} + LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} +) + +# SUB-DIRECTORIES +add_subdirectory(extern) diff --git a/extern/CMakeLists.txt b/extern/CMakeLists.txt new file mode 100644 index 0000000..3a70702 --- /dev/null +++ b/extern/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.10) + +add_subdirectory(SDL2) diff --git a/extern/SDL2/CMakeLists.txt b/extern/SDL2/CMakeLists.txt new file mode 100644 index 0000000..accddf4 --- /dev/null +++ b/extern/SDL2/CMakeLists.txt @@ -0,0 +1,12 @@ +cmake_minimum_required(VERSION 3.10) + +set(SDL_TEST_ENABLED_BY_DEFAULT OFF CACHE BOOL "" FORCE) +set(SDL2_DISABLE_INSTALL OFF CACHE BOOL "" FORCE) +set(SDL2_DISABLE_UNINSTALL OFF CACHE BOOL "" FORCE) +set(SDL2MIXER_VENDORED ON CACHE BOOL "" FORCE) +set(SDL2TTF_VENDORED ON CACHE BOOL "" FORCE) + +add_subdirectory(SDL_image) +add_subdirectory(SDL_ttf) +add_subdirectory(SDL_mixer) +add_subdirectory(SDL) diff --git a/extern/SDL2/SDL b/extern/SDL2/SDL new file mode 160000 index 0000000..8c9beb0 --- /dev/null +++ b/extern/SDL2/SDL @@ -0,0 +1 @@ +Subproject commit 8c9beb0c873f6ca5efbd88f1ad2648bfc793b2ac diff --git a/extern/SDL2/SDL_image b/extern/SDL2/SDL_image new file mode 160000 index 0000000..a861543 --- /dev/null +++ b/extern/SDL2/SDL_image @@ -0,0 +1 @@ +Subproject commit a861543ab78f5d5e18e6af43964ce8df60cb30b3 diff --git a/extern/SDL2/SDL_mixer b/extern/SDL2/SDL_mixer new file mode 160000 index 0000000..75f3181 --- /dev/null +++ b/extern/SDL2/SDL_mixer @@ -0,0 +1 @@ +Subproject commit 75f318100d220e236c4fcc5a3d0c9ba33d064f3f diff --git a/extern/SDL2/SDL_ttf b/extern/SDL2/SDL_ttf new file mode 160000 index 0000000..4f52f9d --- /dev/null +++ b/extern/SDL2/SDL_ttf @@ -0,0 +1 @@ +Subproject commit 4f52f9d74d3e7900b2d6a817524d49dcf660b79e diff --git a/src/engine.c b/src/engine.c new file mode 100644 index 0000000..2625b82 --- /dev/null +++ b/src/engine.c @@ -0,0 +1,11 @@ +#include "SDL.h" +#include "SDL_image.h" +#include "SDL_mixer.h" +#include "SDL_ttf.h" +#include + +void init(void) { + if (SDL_Init(SDL_INIT_EVERYTHING) == 0) { + printf("SDL initialiased successfully\n"); + } +}