From 7759be82f76a634f8041e164aae2bc428797421b Mon Sep 17 00:00:00 2001 From: Mohamed Fatih Date: Fri, 11 Mar 2022 20:28:05 +0100 Subject: [PATCH] add executable SDL --- CMakeLists.txt | 20 +++++++++++++++++++- model.h | 2 +- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 08ce0ba..9d0c9cc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,7 +14,15 @@ set(CMAKE_C_FLAGS "-std=c99 -Wall") set(CMAKE_C_FLAGS_DEBUG "-g --coverage -pthread -Wextra -Wunused-parameter -Wpedantic -Werror") # use CMake option: -DCMAKE_BUILD_TYPE=DEBUG set(CMAKE_C_FLAGS_RELEASE "-O3 -DNDEBUG") # use CMake option: -DCMAKE_BUILD_TYPE=RELEASE -############################# SRC ############################# +## use a CMake3 package to solve SDL2 dependencies + +find_package(SDL2 REQUIRED) +set(SDL2_ALL_INC ${SDL2_INCLUDE_DIRS}) +set(SDL2_ALL_LIBS ${SDL2_LIBRARIES} -lSDL2_ttf -lSDL2_image) # add extra SDL2 libraries + +## print this +message(STATUS "SDL2 include dir: ${SDL2_ALL_INC}") +message(STATUS "SDL2 all libraries: ${SDL2_ALL_LIBS}") # game_text add_executable(game_text game_text.c) @@ -28,6 +36,16 @@ target_link_libraries(game_test game) add_executable(game_solve game_solve.c) target_link_libraries(game_solve game) +# game model +include_directories(${SDL2_ALL_INC}) +add_executable(model model.c) +target_link_libraries(model game ${SDL2_ALL_LIBS} m) + +## copy useful data files in build dir for the SDL +foreach(file "black.png") + file(COPY ${file} DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) +endforeach(file) + # libgame add_library (game game.c game_aux.c game_ext.c game_private.c history.c game_tools.c game_examples.c) diff --git a/model.h b/model.h index 3856082..be9cfad 100644 --- a/model.h +++ b/model.h @@ -3,7 +3,7 @@ #ifndef MODEL_H #define MODEL_H -#include +#include #include #include