-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
139 lines (120 loc) · 3.72 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
cmake_minimum_required(VERSION 3.16)
project(VoxelEngine)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
# Export compile commands for SonarQube
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
if(WIN32)
set(CMAKE_TOOLCHAIN_FILE "$ENV{USERPROFILE}/vcpkg/scripts/buildsystems/vcpkg.cmake" CACHE STRING "")
else()
include_directories(/usr/include)
link_directories(/usr/lib)
endif()
set(OpenGL_GL_PREFERENCE GLVND)
find_package(OpenGL REQUIRED)
if (NOT OPENGL_FOUND)
message(FATAL_ERROR "OpenGL not found. Please install OpenGL package.")
endif()
find_package(glfw3 CONFIG REQUIRED)
if (NOT glfw3_FOUND)
message(FATAL_ERROR "GLFW not found. Please install GLFW3 package.")
endif()
find_package(Lua 5.4 REQUIRED)
if(NOT LUA_FOUND)
message(FATAL_ERROR "Lua >= 5.4 not found. Please install lua5.4 and lua5.4-dev packages.")
endif()
# Add GLAD
add_library(glad STATIC
external/glad/src/glad.c
)
target_include_directories(glad PUBLIC
external/glad/include
)
# Add ImGui source files
set(IMGUI_DIR external/imgui)
set(IMGUI_SOURCES
${IMGUI_DIR}/imgui.cpp
${IMGUI_DIR}/imgui_demo.cpp
${IMGUI_DIR}/imgui_draw.cpp
${IMGUI_DIR}/imgui_tables.cpp
${IMGUI_DIR}/imgui_widgets.cpp
${IMGUI_DIR}/backends/imgui_impl_glfw.cpp
${IMGUI_DIR}/backends/imgui_impl_opengl3.cpp
)
# Engine library sources
set(ENGINE_SOURCES
src/Application.cpp
src/Window/OpenGLWindow.cpp
src/Renderer/Buffer.cpp
src/Renderer/OpenGLBuffer.cpp
src/Renderer/Renderer.cpp
src/Renderer/Renderer2D.cpp
src/Shader/Shader.cpp
src/ImGui/ImGuiLayer.cpp
src/Renderer/VertexArray.cpp
src/Renderer/OpenGLVertexArray.cpp
src/Camera/PerspectiveCamera.cpp
src/Renderer/Material.cpp
src/Renderer/Texture.cpp
src/Debug/Profiler.cpp
src/Threading/ThreadPool.cpp
src/VoxelTerrain.cpp
src/Noise/VoidNoise/VoidNoise.cpp
src/Noise/PerlinNoise/PerlinNoise.cpp
src/Input/InputSystem.cpp
src/TerrainSystem/TerrainSystem.cpp
src/UI/ImGuiOverlay.cpp
src/UI/ImGuiFlameGraph.cpp
src/VoxelChunk.cpp
src/Core/FPSCounter.cpp
src/Shader/ShaderHotReload.cpp
src/Noise/SimplexNoise/SimplexNoise.cpp
src/Noise/ValueNoise/ValueNoise.cpp
external/stb_image/src/stb_image.cpp
src/Scripting/LuaScriptSystem.cpp
src/Scene/Scene.cpp
src/Shader/ShaderLibrary.cpp
src/Shader/ShaderFactory.cpp
${IMGUI_SOURCES}
)
# Create engine library
add_library(voxel-engine STATIC ${ENGINE_SOURCES})
target_include_directories(voxel-engine PUBLIC
${CMAKE_SOURCE_DIR}/src
${IMGUI_DIR}
${IMGUI_DIR}/backends
${CMAKE_SOURCE_DIR}/build/vcpkg_installed/x86-windows/include
${CMAKE_SOURCE_DIR}/external/stb_image/src
${CMAKE_SOURCE_DIR}/external/json
${CMAKE_SOURCE_DIR}/external/glad/include
${CMAKE_SOURCE_DIR}/build/vcpkg_installed/x86-windows/include
${CMAKE_SOURCE_DIR}/external/sol2
)
target_link_libraries(voxel-engine PUBLIC
glfw
OpenGL::GL
glad
${LUA_LIBRARIES} # Add Lua libraries
)
# Create sandbox executable
set(SANDBOX_SOURCES
sandbox/src/SandboxApp.cpp
)
add_executable(sandbox ${SANDBOX_SOURCES})
target_link_libraries(sandbox PRIVATE voxel-engine)
add_custom_command(TARGET sandbox POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/sandbox/assets/scripts
${CMAKE_BINARY_DIR}/assets/scripts
)
add_custom_command(TARGET sandbox POST_BUILD
COMMAND ${CMAKE_COMMAND} -E copy_directory
${CMAKE_SOURCE_DIR}/assets $<TARGET_FILE_DIR:sandbox>/assets
)
# Enable precompiled headers - specify C++ explicitly
target_precompile_headers(voxel-engine
PRIVATE
$<INSTALL_INTERFACE:pch.h>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src/pch.h>
)