Skip to content

Commit 1c1e787

Browse files
committed
Code Restructure To Reduce Disk Usage and Help Readability
- Move from github-submodule structure to use CMake's native dependency management facilities. (https://cmake.org/cmake/help/latest/guide/using-dependencies/index.html). Ideally the dependencies are to be installed using native mechanisms like vcpkg on windows, the linux distribution package manager or homebrew for mac. CMake will find the installed versions as a first option but build the dependencies if not available in the Build Directory at Build time. The linux_build code action is an example of this working in linux. - Restructure The #include statements to indicate the project source, this prevents confusion and is easier to read at the source file. It is also a consistent way to describe the included header and to reason about the include structure. This also is to pave the way to converting to modules. - Explicit Code file declaration in CMake as opposed to File Globbing which is only run once during build system generation. When creating a new file, it is suggested to specify it in the CMake File which will enhance tracking and ensure that it is picked up at build time due to changes in the CMake Files. - Changed Bitmap.h to utf-8 from iso-8859 - Changed from MSVC style of pre-compiled headers, just using plain header includes for portability. Another benefit is storage savings as the pch file was taking up too much space(in my experience)
1 parent d8aa9f3 commit 1c1e787

File tree

257 files changed

+1310
-1465
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

257 files changed

+1310
-1465
lines changed

.clang-format

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ PenaltyBreakTemplateDeclaration: 100
120120
PenaltyReturnTypeOnItsOwnLine: 300
121121
PointerAlignment: Left
122122
ReflowComments: true
123-
SortIncludes: true
123+
SortIncludes: false
124124
SortUsingDeclarations: true
125125
SpaceAfterCStyleCast: true
126126
SpaceAfterLogicalNot: false

.github/workflows/linux-build.yml

Lines changed: 11 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -10,50 +10,21 @@ on:
1010

1111
jobs:
1212
Linux-Build:
13-
runs-on: ubuntu-latest
14-
strategy:
15-
matrix:
16-
buildConfiguration: [Debug, Release]
13+
runs-on: ubuntu-24.04
1714

1815
steps:
1916
- name: Checkout repository
20-
uses: actions/checkout@v2
17+
uses: actions/checkout@v3
2118

22-
# - name: Checkout submodules
23-
# run: git submodule update --init --recursive
19+
- name: Install development library
20+
run: sudo apt-get update && sudo apt-get install -y git libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev cmake gcc g++ ninja-build libassimp-dev libfmt-dev libimgui-dev libstb-dev libglfw3-dev libspdlog-dev libglm-dev libyaml-cpp-dev libspirv-cross-c-shared-dev spirv-cross spirv-tools glslang-dev glslang-tools nlohmann-json3-dev dotnet-runtime-8.0 libgtest-dev
2421

25-
# - name: Install development library
26-
# run: sudo apt-get install libasound2-dev libgl1-mesa-dev libpulse-dev libdbus-1-dev libx11-dev libxcursor-dev libxext-dev libxi-dev libxinerama-dev libxrandr-dev libxss-dev libxt-dev libxxf86vm-dev
22+
- name: Create CMake Build Directory
23+
run: mkdir ../build && cmake -B ../build -DCMAKE_BUILD_TYPE=Debug -G Ninja
2724

28-
# - name: Install CMake
29-
# uses: jwlawson/actions-setup-cmake@v1.9
30-
# with:
31-
# cmake-version: '3.20.x'
25+
- name: Build
26+
run: cmake --build ../build
3227

33-
# - name: Install pre-requisite packages.
34-
# run: sudo apt-get install -y wget apt-transport-https software-properties-common
35-
36-
# - name: Download the Microsoft repository GPG keys
37-
# run: wget -q https://packages.microsoft.com/config/ubuntu/18.04/packages-microsoft-prod.deb
38-
39-
# - name: Register the Microsoft repository GPG keys
40-
# run: sudo dpkg -i packages-microsoft-prod.deb
41-
42-
# - name: Update the list of packages after we added packages.microsoft.com
43-
# run: sudo apt-get update
44-
45-
# - name: Install PowerShell
46-
# run: sudo apt-get install -y powershell
47-
48-
# - name: Add GCC Toolchain repository
49-
# run: sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
50-
51-
# - name: Install GCC compiler
52-
# run: sudo apt install -y gcc-11
53-
54-
# - name: Install G++ compiler
55-
# run: sudo apt install -y g++-11
56-
57-
# - name: CMake Build
58-
# run: .\Scripts\BuildEngine.ps1 -Configurations ${{matrix.buildConfiguration}}
59-
# shell: pwsh
28+
- name: Test
29+
run: ctest .
30+
working-directory: ../build/ZEngine/tests

