-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
168 lines (149 loc) · 5.27 KB
/
Copy pathxmake.lua
File metadata and controls
168 lines (149 loc) · 5.27 KB
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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
set_project("GameEngine")
set_version("0.1.0")
add_rules("mode.debug", "mode.release")
set_languages("c++23")
add_requires("glfw 3.4", {alias = "glfw"})
add_requires("glad 0.1.36", {alias = "glad"})
add_requires("glm 0.9.9", {alias = "glm"})
add_requires("conan::spdlog/1.14.1", {alias = "spdlog", configs = {options = {"spdlog/*:use_std_fmt=True"}, settings = {"compiler.cppstd=23"}, build = "missing"}})
add_requires("conan::catch2/3.6.0", {alias = "catch2"})
add_requires("flecs", {alias = "flecs"})
add_requires("tracy", {alias = "tracy"})
add_requires("imgui", {alias = "imgui", configs = {opengl3 = true}})
add_requires("wgpu-native", {alias = "wgpu"})
add_requires("stb", {alias = "stb"})
option("enable_profiling")
set_default(true)
set_showmenu(true)
set_description("Enable Tracy profiling")
option_end()
option("use_webgpu")
set_default(true)
set_showmenu(true)
set_description("Use WebGPU instead of OpenGL")
option_end()
target("game_engine")
set_kind("static")
add_files("src/**.cpp")
add_headerfiles("include/(game_engine/**.hpp)")
add_includedirs("include", {public = true})
add_packages("glfw", "glad", "glm", "spdlog", "flecs", "imgui", "wgpu", "stb")
add_includedirs("/opt/homebrew/include", {public = true})
add_linkdirs("/opt/homebrew/lib", {public = true})
add_links("SDL3", {public = true})
add_defines("GLM_FORCE_DEPTH_ZERO_TO_ONE", {public = true})
add_defines("GLM_FORCE_LEFT_HANDED", {public = true})
if has_config("enable_profiling") then
add_packages("tracy")
add_defines("TRACY_ENABLE")
end
if has_config("use_webgpu") then
add_defines("USE_WEBGPU")
end
if has_config("enable_coverage") then
add_cxflags("-fprofile-instr-generate", "-fcoverage-mapping")
add_ldflags("-fprofile-instr-generate", "-fcoverage-mapping")
end
add_rules("plugin.cmake.autoreload")
target("triangle_example")
set_kind("binary")
add_deps("game_engine")
add_files("examples/triangle/main.cpp")
add_packages("glfw", "glad", "glm", "spdlog", "flecs", "imgui", "wgpu")
add_links("SDL3")
add_linkdirs("/opt/homebrew/lib")
add_rpathdirs("/opt/homebrew/lib")
if has_config("enable_profiling") then
add_packages("tracy")
add_defines("TRACY_ENABLE")
end
if has_config("use_webgpu") then
add_defines("USE_WEBGPU")
end
target("glass_sphere_example")
set_kind("binary")
add_deps("game_engine")
add_files("examples/glass_sphere/main.cpp")
add_packages("glfw", "glad", "glm", "spdlog", "flecs", "imgui", "wgpu", "stb")
add_links("SDL3")
add_linkdirs("/opt/homebrew/lib")
add_rpathdirs("/opt/homebrew/lib")
if has_config("enable_profiling") then
add_packages("tracy")
add_defines("TRACY_ENABLE")
end
if has_config("use_webgpu") then
add_defines("USE_WEBGPU")
end
target("playground_example")
set_kind("binary")
set_rundir("$(projectdir)")
add_deps("game_engine")
add_files("examples/playground/main.cpp")
add_packages("glfw", "glad", "glm", "spdlog", "flecs", "imgui", "wgpu", "stb")
add_links("SDL3")
add_linkdirs("/opt/homebrew/lib")
add_rpathdirs("/opt/homebrew/lib")
if has_config("enable_profiling") then
add_packages("tracy")
add_defines("TRACY_ENABLE")
end
if has_config("use_webgpu") then
add_defines("USE_WEBGPU")
end
option("enable_coverage")
set_default(false)
set_showmenu(true)
set_description("Enable code coverage")
option_end()
target("tests")
set_kind("binary")
add_deps("game_engine")
add_files("tests/**.cpp")
add_includedirs("tests", "include")
add_packages("catch2", "glfw", "glad", "glm", "spdlog", "flecs")
if has_config("enable_coverage") then
add_cxflags("-fprofile-instr-generate", "-fcoverage-mapping")
add_ldflags("-fprofile-instr-generate", "-fcoverage-mapping")
end
on_load(function (target)
local main_content = [[
#define CATCH_CONFIG_MAIN
#include <catch2/catch_all.hpp>
]]
target:add("files", target:autogenfile("tests/main.cpp", main_content))
end)
if is_mode("debug") then
add_cxflags("-Wall", "-Wextra", "-Werror", "-Wpedantic")
end
rule("plugin.cmake.autoreload")
set_kind("project")
after_build(function (_)
import("core.project.config")
import("core.project.depend")
import("core.project.project")
import("core.base.option")
local verbose = option.get("verbose")
if not os.exec("cmake --version") then
if verbose then
print("CMake not found. Skipping CMake reload.")
end
return
end
if not os.isfile("CMakeLists.txt") then
if verbose then
print("CMakeLists.txt not found. Skipping CMake reload.")
end
return
end
local dependfile = path.join(config.buildir(), ".gens", "rules", "plugin.cmake.autoreload.d")
depend.on_changed(function ()
print("Changes detected. Reloading CMakeFiles...")
local result = os.exec("cmake .")
if result == 0 then
print("CMakeFiles successfully reloaded after changes")
else
print("Error occurred while reloading CMakeFiles")
end
end, {dependfile = dependfile, files = project.allfiles()})
end)