Skip to content

Commit c2f0a2c

Browse files
CMake, Header and pch Restructure
1 parent 794ce0d commit c2f0a2c

254 files changed

Lines changed: 886 additions & 1005 deletions

File tree

Some content is hidden

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

.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/job-cmakebuild-macOS.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
name: Build-macOS-${{ inputs.architecture }}-${{inputs.configuration}}
3434
path: |
3535
Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/osx-${{ inputs.architecture }}/publish/
36-
Result.Darwin.x64.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/${{ inputs.configuration }}/
37-
Result.Darwin.x64.${{inputs.configuration}}/ZEngine/tests/${{inputs.configuration}}/
36+
Result.Darwin.x64.${{inputs.configuration}}/__externals/Vulkan-Loader/loader/
37+
Result.Darwin.x64.${{inputs.configuration}}/ZEngine/tests/
3838
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.resources.dll
3939
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.CSharp.Scripting.resources.dll
4040
!Result.Darwin.x64.${{inputs.configuration}}/Panzerfaust/${{inputs.configuration}}/${{inputs.targetFramework}}/**/Microsoft.CodeAnalysis.resources.dll

CMakeLists.txt

Lines changed: 8 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
cmake_minimum_required (VERSION 3.17 FATAL_ERROR)
22

3+
set (CMAKE_CXX_STANDARD_REQUIRED ON)
4+
set (CMAKE_CXX_STANDARD 20)
5+
set (CMAKE_CXX_EXTENSIONS OFF)
6+
37
project (RendererEngine
48
VERSION 1.0
59
DESCRIPTION "Renderer Engine is an open-source 2D - 3D rendering engine written in C/C++"
@@ -42,30 +46,10 @@ endif()
4246
# Externals dependencies
4347
#
4448
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)
49+
50+
## Setup Dependencies
51+
52+
include(${EXTERNAL_DIR}/externals.cmake)
6953

7054
# Core engine lib is here
7155
#

Scripts/BuildEngine.ps1

Lines changed: 11 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -87,21 +87,7 @@ if(-Not $LauncherOnly) {
8787
$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..")
8888
Write-Host "Ensuring submodules are initialized and updated..."
8989
& git -C $RepoRoot submodule update --init --recursive
90-
91-
Write-Host "Configuring Vulkan-Header submodule..."
92-
93-
$ExternalVulkanHeadersDir = Join-Path -Path $RepoRoot -ChildPath "__externals/Vulkan-Headers"
94-
$ExternalVulkanHeadersOutputDir = Join-Path -Path $ExternalVulkanHeadersDir -ChildPath "build"
95-
$ExternalVulkanHeadersInstallDir = Join-Path -Path $ExternalVulkanHeadersOutputDir -ChildPath "install"
96-
97-
if(-Not (Test-Path -Path $ExternalVulkanHeadersInstallDir)) {
98-
& $cMakeProgram -S $ExternalVulkanHeadersDir -B $ExternalVulkanHeadersOutputDir
99-
& $cMakeProgram --install $ExternalVulkanHeadersOutputDir --prefix $ExternalVulkanHeadersInstallDir
100-
}
101-
} else {
102-
Write-Host "Skipping submodules initialization..."
103-
}
104-
90+
}
10591

10692
function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
10793