.gitmodules

Lines changed: 0 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -1,69 +0,0 @@
1-
[submodule "__externals/fmt"]
2-
path = __externals/fmt
3-
url = https://github.com/fmtlib/fmt
4-
[submodule "__externals/stb"]
5-
path = __externals/stb
6-
url = https://github.com/nothings/stb
7-
[submodule "__externals/imgui/src"]
8-
path = __externals/imgui/src
9-
url = https://github.com/ocornut/imgui
10-
[submodule "__externals/spdlog"]
11-
path = __externals/spdlog
12-
url = https://github.com/gabime/spdlog
13-
[submodule "__externals/glfw"]
14-
path = __externals/glfw
15-
url = https://github.com/glfw/glfw
16-
[submodule "__externals/entt"]
17-
path = __externals/entt
18-
url = https://github.com/skypjack/entt
19-
[submodule "__externals/assimp"]
20-
path = __externals/assimp
21-
url = https://github.com/assimp/assimp
22-
[submodule "__externals/stduuid"]
23-
path = __externals/stduuid
24-
url = https://github.com/mariusbancila/stduuid
25-
[submodule "__externals/yaml-cpp"]
26-
path = __externals/yaml-cpp
27-
url = https://github.com/jbeder/yaml-cpp
28-
[submodule "__externals/ImGuizmo"]
29-
path = __externals/ImGuizmo
30-
url = https://github.com/CedricGuillemet/ImGuizmo
31-
[submodule "__externals/SPIRV-Cross"]
32-
path = __externals/SPIRV-Cross
33-
url = https://github.com/KhronosGroup/SPIRV-Cross
34-
[submodule "__externals/gtest"]
35-
path = __externals/gtest
36-
url = https://github.com/google/googletest
37-
[submodule "__externals/VulkanMemoryAllocator"]
38-
path = __externals/VulkanMemoryAllocator
39-
url = https://github.com/GPUOpen-LibrariesAndSDKs/VulkanMemoryAllocator
40-
[submodule "__externals/nlohmann_json"]
41-
path = __externals/nlohmann_json
42-
url = https://github.com/nlohmann/json
43-
[submodule "__externals/glslang"]
44-
path = __externals/glslang
45-
url = https://github.com/khronosGroup/glslang.git
46-
[submodule "__externals/SPIRV-headers"]
47-
path = __externals/SPIRV-headers
48-
url = https://github.com/khronosGroup/SPIRV-headers.git
49-
[submodule "__externals/SPIRV-Tools"]
50-
path = __externals/SPIRV-Tools
51-
url = https://github.com/khronosGroup/SPIRV-Tools
52-
[submodule "__externals/Vulkan-Loader"]
53-
path = __externals/Vulkan-Loader
54-
url = https://github.com/KhronosGroup/Vulkan-Loader
55-
[submodule "__externals/glm"]
56-
path = __externals/glm
57-
url = https://github.com/g-truc/glm
58-
[submodule "__externals/Vulkan-Headers"]
59-
path = __externals/Vulkan-Headers
60-
url = https://github.com/KhronosGroup/Vulkan-Headers
61-
[submodule "__externals/tlsf/src"]
62-
path = __externals/tlsf/src
63-
url = https://github.com/mattconte/tlsf
64-
[submodule "__externals/CLI11"]
65-
path = __externals/CLI11
66-
url = https://github.com/CLIUtils/CLI11
67-
[submodule "__externals/rapidhash/src"]
68-
path = __externals/rapidhash/src
69-
url = https://github.com/Nicoshev/rapidhash

CMakeLists.txt

Lines changed: 58 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -1,115 +1,81 @@
1-
cmake_minimum_required (VERSION 3.17 FATAL_ERROR)
1+
cmake_minimum_required(VERSION 3.17 FATAL_ERROR)
22

