-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
113 lines (92 loc) · 4.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
cmake_minimum_required(VERSION 3.20)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake")
project(SpaceShooter VERSION 0.1.0.0)
set(POJECT_AUTHOR "YOUR NAME <YOUR.EMAIL@esiee.fr>")
set(PROJECT_ASSETS_PATH "./../../../assets")
set(CXX_STANDARD_REQUIRED 20)
set(CMAKE_CXX_STANDARD_REQUIRED 20)
if(MSVC)
list(APPEND CMAKE_PREFIX_PATH "${PROJECT_SOURCE_DIR}/SFML-2.6.0")
set(BUILD_SHARED_LIBS OFF)
set(SFML_STATIC_LIBRARIES ON)
set(SFML_DIR "${PROJECT_SOURCE_DIR}/SFML-2.6.0")
set(SFML_ROOT "${PROJECT_SOURCE_DIR}/SFML-2.6.0")
endif()
# For linux : apt install libsfml-dev
# SFML2 (system)
find_package(SFML 2 COMPONENTS
system window graphics audio # Core for game
network # Optional
# Main # Windows OS only
REQUIRED)
# SPACE-SHOOTER
set(SOURCE_FILES
# ADD SOURCE FILES HERE !!
# Core of Game
src/space-shooter/main.cpp
src/space-shooter/utils.cpp
src/space-shooter/game_state.cpp
# Scenes
src/space-shooter/scenes/exit.cpp
src/space-shooter/scenes/level.cpp
src/space-shooter/scenes/menu.cpp
src/space-shooter/scenes/pause.cpp
src/space-shooter/scenes/score.cpp
# Core of ECS
src/space-shooter/ecs/entity.cpp
src/space-shooter/ecs/system.cpp
src/space-shooter/ecs/manager.cpp
# Entities
src/space-shooter/ecs/entites/background.cpp
src/space-shooter/ecs/entites/player_ship.cpp
src/space-shooter/ecs/entites/text_entity.cpp
# Systems
src/space-shooter/ecs/systems/input_system.cpp
src/space-shooter/ecs/systems/rendering_system.cpp
src/space-shooter/ecs/systems/movement_system.cpp
src/space-shooter/ecs/systems/wait_key_system.cpp
src/space-shooter/ecs/systems/collider_system.cpp
"src/space-shooter/ecs/systems/text_system.cpp" "src/space-shooter/ecs/entites/missile.cpp" "src/space-shooter/ecs/systems/controller_system.cpp" "src/space-shooter/ecs/systems/shape_system.cpp" "src/space-shooter/ecs/systems/oob_system.cpp" "src/space-shooter/ecs/systems/shooting_system.cpp" "src/space-shooter/ecs/systems/clock_system.cpp" "src/space-shooter/ecs/entites/score_entity.cpp" "src/space-shooter/ecs/entites/wait_key.cpp" "src/space-shooter/ecs/systems/health_display_system.cpp" "src/space-shooter/ecs/systems/timer_system.cpp" "src/space-shooter/ecs/entites/timer.cpp" "src/space-shooter/ecs/systems/score_system.cpp")
# Add executable
add_executable(space-shooter ${SOURCE_FILES} "src/space-shooter/ecs/entites/enemy_ship.cpp" "src/space-shooter/ecs/entites/enemy_spawner.cpp" "src/space-shooter/ecs/systems/enemy_spawn_system.cpp" "src/space-shooter/ecs/systems/enemy_controller_system.cpp" "src/space-shooter/ecs/systems/health_system.cpp" "src/space-shooter/ecs/systems/audio_system.cpp" "src/space-shooter/ecs/entites/audio_player_entity.cpp")
set_property(TARGET space-shooter PROPERTY CXX_STANDARD 20)
# Configure file
configure_file (
"${PROJECT_SOURCE_DIR}/utils/version.hpp.in"
"${PROJECT_BINARY_DIR}/include/space-shooter/version.hpp"
)
# Set include directories
target_include_directories(space-shooter PRIVATE "${PROJECT_SOURCE_DIR}/include")
target_include_directories(space-shooter PRIVATE "${PROJECT_BINARY_DIR}/include") #for the generated version file
target_include_directories(space-shooter PRIVATE "${PROJECT_SOURCE_DIR}/src/space-shooter")
# Set SFML dependency
# SFML 2 (system)
target_link_libraries(space-shooter PRIVATE sfml-system sfml-window sfml-network sfml-graphics sfml-audio)
# Adress + leak sanitizer !
if (MSVC)
add_compile_options(/W4 /WX /permissive-)
# (OPTIONAL) TOGGLE ADRESS SANITIZER HERE
add_compile_options(/fsanitize=address)
add_link_options(/fsanitize=address)
else()
#Compile options
target_compile_options(space-shooter PRIVATE -Wall -Wextra -pedantic -Werror )
target_compile_options(space-shooter PRIVATE -Wno-unused-parameter)
target_compile_options(space-shooter PRIVATE -Wno-missing-field-initializers) # https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110064
# (OPTIONAL) TOGGLE ADRESS SANITIZER HERE
target_compile_options(space-shooter PRIVATE -fsanitize=address -fno-omit-frame-pointer)
target_link_options(space-shooter PRIVATE -fsanitize=address -fno-omit-frame-pointer)
endif()
# Install the game
# Specify the installation of the binary
install(TARGETS space-shooter DESTINATION .)
# Install the entire assets directory
install(DIRECTORY ${CMAKE_SOURCE_DIR}/assets/ DESTINATION assets)
# Specify a custom target for creating a zip
add_custom_target(
package
COMMAND ${CMAKE_COMMAND} --install . --prefix package-install
COMMAND zip -r space-shooter.zip package-install
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
COMMENT "Packaging game and assets into space-shooter.zip"
)