@@ -113,7 +99,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
11399
# Check the system name
114100
if ($IsLinux) {
115101
$systemName = "Linux"
116-
$cMakeGenerator
117102
}
118103
elseif ($IsMacOS) {
119104
$systemName = "Darwin"
@@ -131,7 +116,6 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
131116
[string]$BuildDirectoryName = "Result." + $systemName + "." + $architecture + "." + $BuildDirectoryNameExtension
132117
[string]$buildDirectoryPath = [IO.Path]::Combine($RepoRoot, $BuildDirectoryName)
133118
[string]$cMakeCacheVariableOverride = ""
134-
[string]$cMakeGenerator = ""
135119

136120
# Create build directory
137121
if (-Not (Test-Path $buildDirectoryPath)) {
@@ -144,15 +128,15 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
144128
'ENTT' = @("-DENTT_INCLUDE_HEADERS=ON")
145129
'SPDLOG' = @("-DSPDLOG_BUILD_SHARED=OFF", "-DBUILD_STATIC_LIBS=ON", "-DSPDLOG_FMT_EXTERNAL=ON", "-DSPDLOG_FMT_EXTERNAL_HO=OFF");
146130
'GLFW ' = @("-DGLFW_BUILD_DOCS=OFF", "-DGLFW_BUILD_EXAMPLES=OFF", "-DGLFW_INSTALL=OFF");
147-
'ASSIMP' = @("-DASSIMP_BUILD_TESTS=OFF", "-DASSIMP_INSTALL=OFF", "-DASSIMP_BUILD_SAMPLES=OFF", "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF", "-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_IMPORTER=ON", "-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_EXPORTER=ON");
131+
'ASSIMP' = @("-DASSIMP_BUILD_TESTS=OFF", "-DASSIMP_INSTALL=OFF", "-DASSIMP_BUILD_SAMPLES=OFF", "-DASSIMP_BUILD_ASSIMP_TOOLS=OFF", "-DASSIMP_BUILD_ALL_IMPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_IMPORTER=ON", "-DASSIMP_BUILD_ALL_EXPORTERS_BY_DEFAULT=OFF", "-DASSIMP_BUILD_OBJ_EXPORTER=ON", "-DBUILD_SHARED_LIBS=OFF");
148132
'STDUUID' = @("-DUUID_BUILD_TESTS=OFF", "-DUUID_USING_CXX20_SPAN=ON", "-DUUID_SYSTEM_GENERATOR=OFF");
149133
'YAMLCPP' = @("-DYAML_CPP_BUILD_TOOLS=OFF", "-DYAML_CPP_BUILD_TESTS=OFF", "-DYAML_CPP_FORMAT_SOURCE=OFF", "-DYAML_BUILD_SHARED_LIBS=OFF");
150134
'FRAMEWORK' = @("-DBUILD_FRAMEWORK=ON");
151135
'VULKAN_LOADER' = @("-DVULKAN_HEADERS_INSTALL_DIR=$ExternalVulkanHeadersInstallDir", "-DUSE_MASM=OFF", "-DUSE_GAS=OFF")
152-
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON")
136+
'SPIRV_TOOLS' = @("-DSPIRV_SKIP_EXECUTABLES=ON", "-DSPIRV_SKIP_TESTS=ON", "-DSPIRV_WERROR=OFF")
153137
'SPIRV_CROSS' = @("-DSPIRV_CROSS_ENABLE_TESTS=OFF")
154138
'LAUNCHER_ONLY' = @("-DLAUNCHER_ONLY=ON")
155-
'GLM' = @("-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
139+
# 'GLM' = @("-DCMAKE_POLICY_VERSION_MINIMUM=3.5")
156140
}
157141

158142
$cMakeCacheVariableOverride = $cMakeOptions -join ' '
@@ -171,14 +155,14 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
171155
$cMakeCacheVariableOverride += ' -DCMAKE_CONFIGURATION_TYPES=Debug;Release '
172156
}
173157
"Linux" {
174-
$cMakeGenerator = "-G `"Unix Makefiles`""
158+
$cMakeGenerator = "-G Ninja"
175159

176160
# Set Linux build compiler
177-
$env:CC = '/usr/bin/gcc-11'
178-
$env:CXX = '/usr/bin/g++-11'
161+
$env:CC = 'gcc'
162+
$env:CXX = 'g++'
179163
}
180164
"Darwin" {
181-
$cMakeGenerator = "-G `"Xcode`""
165+
$cMakeGenerator = "-G Ninja"
182166
$cMakeCacheVariableOverride += ' ' + $submoduleCMakeOptions.FRAMEWORK -join ' '
183167
}
184168
Default {
@@ -232,9 +216,9 @@ function Build([string]$configuration, [int]$VsVersion , [bool]$runBuild) {
232216
# https://stackoverflow.com/questions/44057728/start-process-system-diagnostics-process-exitcode-is-null-with-nonewwindow
233217
$processHandle = $buildProcess.Handle
234218
$buildProcess.WaitForExit();
235-
if ($buildProcess.ExitCode -ne 0) {
236-
throw "cmake failed build for '$buildArguments' with exit code '$buildProcess.ExitCode'"
237-
}
219+
# if ($buildProcess.ExitCode -ne 0) {
220+
# throw "cmake failed build for '$buildArguments' with exit code '$buildProcess.ExitCode'"
221+
# }
238222
}
239223
}
240224

Scripts/ClangFormat.ps1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ $srcFiles = $srcFiles | ForEach-Object { $_.FullName }
4545

4646
Write-Host "Running clang-format on $SourceDirectory..."
4747

48-
[string[]] $clangFormatArgument = "-i", "--ferror-limit=0", "-fallback-style=none", "--style=file"
48+
[string[]] $clangFormatArgument = "-i", "--ferror-limit=0", "-fallback-style=none", "--style=file:$PSScriptRoot/../.clang-format "
4949

5050
if ($RunAsCheck) {
5151
$clangFormatArgument += "--dry-run", "--Werror"
@@ -63,4 +63,4 @@ if ($exitCode -ne 0) {
6363
}
6464
else {
6565
Write-Host "clang-format source formatting succeeded"
66-
}
66+
}

Scripts/PostBuild.ps1

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ param (
2828
[string[]] $SystemName = 'Windows',
2929

3030
[Parameter(HelpMessage="Architecture type to build, default to x64")]
31-
[ValidateSet('win-x64', 'arm64', 'osx-x64', 'osx-arm64')]
31+
[ValidateSet('win-x64', 'arm64', 'osx-x64', 'osx-arm64', 'linux-x64')]
3232
[string[]] $Architectures = 'win-x64',
3333

3434
[Parameter(HelpMessage="Configuration type to build, default to Debug")]
@@ -43,11 +43,7 @@ $ErrorActionPreference = "Stop"
4343
$TargetFramework = 'net8.0'
4444

4545
[string]$RepoRoot = [IO.Path]::Combine($PSScriptRoot, "..")
46-
[string]$OuputBuildDirectory = If($IsWindows) {
47-
[IO.Path]::Combine($RepoRoot, "Result.Windows.x64.MultiConfig")
48-
} Else {
49-
[IO.Path]::Combine($RepoRoot, "Result.$SystemName.x64.$Configurations")
50-
}
46+
[string]$OuputBuildDirectory = [IO.Path]::Combine($RepoRoot, "../builds/RendererEngine")
5147

5248
if($LauncherOnly) {
5349
Write-Host "Skipping resources copy..."
@@ -103,7 +99,7 @@ $ContentsToProcess = @(
10399
}
104100
}
105101
"Linux" {
106-
@{ From = "$OuputBuildDirectory\Tetragrama\$Configurations"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"}
102+
@{ From = "$OuputBuildDirectory\Tetragrama\"; To = "$OuputBuildDirectory\Panzerfaust\$Configurations\$TargetFramework\Editor"}
107103
}
108104
Default {
109105
throw 'This system is not supported'
@@ -133,4 +129,4 @@ foreach ($item in $ContentsToProcess) {
133129
[string]$ToDirectory = $content.To
134130
Write-Host "Copied $name --> $ToDirectory"
135131
}
136-
}
132+
}

Scripts/Shared.ps1

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,6 @@ function Find-GlslangValidator () {
186186
function Find-ClangFormat () {
187187
$repoConfiguration = Get-RepositoryConfiguration
188188
$LLVMMinimumVersion = $repoConfiguration.Requirements.LLVM.Version
189-
$LLVMMaximumVersion = $repoConfiguration.Requirements.LLVM.MaximumVersion
190189

191190
$candidates = @(
192191
'clang-format'
@@ -204,17 +203,20 @@ function Find-ClangFormat () {
204203
if ($clangFormatCommand) {
205204
if ((& $clangFormatCommand --version | Out-String) -match "clang-format version ([\d\.]*)") {
206205
[Version] $clangFormatVersion = $Matches[1]
207-
if ((CompareVersion $clangFormatVersion $LLVMMinimumVersion) -and (CompareVersion $LLVMMaximumVersion $clangFormatVersion)) {
206+
if ((CompareVersion $clangFormatVersion $LLVMMinimumVersion) ) {
208207
return $clangFormatCommand.Source
209208
}
210209
}
211210
}
212211
}
213212

214-
throw "Failed to find clang-format min $LLVMMinimumVersion max $LLVMMaximumVersion. Tried: " + ($candidates -join ', ')
213+
throw "Failed to find clang-format min $LLVMMinimumVersion. Tried: " + ($candidates -join ', ')
215214
}
216215

217216
function Setup-ShaderCCompilerTool () {
217+
if($IsLinux) {
218+
return
219+
}
218220
$repoConfiguration = Get-RepositoryConfiguration
219221
$repositoryToolPath = $repoConfiguration.Paths.Tools
220222

Tetragrama/CMakeLists.txt

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,3 @@
1-
cmake_minimum_required (VERSION 3.17)
2-
3-
project (Tetragrama
4-
VERSION 1.0
5-
DESCRIPTION "Tetragrama, the ZEngine Editor"
6-
LANGUAGES CXX
7-
)
8-
9-
set (CMAKE_CXX_STANDARD_REQUIRED ON)
10-
set (CMAKE_CXX_STANDARD 20)
11-
121
file (GLOB_RECURSE HEADER_FILES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.h)
132
file (GLOB_RECURSE CPP_FILES CONFIGURE_DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp)
143

@@ -31,22 +20,9 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
3120
set_target_properties(${TARGET_NAME} PROPERTIES VS_DEBUGGER_WORKING_DIRECTORY "$(ProjectDir)$(Configuration)")
3221
endif ()
3322

34-
include(${EXTERNAL_DIR}/externals.cmake)
35-
3623
target_include_directories (${TARGET_NAME}
3724
PRIVATE
38-
.
39-
./Components
40-
./Components/Events
41-
./Controllers
42-
./Inputs
43-
./Layers
44-
./Messengers
45-
./Helpers
46-
./Importers
47-
./Serializers
48-
./Managers
49-
${ENLISTMENT_ROOT}/ZEngine
25+
${CMAKE_CURRENT_SOURCE_DIR}/..
5026
)
5127

5228
target_precompile_headers(${TARGET_NAME} PRIVATE pch.h)
@@ -62,4 +38,4 @@ target_link_libraries(${TARGET_NAME} PRIVATE
6238
imported::External_editorLibs
6339
)
6440

65-
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "zEngineEditor")
41+
set_target_properties(${TARGET_NAME} PROPERTIES OUTPUT_NAME "zEngineEditor")

Tetragrama/Components/DemoUIComponent.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#pragma once
2-
#include <UIComponent.h>
2+
#include <Tetragrama/Components/UIComponent.h>
33
#include <imgui.h>
44

55
namespace Tetragrama::Components

Tetragrama/Components/DockspaceUIComponent.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
#include <pch.h>
2-
#include <DockspaceUIComponent.h>
3-
#include <Editor.h>
4-
#include <Helpers/UIDispatcher.h>
5-
#include <Importers/AssimpImporter.h>
6-
#include <MessageToken.h>
7-
#include <Messengers/Messenger.h>
1+
#include <Tetragrama/Components/DockspaceUIComponent.h>
2+
#include <Tetragrama/Editor.h>
3+
#include <Tetragrama/Helpers/UIComponentDrawerHelper.h>
4+
#include <Tetragrama/Helpers/UIDispatcher.h>
5+
#include <Tetragrama/Importers/AssimpImporter.h>
6+
#include <Tetragrama/MessageToken.h>
7+
#include <Tetragrama/Messengers/Messenger.h>
88
#include <ZEngine/Logging/LoggerDefinition.h>
99
#include <fmt/format.h>
10-
#include <imgui/src/imgui_internal.h>
10+
#include <ImGuizmo/ImGuizmo.h>
1111

1212
namespace fs = std::filesystem;
1313

0 commit comments

Comments
 (0)