3-
project (RendererEngine
4-
VERSION 1.0
5-
DESCRIPTION "Renderer Engine is an open-source 2D - 3D rendering engine written in C/C++"
6-
LANGUAGES CXX C
7-
)
3+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
4+
set(CMAKE_CXX_EXTENSIONS OFF)
5+
set(CMAKE_CXX_STANDARD 20)
86

9-
set_property (GLOBAL PROPERTY USE_FOLDERS ON)
7+
project(
8+
RendererEngine
9+
VERSION 1.0
10+
DESCRIPTION
11+
"Renderer Engine is an open-source 2D - 3D rendering engine written in C/C++"
12+
LANGUAGES CXX)
13+
14+
set_property(GLOBAL PROPERTY USE_FOLDERS ON)
1015

1116
# Core invariants
1217
#
13-
get_filename_component (ENLISTMENT_ROOT "." ABSOLUTE CACHE)
14-
get_filename_component (EXTERNAL_DIR "${ENLISTMENT_ROOT}/__externals" ABSOLUTE CACHE)
15-
get_filename_component (EXTERNAL_NUGET_DIR "${ENLISTMENT_ROOT}/__externals/nuget" ABSOLUTE CACHE)
18+
get_filename_component(ENLISTMENT_ROOT "." ABSOLUTE CACHE)
19+
get_filename_component(EXAMPLE_DIR "${ENLISTMENT_ROOT}/Examples" ABSOLUTE CACHE)
1620

1721
include(${ENLISTMENT_ROOT}/Scripts/CMake/NuGet.cmake)
18-
include(${ENLISTMENT_ROOT}/Scripts/CMake/CppWinRT.cmake)
19-
include(${ENLISTMENT_ROOT}/dependencies.cmake)
20-
2122

22-
option (COPY_EXAMPLE_PROJECT "Copy example projects that show how to use Launcher" ON)
23-
option (LAUNCHER_ONLY "Build Launcher only" OFF)
24-
25-
set (MACOSX_ARCHITECTURE_ARM64 OFF)
26-
if (APPLE)
27-
# Use uname to detect the macOS processor architecture
28-
execute_process(
29-
COMMAND uname -m
30-
OUTPUT_VARIABLE MACOSX_ARCHITECTURE
31-
OUTPUT_STRIP_TRAILING_WHITESPACE
32-
)
33-
if (MACOSX_ARCHITECTURE STREQUAL "arm64")
34-
set (MACOSX_ARCHITECTURE_ARM64 ON)
35-
endif ()
36-
endif ()
23+
option(COPY_EXAMPLE_PROJECT
24+
"Copy example projects that show how to use Launcher" ON)
25+
option(LAUNCHER_ONLY "Build Launcher only" OFF)
26+
27+
set(MACOSX_ARCHITECTURE_ARM64 OFF)
28+
if(APPLE)
29+
# Use uname to detect the macOS processor architecture
30+
execute_process(
31+
COMMAND uname -m
32+
OUTPUT_VARIABLE MACOSX_ARCHITECTURE
33+
OUTPUT_STRIP_TRAILING_WHITESPACE)
34+
if(MACOSX_ARCHITECTURE STREQUAL "arm64")
35+
set(MACOSX_ARCHITECTURE_ARM64 ON)
36+
endif()
37+
endif()
3738

3839
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
3940
add_compile_definitions(_SILENCE_STDEXT_ARR_ITERS_DEPRECATION_WARNING) # Fix Warning from VS 2022 +
4041
endif()
4142

