Review SDL2 implementation with Conan support
This commit is contained in:
parent
1c2c47bb1f
commit
42a2dc80e5
3
.gitignore
vendored
3
.gitignore
vendored
@ -63,10 +63,9 @@ CMakeFiles
|
||||
CMakeScripts
|
||||
Testing
|
||||
Makefile
|
||||
cmake_install.cmake
|
||||
*.cmake
|
||||
install_manifest.txt
|
||||
compile_commands.json
|
||||
CTestTestfile.cmake
|
||||
_deps
|
||||
|
||||
.project
|
||||
|
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -1,3 +0,0 @@
|
||||
[submodule "cmake/sdl2"]
|
||||
path = cmake/sdl2
|
||||
url = https://git.jcsmith.fr/jackcartersmith/sdl2-cmake-modules.git
|
@ -4,6 +4,8 @@
|
||||
# This code is released under the AST license.
|
||||
|
||||
cmake_minimum_required(VERSION 3.5.1)
|
||||
cmake_policy(VERSION 3.5.1)
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
|
||||
|
||||
# define project
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/sdl2)
|
||||
@ -15,6 +17,14 @@ configure_file(${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in ${CMAKE_CURRENT_SOURC
|
||||
include(FindPkgConfig)
|
||||
include(CheckIncludeFile)
|
||||
include(CheckCSourceCompiles)
|
||||
#include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake)
|
||||
#conan_basic_setup()
|
||||
|
||||
# Find SDL2, SDL2_image and SDL2_gfx libraries
|
||||
find_package(SDL2 REQUIRED)
|
||||
include_directories(${SDL2_INCLUDE_DIR})
|
||||
find_package(SDL2_image REQUIRED)
|
||||
include_directories(${SDL2_image_INCLUDE_DIR})
|
||||
|
||||
# define src/headers files
|
||||
|
||||
@ -32,18 +42,12 @@ add_executable(AST ${AST_SCRS} ${AST_HRDS})
|
||||
set_target_properties(AST PROPERTIES OUTPUT_NAME ${AST_NAME})
|
||||
if(MSVC)
|
||||
# msvc does not append 'lib' - do it here to have consistent name
|
||||
set_target_properties(AST PROPERTIES PREFIX "lib")
|
||||
#set_target_properties(AST PROPERTIES PREFIX "lib")
|
||||
set_target_properties(AST PROPERTIES IMPORT_PREFIX "lib")
|
||||
endif()
|
||||
|
||||
target_include_directories(${PROJECT_NAME} PRIVATE include)
|
||||
|
||||
# Find SDL2, SDL2_image and SDL2_gfx libraries
|
||||
find_package(SDL2 REQUIRED)
|
||||
find_package(SDL2_image REQUIRED)
|
||||
|
||||
# Link SDL2::Main, SDL2::Image and SDL2::GFX to our project
|
||||
target_link_libraries(${PROJECT_NAME} SDL2::Main SDL2::Image)
|
||||
target_link_libraries(${PROJECT_NAME} ${SDL2_LIBRARIES} ${SDL2_image_LIBRARIES})
|
||||
|
||||
# install executable
|
||||
|
||||
|
@ -1,8 +0,0 @@
|
||||
The MIT License (MIT)
|
||||
Copyright (c) 2016 Simon Eisenmann <simon@longsleep.org>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
79
Makefile.old
79
Makefile.old
@ -1,79 +0,0 @@
|
||||
BUILD_DIR := build
|
||||
RM := rm -rf $(BUILD_DIR)
|
||||
|
||||
OBJ_SRCS :=
|
||||
ASM_SRCS :=
|
||||
C_SRCS :=
|
||||
O_SRCS :=
|
||||
S_UPPER_SRCS :=
|
||||
EXECUTABLES :=
|
||||
OBJS :=
|
||||
C_DEPS :=
|
||||
|
||||
# Every subdirectory with source files must be described here
|
||||
SUBDIRS := \
|
||||
. \
|
||||
|
||||
C_SRCS += \
|
||||
src/IAEngine.c \
|
||||
src/arenaEngine.c \
|
||||
src/arenaGUI.c \
|
||||
src/fileHandler.c \
|
||||
src/logHelper.c \
|
||||
src/main.c \
|
||||
src/menuGUI.c
|
||||
|
||||
OBJS += \
|
||||
build/IAEngine.o \
|
||||
build/arenaEngine.o \
|
||||
build/arenaGUI.o \
|
||||
build/fileHandler.o \
|
||||
build/logHelper.o \
|
||||
build/main.o \
|
||||
build/menuGUI.o
|
||||
|
||||
C_DEPS += \
|
||||
build/IAEngine.d \
|
||||
build/arenaEngine.d \
|
||||
build/arenaGUI.d \
|
||||
build/fileHandler.d \
|
||||
build/logHelper.d \
|
||||
build/main.d \
|
||||
build/menuGUI.d
|
||||
|
||||
|
||||
build/%.o: src/%.c
|
||||
@echo 'Building file: $<'
|
||||
@echo 'Invoking: GCC C Compiler'
|
||||
gcc -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@)" -o "$@" "$<"
|
||||
@echo 'Finished building: $<'
|
||||
@echo ' '
|
||||
|
||||
LIBS := -lSDL2 -lSDL2main -lSDL2_image
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(strip $(C_DEPS)),)
|
||||
-include $(C_DEPS)
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: all buildDir clean dependents
|
||||
|
||||
# All Target
|
||||
all: buildDir ArenaSurvivalTournament
|
||||
|
||||
buildDir:
|
||||
[ -d $(BUILD_DIR) ] || mkdir -p $(BUILD_DIR)
|
||||
|
||||
# Tool invocations
|
||||
ArenaSurvivalTournament: $(OBJS)
|
||||
@echo 'Building target: $@'
|
||||
@echo 'Invoking: GCC C Linker'
|
||||
gcc -o "ArenaSurvivalTournament" $(OBJS) $(LIBS)
|
||||
@echo 'Finished building target: $@'
|
||||
@echo ' '
|
||||
|
||||
# Other Targets
|
||||
clean:
|
||||
-$(RM) $(EXECUTABLES)$(OBJS)$(C_DEPS) ArenaSurvivalTournament
|
||||
-@echo ' '
|
16
README.md
16
README.md
@ -1,11 +1,13 @@
|
||||
# Arena Survival Tournament
|
||||
|
||||
This is one of my first game prototype.
|
||||
It's fully coded in C with SDL2 libs.
|
||||
It's fully coded in C with SDL2 and SDL2_image libs.
|
||||
All SDL2 parts and sub-parts are under the same license as SDL2 lib.
|
||||
All code of AST are covered by the MIT license.
|
||||
|
||||
## Functions
|
||||
|
||||
The game can do following:
|
||||
The game can do following and you can learn from that like we do when you created this code:
|
||||
- Generate random maps level
|
||||
- Control a simple IA
|
||||
- Manage gold resources
|
||||
@ -14,20 +16,22 @@ The game can do following:
|
||||
|
||||
## Compiling
|
||||
|
||||
Before compiling, you need to install both build suite (GCC/MSVC) with CMake and SDL2 libs:
|
||||
Before compiling, you need to install your favorite compiler (GCC or MSVC) with CMake and the lib manager Conan (https://conan.io):
|
||||
|
||||
```shell
|
||||
# For debian based distribution:
|
||||
apt update
|
||||
apt install build-essential cmake libsdl2-dev libsdl2-image-dev
|
||||
apt install build-essential cmake conan
|
||||
```
|
||||
|
||||
Clone the repo with submodules updated and launch cmake to prepare compile:
|
||||
Clone the repo and launch in order conan and cmake in order to compile the program:
|
||||
|
||||
```shell
|
||||
cd AST
|
||||
mkdir build && cd build
|
||||
cp -R ../data .
|
||||
cmake ..
|
||||
conan install .. --build=missing
|
||||
cmake .. # or with '-G "MinGW Makefiles"' if under Windows
|
||||
make
|
||||
```
|
||||
|
||||
|
@ -1 +0,0 @@
|
||||
Subproject commit f12dd8f3c33863b5109ae17082a5b2c5257aeae7
|
25
conanfile.txt
Normal file
25
conanfile.txt
Normal file
@ -0,0 +1,25 @@
|
||||
[requires]
|
||||
sdl/2.0.16
|
||||
sdl_image/2.0.5
|
||||
|
||||
[generators]
|
||||
cmake
|
||||
cmake_find_package
|
||||
|
||||
[options]
|
||||
sdl:shared=True
|
||||
sdl_image:shared=True
|
||||
sdl_image:with_libjpeg=False
|
||||
sdl_image:with_libtiff=False
|
||||
sdl_image:with_libwebp=False
|
||||
sdl_image:lbm=False
|
||||
sdl_image:pcx=False
|
||||
sdl_image:pnm=False
|
||||
sdl_image:svg=False
|
||||
sdl_image:tga=False
|
||||
sdl_image:xcf=False
|
||||
sdl_image:xpm=False
|
||||
sdl_image:xv=False
|
||||
|
||||
[imports]
|
||||
bin, *.dll -> .
|
Loading…
x
Reference in New Issue
Block a user