Skip to content

Commit

Permalink
Configure cmake (#8)
Browse files Browse the repository at this point in the history
* Configure cmake

* Make it parallel

* Update readme
  • Loading branch information
bilalkah authored Aug 28, 2024
1 parent cfeddd5 commit 3a9297c
Show file tree
Hide file tree
Showing 26 changed files with 55 additions and 183 deletions.
45 changes: 15 additions & 30 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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")
Expand All @@ -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)
Expand All @@ -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
)

12 changes: 10 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
```
22 changes: 1 addition & 21 deletions app/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
)
2 changes: 1 addition & 1 deletion app/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
*
*/

#include <Core/game.h>
#include "Core/game.h"

int main() {
using namespace wolfenstein;
Expand Down
3 changes: 3 additions & 0 deletions images/minimap.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/screenshot2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions images/screenshot3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions scripts/compile.sh
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cmake -S . -B build
cmake --build build
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
cmake --build build --config Release --parallel 8
Empty file modified scripts/install_deps.sh
100644 → 100755
Empty file.
7 changes: 0 additions & 7 deletions src/Animation/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
13 changes: 1 addition & 12 deletions src/Camera/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,37 +1,26 @@
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
PUBLIC
vector
)

# camera library

add_library(
camera
STATIC
src/camera.cpp
src/raycaster.cpp
)
target_include_directories(camera PUBLIC
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
${PROJECT_SOURCE_DIR}
)
target_link_libraries(
camera
Expand Down
9 changes: 1 addition & 8 deletions src/Characters/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,23 +4,16 @@ 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
game_object
vector
collision_manager
animation
SDL2
)

10 changes: 1 addition & 9 deletions src/CollisionManager/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
)
13 changes: 3 additions & 10 deletions src/Core/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -30,4 +21,6 @@ target_link_libraries(
texture_manager
navigation_manager
SDL2
)
SDL2_image
SDL2_ttf
)
11 changes: 0 additions & 11 deletions src/GameObjects/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
3 changes: 1 addition & 2 deletions src/GameObjects/include/GameObjects/dynamic_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <memory>

namespace wolfenstein {
Expand Down
1 change: 0 additions & 1 deletion src/GameObjects/include/GameObjects/static_object.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand Down
1 change: 0 additions & 1 deletion src/GameObjects/src/static_object.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
#include "GameObjects/static_object.h"
#include "GameObjects/game_object.h"
#include "Utility/uuid_generator.h"

namespace wolfenstein {
Expand Down
15 changes: 4 additions & 11 deletions src/Graphics/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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
)
SDL2
SDL2_image
SDL2_ttf
)
Loading

0 comments on commit 3a9297c

Please sign in to comment.