42-
# Externals dependencies
43-
#
44-
if (NOT LAUNCHER_ONLY)
45-
add_subdirectory (${EXTERNAL_DIR}/fmt)
46-
add_subdirectory (${EXTERNAL_DIR}/imgui)
47-
add_subdirectory (${EXTERNAL_DIR}/glfw)
48-
add_subdirectory (${EXTERNAL_DIR}/spdlog)
49-
add_subdirectory (${EXTERNAL_DIR}/glm)
50-
add_subdirectory (${EXTERNAL_DIR}/entt)
51-
add_subdirectory (${EXTERNAL_DIR}/assimp)
52-
add_subdirectory (${EXTERNAL_DIR}/stduuid)
53-
add_subdirectory (${EXTERNAL_DIR}/yaml-cpp)
54-
add_subdirectory (${EXTERNAL_DIR}/SPIRV-headers)
55-
add_subdirectory (${EXTERNAL_DIR}/SPIRV-Tools)
56-
add_subdirectory (${EXTERNAL_DIR}/glslang)
57-
add_subdirectory (${EXTERNAL_DIR}/SPIRV-Cross)
58-
add_subdirectory (${EXTERNAL_DIR}/gtest)
59-
add_subdirectory (${EXTERNAL_DIR}/VulkanMemoryAllocator)
60-
add_subdirectory (${EXTERNAL_DIR}/tlsf)
61-
add_subdirectory (${EXTERNAL_DIR}/rapidhash)
62-
add_subdirectory (${EXTERNAL_DIR}/CLI11)
63-
64-
set (CMAKE_PREFIX_PATH
65-
${CMAKE_PREFIX_PATH}
66-
${EXTERNAL_DIR}/Vulkan-Headers/build/install/share/cmake
67-
)
68-
add_subdirectory (${EXTERNAL_DIR}/Vulkan-Loader)
43+
include(externals.cmake)
6944

70-
# Core engine lib is here
71-
#
72-
add_subdirectory (ZEngine)
45+
# Core engine lib is here
46+
#
47+
add_subdirectory(ZEngine)
7348

74-
# Editor is here
75-
#
76-
add_subdirectory (Tetragrama)
77-
endif ()
49+
# Editor is here
50+
#
51+
add_subdirectory(Tetragrama)
7852

7953
# Launcher is here
8054
#
81-
add_subdirectory (Panzerfaust)
55+
add_subdirectory (Panzerfaust)
8256

83-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
84-
set_property (DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT Panzerfaust)
85-
endif ()
57+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
58+
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT
59+
Panzerfaust)
60+
endif()
8661

8762
# Post build operation
8863
#
89-
set (SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
90-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
91-
set (SYSTEM_ARCHITECTURE "win-x64")
92-
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
93-
set (SYSTEM_ARCHITECTURE "linux-x64")
94-
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
95-
if (MACOSX_ARCHITECTURE_ARM64)
96-
set (SYSTEM_ARCHITECTURE "osx-arm64")
97-
else ()
98-
set (SYSTEM_ARCHITECTURE "osx-x64")
99-
endif ()
100-
endif ()
101-
102-
add_custom_target (AssembleContent ALL
103-
COMMENT "Copying assets and resources contents"
104-
COMMAND pwsh ${CMAKE_CURRENT_SOURCE_DIR}/Scripts/PostBuild.ps1 -SystemName ${SYSTEM_NAME} -Architectures ${SYSTEM_ARCHITECTURE} -Configurations $<IF:$<CONFIG:Debug>,Debug,Release> $<$<BOOL:${LAUNCHER_ONLY}>:-LauncherOnly>
105-
)
106-
107-
if (NOT LAUNCHER_ONLY)
108-
add_dependencies(AssembleContent zEngineLib tetragrama)
109-
endif ()
64+
set(SYSTEM_NAME ${CMAKE_SYSTEM_NAME})
65+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
66+
set(SYSTEM_ARCHITECTURE "win-x64")
67+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
68+
set(SYSTEM_ARCHITECTURE "linux-x64")
69+
elseif(${CMAKE_SYSTEM_NAME} STREQUAL "Darwin")
70+
if(MACOSX_ARCHITECTURE_ARM64)
71+
set(SYSTEM_ARCHITECTURE "osx-arm64")
72+
else()
73+
set(SYSTEM_ARCHITECTURE "osx-x64")
74+
endif()
75+
endif()
11076

111-
if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
112-
add_dependencies(AssembleContent Panzerfaust-WinBuild)
113-
else ()
114-
add_dependencies(AssembleContent Panzerfaust)
115-
endif ()
77+
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
78+
# add_dependencies(AssembleContent Panzerfaust-WinBuild)
79+
else()
80+
# add_dependencies(AssembleContent Panzerfaust)
81+
endif()

0 commit comments

Comments
 (0)