From 3a9297ce38d23c12c939dae1968863c577602be7 Mon Sep 17 00:00:00 2001 From: Bilal Kahraman <45990633+bilalkah@users.noreply.github.com> Date: Thu, 29 Aug 2024 01:56:23 +0300 Subject: [PATCH] Configure cmake (#8) * Configure cmake * Make it parallel * Update readme --- CMakeLists.txt | 45 +++++++------------ README.md | 12 ++++- app/CMakeLists.txt | 22 +-------- app/main.cpp | 2 +- images/minimap.png | 3 ++ images/screenshot1.png | 3 ++ images/screenshot2.png | 3 ++ images/screenshot3.png | 3 ++ scripts/compile.sh | 4 +- scripts/install_deps.sh | 0 src/Animation/CMakeLists.txt | 7 --- src/Camera/CMakeLists.txt | 13 +----- src/Characters/CMakeLists.txt | 9 +--- src/CollisionManager/CMakeLists.txt | 10 +---- src/Core/CMakeLists.txt | 13 ++---- src/GameObjects/CMakeLists.txt | 11 ----- .../include/GameObjects/dynamic_object.h | 3 +- .../include/GameObjects/static_object.h | 1 - src/GameObjects/src/static_object.cpp | 1 - src/Graphics/CMakeLists.txt | 15 ++----- src/Map/CMakeLists.txt | 11 +---- src/Math/CMakeLists.txt | 7 --- src/NavigationManager/CMakeLists.txt | 13 +----- src/TextureManager/CMakeLists.txt | 8 ---- src/TimeManager/CMakeLists.txt | 8 ---- src/Utility/CMakeLists.txt | 11 ----- 26 files changed, 55 insertions(+), 183 deletions(-) create mode 100644 images/minimap.png create mode 100644 images/screenshot1.png create mode 100644 images/screenshot2.png create mode 100644 images/screenshot3.png mode change 100644 => 100755 scripts/install_deps.sh diff --git a/CMakeLists.txt b/CMakeLists.txt index fa84baa..ff527ef 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,26 +1,32 @@ cmake_minimum_required(VERSION 3.5) -project(wolfenstein VERSION 1.0 LANGUAGES CXX) +project(wolfenstein VERSION 1.0 LANGUAGES CXX C) add_definitions("-Wall" "-g") +add_definitions("-Wno-dev") +# Set the C++ standard to C++20 set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED ON) +# Set the output directory for the build executables and libraries +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib) + +# Set the executable name set(EXECUTABLE wolfenstein) set(PROJECT WOLFENSTEIN) -set(RESOURCE_DIR ${PROJECT_SOURCE_DIR}/assets/) +# Set the resource directory +set(RESOURCE_DIR ${PROJECT_SOURCE_DIR}/assets/) add_definitions( -DRESOURCE_DIR="${RESOURCE_DIR}" ) -# define debug mode -set(CMAKE_BUILD_TYPE Debug) -# set(CMAKE_BUILD_TYPE Release) - +# Find Git find_package(Git QUIET) +find_package(SDL2 REQUIRED) if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") -# Update submodules as needed +# Update submodules if any option(GIT_SUBMODULE "Check submodules during build" ON) if(GIT_SUBMODULE) message(STATUS "Submodule update") @@ -41,7 +47,7 @@ if(NOT EXISTS "${PROJECT_SOURCE_DIR}/third-party/path-planning/CMakeLists.txt") message(FATAL_ERROR "The submodules were not downloaded! GIT_SUBMODULE was turned off or failed. Please update submodules and try again.") endif() -# internal libraries +# internal libraries/modules add_subdirectory(app) add_subdirectory(src/Animation) add_subdirectory(src/Camera) @@ -57,27 +63,6 @@ add_subdirectory(src/TextureManager) add_subdirectory(src/TimeManager) add_subdirectory(src/Utility) -# external libraries +# external libraries/modules add_subdirectory(third-party/uuid_v4) add_subdirectory(third-party/path-planning) - -find_package(SDL2 REQUIRED) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/third-party - ${SDL2_INCLUDE_DIRS} -) - -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/third-party -) -set(LIBRARIES - ${SDL2_LIBRARIES} - SDL2_ttf - SDL2_image -) - diff --git a/README.md b/README.md index 202f4b2..8949ded 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,14 @@ # Project-Wolfenstein -## Installing dependencies +## Views from the game + +![](images/screenshot1.png) +![](images/screenshot2.png) +![](images/screenshot3.png) +![](images/minimap.png) + +## Install dependencies and build ```batch -bash install_deps.sh +./scripts/install_deps.sh +./scripts/compile.sh ``` \ No newline at end of file diff --git a/app/CMakeLists.txt b/app/CMakeLists.txt index 2c3d143..082902d 100644 --- a/app/CMakeLists.txt +++ b/app/CMakeLists.txt @@ -1,26 +1,6 @@ -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/include - ${SDL2_INCLUDE_DIRS} -) - -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR} - ${PROJECT_SOURCE_DIR}/include - ${SDL2_INCLUDE_DIRS} -) -set(LIBRARIES - ${SDL2_LIBRARIES} - SDL2_ttf - SDL2_image -) - add_executable(${EXECUTABLE} main.cpp) target_compile_definitions(${EXECUTABLE} PRIVATE DEBUG=1) target_link_libraries( ${EXECUTABLE} - ${LIBRARIES} game -) \ No newline at end of file +) diff --git a/app/main.cpp b/app/main.cpp index cc5ca86..6fa37e9 100644 --- a/app/main.cpp +++ b/app/main.cpp @@ -9,7 +9,7 @@ * */ -#include +#include "Core/game.h" int main() { using namespace wolfenstein; diff --git a/images/minimap.png b/images/minimap.png new file mode 100644 index 0000000..7d36889 --- /dev/null +++ b/images/minimap.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:64636c9f52392812f354096839f6c1682d94d3c60a1b7920ea1ab5becb432b5f +size 14696 diff --git a/images/screenshot1.png b/images/screenshot1.png new file mode 100644 index 0000000..83b088f --- /dev/null +++ b/images/screenshot1.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f4d35c33ae2c47cf21027099f709c19b47f325d44188c23dc15b1010a2c9825b +size 2150992 diff --git a/images/screenshot2.png b/images/screenshot2.png new file mode 100644 index 0000000..f621d4f --- /dev/null +++ b/images/screenshot2.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:15eb8e5b35434110dcdce127e0ebb59b9334529d8f8db98f077de1ab5674566f +size 2602201 diff --git a/images/screenshot3.png b/images/screenshot3.png new file mode 100644 index 0000000..1c05ee0 --- /dev/null +++ b/images/screenshot3.png @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:d4f56e6c70abab427d55af04f1a0537c3f5178b179bb1bc4cd432c38c52725d7 +size 2152048 diff --git a/scripts/compile.sh b/scripts/compile.sh index c203dc0..c2f3e58 100755 --- a/scripts/compile.sh +++ b/scripts/compile.sh @@ -1,2 +1,2 @@ -cmake -S . -B build -cmake --build build \ No newline at end of file +cmake -S . -B build -DCMAKE_BUILD_TYPE=Release +cmake --build build --config Release --parallel 8 \ No newline at end of file diff --git a/scripts/install_deps.sh b/scripts/install_deps.sh old mode 100644 new mode 100755 diff --git a/src/Animation/CMakeLists.txt b/src/Animation/CMakeLists.txt index 8fd6467..bd5e601 100644 --- a/src/Animation/CMakeLists.txt +++ b/src/Animation/CMakeLists.txt @@ -1,16 +1,9 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library( animation STATIC src/time_based_single_animation.cpp src/walk_animation.cpp ) - target_include_directories(animation PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) diff --git a/src/Camera/CMakeLists.txt b/src/Camera/CMakeLists.txt index 4732e19..81b8d8a 100644 --- a/src/Camera/CMakeLists.txt +++ b/src/Camera/CMakeLists.txt @@ -1,19 +1,10 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR} -) - -# Ray library add_library( ray STATIC src/ray.cpp ) target_include_directories(ray PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR} ) target_link_libraries( ray @@ -21,7 +12,7 @@ target_link_libraries( vector ) -# camera library + add_library( camera STATIC @@ -29,9 +20,7 @@ add_library( src/raycaster.cpp ) target_include_directories(camera PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR} ) target_link_libraries( camera diff --git a/src/Characters/CMakeLists.txt b/src/Characters/CMakeLists.txt index ffb3f76..60402c8 100644 --- a/src/Characters/CMakeLists.txt +++ b/src/Characters/CMakeLists.txt @@ -4,17 +4,9 @@ add_library( src/player.cpp src/enemy.cpp ) - target_include_directories(character PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - -target_link_directories(character PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - target_link_libraries( character PUBLIC @@ -22,5 +14,6 @@ target_link_libraries( vector collision_manager animation + SDL2 ) diff --git a/src/CollisionManager/CMakeLists.txt b/src/CollisionManager/CMakeLists.txt index 449a957..cdd71fa 100644 --- a/src/CollisionManager/CMakeLists.txt +++ b/src/CollisionManager/CMakeLists.txt @@ -1,23 +1,15 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library( collision_manager STATIC src/collision_manager.cpp ) - target_include_directories(collision_manager PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - target_link_libraries( collision_manager PUBLIC map vector game_object -) \ No newline at end of file +) diff --git a/src/Core/CMakeLists.txt b/src/Core/CMakeLists.txt index 567c909..6e8dc54 100644 --- a/src/Core/CMakeLists.txt +++ b/src/Core/CMakeLists.txt @@ -1,20 +1,11 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - - add_library( game STATIC src/game.cpp ) - target_include_directories(game PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - target_link_libraries( game PUBLIC @@ -30,4 +21,6 @@ target_link_libraries( texture_manager navigation_manager SDL2 -) \ No newline at end of file + SDL2_image + SDL2_ttf +) diff --git a/src/GameObjects/CMakeLists.txt b/src/GameObjects/CMakeLists.txt index c05b48d..cb6ebab 100644 --- a/src/GameObjects/CMakeLists.txt +++ b/src/GameObjects/CMakeLists.txt @@ -1,27 +1,16 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR} -) - add_library( game_object STATIC src/static_object.cpp src/dynamic_object.cpp ) - target_include_directories(game_object PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR} ) - target_link_libraries( game_object PUBLIC vector - character uuid_generator animation ) diff --git a/src/GameObjects/include/GameObjects/dynamic_object.h b/src/GameObjects/include/GameObjects/dynamic_object.h index f133d7b..f300d7e 100644 --- a/src/GameObjects/include/GameObjects/dynamic_object.h +++ b/src/GameObjects/include/GameObjects/dynamic_object.h @@ -12,9 +12,8 @@ #ifndef GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H #define GAME_OBJECTS_INCLUDE_DYNAMIC_OBJECT_H -#include "Animation/time_based_single_animation.h" +#include "Animation/animation.h" #include "GameObjects/game_object.h" -#include "Utility/uuid_generator.h" #include namespace wolfenstein { diff --git a/src/GameObjects/include/GameObjects/static_object.h b/src/GameObjects/include/GameObjects/static_object.h index 3676f8a..e08d018 100644 --- a/src/GameObjects/include/GameObjects/static_object.h +++ b/src/GameObjects/include/GameObjects/static_object.h @@ -12,7 +12,6 @@ #ifndef GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H #define GAME_OBJECTS_INCLUDE_STATIC_OBJECT_H -#include "Characters/character.h" #include "GameObjects/game_object.h" #include "Math/vector.h" diff --git a/src/GameObjects/src/static_object.cpp b/src/GameObjects/src/static_object.cpp index c3e7101..3523c18 100644 --- a/src/GameObjects/src/static_object.cpp +++ b/src/GameObjects/src/static_object.cpp @@ -1,5 +1,4 @@ #include "GameObjects/static_object.h" -#include "GameObjects/game_object.h" #include "Utility/uuid_generator.h" namespace wolfenstein { diff --git a/src/Graphics/CMakeLists.txt b/src/Graphics/CMakeLists.txt index 2bd5a67..b31f704 100644 --- a/src/Graphics/CMakeLists.txt +++ b/src/Graphics/CMakeLists.txt @@ -1,19 +1,11 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library( scene STATIC src/scene.cpp ) - target_include_directories(scene PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - target_link_libraries( scene PUBLIC @@ -27,16 +19,17 @@ add_library( STATIC src/renderer.cpp ) - target_include_directories(renderer PUBLIC ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - target_link_libraries( renderer PUBLIC camera texture_manager navigation_manager -) \ No newline at end of file + SDL2 + SDL2_image + SDL2_ttf +) diff --git a/src/Map/CMakeLists.txt b/src/Map/CMakeLists.txt index d665b96..ecb9d4a 100644 --- a/src/Map/CMakeLists.txt +++ b/src/Map/CMakeLists.txt @@ -3,21 +3,12 @@ add_library( STATIC src/map.cpp ) - target_include_directories(map PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/third-party/ ) - -target_link_directories(map PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/third-party/path-planning/planning/utility -) - target_link_libraries( map PUBLIC common_planning -) \ No newline at end of file +) diff --git a/src/Math/CMakeLists.txt b/src/Math/CMakeLists.txt index c6fec2a..4a209c5 100644 --- a/src/Math/CMakeLists.txt +++ b/src/Math/CMakeLists.txt @@ -1,15 +1,8 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library( vector STATIC src/vector.cpp ) - target_include_directories(vector PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) diff --git a/src/NavigationManager/CMakeLists.txt b/src/NavigationManager/CMakeLists.txt index ccc1693..0a2af5c 100644 --- a/src/NavigationManager/CMakeLists.txt +++ b/src/NavigationManager/CMakeLists.txt @@ -3,19 +3,10 @@ add_library( STATIC src/navigation_manager.cpp ) - target_include_directories(navigation_manager PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/third-party/path-planning + ${PROJECT_SOURCE_DIR}/third-party/ ) - -target_link_directories(navigation_manager PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include - ${PROJECT_SOURCE_DIR}/third-party/path-planning -) - target_link_libraries( navigation_manager PUBLIC @@ -23,4 +14,4 @@ target_link_libraries( character astar map -) \ No newline at end of file +) diff --git a/src/TextureManager/CMakeLists.txt b/src/TextureManager/CMakeLists.txt index cb2b73d..7b8ff03 100644 --- a/src/TextureManager/CMakeLists.txt +++ b/src/TextureManager/CMakeLists.txt @@ -1,19 +1,11 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library( texture_manager STATIC src/texture_manager.cpp ) - target_include_directories(texture_manager PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) - target_link_libraries( texture_manager PUBLIC diff --git a/src/TimeManager/CMakeLists.txt b/src/TimeManager/CMakeLists.txt index f245a32..53cc1f2 100644 --- a/src/TimeManager/CMakeLists.txt +++ b/src/TimeManager/CMakeLists.txt @@ -1,16 +1,8 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - - add_library( time_manager STATIC src/time_manager.cpp ) - target_include_directories(time_manager PUBLIC - ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/include ) diff --git a/src/Utility/CMakeLists.txt b/src/Utility/CMakeLists.txt index 1bc7fa3..bd540b4 100644 --- a/src/Utility/CMakeLists.txt +++ b/src/Utility/CMakeLists.txt @@ -1,16 +1,6 @@ -link_directories( - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - -include_directories( - ${CMAKE_CURRENT_SOURCE_DIR}/include -) - add_library(utilities src/logger.cpp ) - target_include_directories(utilities PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ) @@ -18,7 +8,6 @@ target_include_directories(utilities PUBLIC add_library(uuid_generator src/uuid_generator.cpp ) - target_include_directories(uuid_generator PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/include ${PROJECT_SOURCE_DIR}/third-party