diff --git a/CMakeLists.txt b/CMakeLists.txt index 237f27be..69d322bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,19 +1,23 @@ cmake_minimum_required(VERSION 3.5) +# Project name project(R-Type) -option(BUILD_TESTS "Build the tests" ON) +# Set a directory path in a CMake variable +set(GAME_DIR "${CMAKE_SOURCE_DIR}/Game") -#R-Type Game -add_subdirectory(R-TypeGame) +# Define a preprocessor macro globally for all targets +add_compile_definitions(GAME_ROOT="${GAME_DIR}") -#Graphic Library -add_subdirectory(GraphicLibrary) +# Option to build tests +option(BUILD_TESTS "Build the tests" ON) -#Engine -add_subdirectory(Engine) +# Add subdirectories for different components of the project +add_subdirectory(R-TypeGame) # R-Type Game +add_subdirectory(GraphicLibrary) # Graphic Library +add_subdirectory(Engine) # Engine -# tests +# Add subdirectory for tests if the option is enabled if(BUILD_TESTS) add_subdirectory(tests) endif() diff --git a/Engine/CMakeLists.txt b/Engine/CMakeLists.txt index 20cd1cd5..296c32a3 100644 --- a/Engine/CMakeLists.txt +++ b/Engine/CMakeLists.txt @@ -1,5 +1,7 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Add subdirectories for different components of the Engine add_subdirectory(Client) add_subdirectory(Server) add_subdirectory(Shared) diff --git a/Engine/Client/CMakeLists.txt b/Engine/Client/CMakeLists.txt index 06e7dc46..ba76231b 100644 --- a/Engine/Client/CMakeLists.txt +++ b/Engine/Client/CMakeLists.txt @@ -1,13 +1,22 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 +set(CMAKE_CXX_STANDARD 20) + +# Set the executable name set(EXE r-type_client) + +# Set the output directory for the executable set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Game) +# Define source and include paths set(EXE_SRC_PATH "Src") set(EXE_INCLUDE_PATH "Include") +# Define component source files set(COMPONENT_SRC_FILE - ./Src/Components/ShaderComponent/ShaderPathComponent.cpp + ${EXE_SRC_PATH}/Components/ShaderComponent/ShaderPathComponent.cpp ../Shared/Component/FontPathComponent.cpp ../Shared/Component/ObjPathComponent.cpp ../Shared/Component/TexturePathComponent.cpp @@ -25,51 +34,55 @@ set(COMPONENT_SRC_FILE ../Shared/Component/SoundPitchComponent.cpp ../Shared/Component/SoundVolumeComponent.cpp ) + +# Define system source files set(SYSTEM_SRC_FILE - Src/Systems/DrawOBJ/DrawOBJSystem.cpp + ${EXE_SRC_PATH}/Systems/DrawOBJ/DrawOBJSystem.cpp ) -set(COMPONENT_INCLUDE_DIR ./Include/Components/ShaderComponent) - -set(CMAKE_CXX_STANDARD 20) - +# Define the main source files for the executable set(SRC_EXE - Src/main.cpp - Src/Application/Application.cpp - Src/ClientSceneManager/ClientSceneManager.cpp - Src/GraphicalLibrary/GetGraphicalLibrary.cpp - - ../Shared/SceneManager/ASceneManager.cpp - ${COMPONENT_SRC_FILE} - ${SYSTEM_SRC_FILE} + ${EXE_SRC_PATH}/main.cpp + ${EXE_SRC_PATH}/Application/Application.cpp + ${EXE_SRC_PATH}/ClientSceneManager/ClientSceneManager.cpp + ${EXE_SRC_PATH}/GraphicalLibrary/GetGraphicalLibrary.cpp + ../Shared/SceneManager/ASceneManager.cpp + ${COMPONENT_SRC_FILE} + ${SYSTEM_SRC_FILE} ) +# Include directories for header files include_directories( - Src/Network - Src/Application - Src/ClientSceneManager - Src/GraphicalLibrary - Src/Errors - Src/Systems - ../Shared/GraphicalLoad - ../Shared/Component - ../Shared/Ecs/Src - ../Shared/Interface - ../Shared/SceneManager - ../Shared/DLLoader - ${COMPONENT_INCLUDE_DIR} + ${EXE_SRC_PATH}/Network + ${EXE_SRC_PATH}/Application + ${EXE_SRC_PATH}/ClientSceneManager + ${EXE_SRC_PATH}/GraphicalLibrary + ${EXE_SRC_PATH}/Errors + ${EXE_SRC_PATH}/Systems + ../Shared/GraphicalLoad + ../Shared/Component + ../Shared/Ecs/Src + ../Shared/Interface + ../Shared/SceneManager + ../Shared/DLLoader + ${EXE_INCLUDE_PATH}/Components/ShaderComponent ) -add_subdirectory(Src/Network) +# Add subdirectory for network sources +add_subdirectory(${EXE_SRC_PATH}/Network) +# Add the executable target add_executable(${EXE} ${SRC_EXE}) +# Include directories for the executable target target_include_directories(${EXE} PUBLIC ${EXE_INCLUDE_PATH}) +# Find required packages find_package(asio REQUIRED) find_package(jsoncpp REQUIRED) find_package(raylib REQUIRED) +# Link libraries to the executable target target_link_libraries( ${EXE} PRIVATE asio::asio @@ -78,13 +91,3 @@ target_link_libraries( r-type_ecs r-type_network_client ) - -add_custom_command(TARGET ${EXE} PRE_BUILD - COMMAND mkdir ${CMAKE_SOURCE_DIR}/Game/GameData -) - -add_custom_command(TARGET ${EXE} - POST_BUILD - COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/Game/GameData - COMMAND cp -r ${CMAKE_SOURCE_DIR}/Engine/Server/Config/* ${CMAKE_SOURCE_DIR}/Game/GameData -) diff --git a/Engine/Server/CMakeLists.txt b/Engine/Server/CMakeLists.txt index d451bf8f..7513c72d 100644 --- a/Engine/Server/CMakeLists.txt +++ b/Engine/Server/CMakeLists.txt @@ -1,8 +1,16 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 +set(CMAKE_CXX_STANDARD 20) + +# Set the executable name set(EXE r-type_server) + +# Set the output directory for the executable set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Game) +# Define source and include paths set(EXE_SRC_PATH "Src") set(EXE_INCLUDE_PATH "Include" @@ -11,12 +19,11 @@ set(EXE_INCLUDE_PATH "Src/GameEngine/ServerSceneManager" ) -set(CMAKE_CXX_STANDARD 20) - +# Define the main source files for the executable set(SRC_EXE - ./${EXE_SRC_PATH}/main.cpp - ./${EXE_SRC_PATH}/GameEngine/Application/Application.cpp - ./${EXE_SRC_PATH}/GameEngine/ServerSceneManager/ServerSceneManager.cpp + ${EXE_SRC_PATH}/main.cpp + ${EXE_SRC_PATH}/GameEngine/Application/Application.cpp + ${EXE_SRC_PATH}/GameEngine/ServerSceneManager/ServerSceneManager.cpp ../Shared/SceneManager/ASceneManager.cpp ../Shared/Component/FontPathComponent.cpp ../Shared/Component/ObjPathComponent.cpp @@ -36,37 +43,37 @@ set(SRC_EXE ../Shared/Component/SoundVolumeComponent.cpp ) +# Include directories for header files include_directories( - src/Network - src/GameEngine/Errors - src/GameEngine/Application - src/GameEngine/ServerSceneManager - ../Shared/Ecs/Src - ../Shared/Interface - ../Shared/SceneManager - ../Shared/Network/Packet - ../Shared/Component + ${EXE_SRC_PATH}/Network + ${EXE_SRC_PATH}/GameEngine/Errors + ${EXE_SRC_PATH}/GameEngine/Application + ${EXE_SRC_PATH}/GameEngine/ServerSceneManager + ../Shared/Ecs/Src + ../Shared/Interface + ../Shared/SceneManager + ../Shared/Network/Packet + ../Shared/Component ) -add_subdirectory(Src/Network) +# Add subdirectory for network sources +add_subdirectory(${EXE_SRC_PATH}/Network) +# Add the executable target add_executable(${EXE} ${SRC_EXE}) +# Include directories for the executable target target_include_directories(${EXE} PUBLIC ${EXE_INCLUDE_PATH}) +# Find required packages find_package(asio REQUIRED) find_package(jsoncpp REQUIRED) +# Link libraries to the executable target target_link_libraries( ${EXE} PRIVATE asio::asio JsonCpp::JsonCpp r-type_ecs r-type_network_server -) - -add_custom_command(TARGET ${EXE} POST_BUILD - COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/Game/GameData - COMMAND cp -r ${CMAKE_SOURCE_DIR}/Engine/Server/Config/* ${CMAKE_SOURCE_DIR}/Game/GameData - COMMAND mkdir -p ${CMAKE_SOURCE_DIR}/Game/Mods -) +) \ No newline at end of file diff --git a/Engine/Server/Src/Network/CMakeLists.txt b/Engine/Server/Src/Network/CMakeLists.txt index a1710e5e..e109c70d 100644 --- a/Engine/Server/Src/Network/CMakeLists.txt +++ b/Engine/Server/Src/Network/CMakeLists.txt @@ -2,6 +2,8 @@ cmake_minimum_required(VERSION 3.10) set(LIB r-type_network_server) +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Game/Libs/Network/) + set(LIB_SRC_PATH ".") set(CMAKE_CXX_STANDARD 20) diff --git a/Engine/Shared/CMakeLists.txt b/Engine/Shared/CMakeLists.txt index 55603e88..7f776348 100644 --- a/Engine/Shared/CMakeLists.txt +++ b/Engine/Shared/CMakeLists.txt @@ -1,4 +1,6 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Add subdirectories for different components of the Engine add_subdirectory(Ecs) add_subdirectory(Network) diff --git a/Engine/Shared/Ecs/CMakeLists.txt b/Engine/Shared/Ecs/CMakeLists.txt index 0346d2c1..ee0d9750 100644 --- a/Engine/Shared/Ecs/CMakeLists.txt +++ b/Engine/Shared/Ecs/CMakeLists.txt @@ -1,16 +1,26 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 +set(CMAKE_CXX_STANDARD 20) + +# Set the library name set(LIB r-type_ecs) +# Set the output directory for the library +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Game/Libs/ECS/) + +# Define source and include paths set(LIB_SRC_PATH "Src") set(LIB_INCLUDE_PATH "Include") -set(CMAKE_CXX_STANDARD 20) - +# Define the main source files for the library set(SRC_LIB - ${LIB_SRC_PATH}/Registry.cpp + ${LIB_SRC_PATH}/Registry.cpp ) +# Add the static library target add_library(${LIB} STATIC ${SRC_LIB}) -target_include_directories(${LIB} PUBLIC ${INCLUDE_EXE}) +# Include directories for the library target +target_include_directories(${LIB} PUBLIC ${LIB_INCLUDE_PATH}) diff --git a/Engine/Shared/Network/CMakeLists.txt b/Engine/Shared/Network/CMakeLists.txt index 55f5f24b..bd0c44f5 100644 --- a/Engine/Shared/Network/CMakeLists.txt +++ b/Engine/Shared/Network/CMakeLists.txt @@ -1,3 +1,5 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Add subdirectory for Packet add_subdirectory(Packet) diff --git a/Engine/Shared/Network/Packet/CMakeLists.txt b/Engine/Shared/Network/Packet/CMakeLists.txt index 204492e2..9a29bada 100644 --- a/Engine/Shared/Network/Packet/CMakeLists.txt +++ b/Engine/Shared/Network/Packet/CMakeLists.txt @@ -1,20 +1,34 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 +set(CMAKE_CXX_STANDARD 20) + +# Set the library name set(LIB r-type_packet) -set(LIB_INCLUDE_PATH "Include") -set(CMAKE_CXX_STANDARD 20) +# Set the output directory for the library +set(LIBRARY_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/Game/Libs/Network/) +# Define include paths +set(LIB_INCLUDE_PATH "Include") + +# Define the main source files for the library set(SRC_LIB - NetworkPacket.cpp + NetworkPacket.cpp ) +# Add the static library target add_library(${LIB} STATIC ${SRC_LIB}) +# Find required packages find_package(asio CONFIG REQUIRED) + +# Link libraries to the library target target_link_libraries( ${LIB} PRIVATE asio::asio ) -target_include_directories(${LIB} PUBLIC ${INCLUDE_EXE}) +# Include directories for the library target +target_include_directories(${LIB} PUBLIC ${LIB_INCLUDE_PATH}) diff --git a/Game/Assets/.gitkeep b/Game/Assets/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/GraphicLibrary/CMakeLists.txt b/GraphicLibrary/CMakeLists.txt index 8719aa74..b03e20bd 100644 --- a/GraphicLibrary/CMakeLists.txt +++ b/GraphicLibrary/CMakeLists.txt @@ -1,13 +1,19 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 set(CMAKE_CXX_STANDARD 20) +# Set the output directory for the library set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Game/Config/GraphicLibrary/) +# Include directories for header files include_directories( - ../Engine/Shared/Interface/ + ${CMAKE_SOURCE_DIR}/Engine/Shared/Interface/ ) +# Add a shared library target 'graphic_raylib' add_library(graphic_raylib SHARED Src/GraphicLib.cpp) +# Link the 'raylib' library to 'graphic_raylib' target_link_libraries(graphic_raylib PRIVATE raylib) diff --git a/R-TypeGame/CMakeLists.txt b/R-TypeGame/CMakeLists.txt index 06c35a1d..389d5b75 100644 --- a/R-TypeGame/CMakeLists.txt +++ b/R-TypeGame/CMakeLists.txt @@ -1,3 +1,5 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Add the 'Systems' subdirectory to the build add_subdirectory(Systems) diff --git a/R-TypeGame/Systems/CMakeLists.txt b/R-TypeGame/Systems/CMakeLists.txt index 7135f591..b720cb41 100644 --- a/R-TypeGame/Systems/CMakeLists.txt +++ b/R-TypeGame/Systems/CMakeLists.txt @@ -1,17 +1,23 @@ +# Minimum required version of CMake cmake_minimum_required(VERSION 3.5) +# Set the C++ standard to C++20 set(CMAKE_CXX_STANDARD 20) -set (CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Game/Config/Systems/) +# Set the output directory for the library +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/Game/Config/Systems/) +# Include directories for header files include_directories( - ../../Engine/Shared/Ecs/Include/ - ../../Engine/Shared/Interface/ - ../../Engine/Shared/Component/ + ${CMAKE_SOURCE_DIR}/Engine/Shared/Ecs/Include/ + ${CMAKE_SOURCE_DIR}/Engine/Shared/Interface/ + ${CMAKE_SOURCE_DIR}/Engine/Shared/Component/ ) +# Add a shared library target 'system_initPlayer' add_library(system_initPlayer SHARED Players/PlayerInitSystem.cpp ../Components/Life/LifeComponent.cpp - ../../Engine/Shared/Component/Position3DComponent.cpp - ../../Engine/Shared/Component/ObjPathComponent.cpp) + ${CMAKE_SOURCE_DIR}/Engine/Shared/Component/Position3DComponent.cpp + ${CMAKE_SOURCE_DIR}/Engine/Shared/Component/ObjPathComponent.cpp +) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index f818a0b1..bf82658c 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -4,6 +4,8 @@ cmake_minimum_required(VERSION 3.5) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} --coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} --coverage") +set(EXECUTABLE_OUTPUT_PATH ${CMAKE_SOURCE_DIR}/tests) + add_executable(server_test ./Server/tests.cpp ) @@ -16,11 +18,6 @@ add_executable(ecs_test ./Server/tests.cpp ) -add_custom_command(TARGET server_test PRE_BUILD - COMMAND rm -fr ${CMAKE_SOURCE_DIR}/TestsResult - COMMAND mkdir ${CMAKE_SOURCE_DIR}/TestsResult -) - # enable testing functionality enable_testing()