-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathxmake.lua
More file actions
76 lines (67 loc) · 3.72 KB
/
Copy pathxmake.lua
File metadata and controls
76 lines (67 loc) · 3.72 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
-- 工程设置
set_project("vulkan-sample")
set_version("0.0.1", {build = tostring(get_config("buildversion")), soname = true})
set_xmakever("3.0.0")
option("alias", {showmenu = false, default = "vks"}) -- 工程名缩写
set_configvar("LEGAL_COPYRIGHT", "Copyright (C) 2024 SnowinterCat")
set_configvar("PROJECT_NAME", "vulkan-sample")
-- 全局设置
option("stdc", {showmenu = true, default = 23, values = {23}})
option("stdcxx", {showmenu = true, default = 23, values = {26, 23, 20}})
function stdc() return "c" .. tostring(get_config("stdc")) end
function stdcxx() return "c++" .. tostring(get_config("stdcxx")) end
set_languages(stdc(), stdcxx())
set_warnings("allextra")
set_encodings("utf-8")
set_exceptions("cxx")
-- 添加编译选项
add_rules("mode.release", "mode.debug", "mode.releasedbg", "mode.minsizerel")
add_rules("plugin.compile_commands.autoupdate", {lsp = "clangd", outputdir = ".vscode"})
-- 编译设置
option("3rd_kind", {showmenu = true, default = get_config("kind"), values = {"static", "shared"}})
option("outputdir", {showmenu = true, default = path.join(os.projectdir(), "bin"), type = "string"})
option("buildversion", {showmenu = true, default = 0, type = "number"})
option("replace", {showmenu = true, default = false, type = "boolean"}) -- export 三方库时是否强制替换
includes("lua/check")
check_macros("has_std_out_ptr", "__cpp_lib_out_ptr", {languages = stdcxx(), includes = "memory"})
check_macros("has_std_expected", "__cpp_lib_expected", {languages = stdcxx(), includes = "expected"})
check_macros("has_std_runtime_format", "__cpp_lib_format >= 202311L", {languages = stdcxx(), includes = "format"})
-- 隐藏设置、隐藏目标、打包命令
includes("lua/hideoptions.lua")
includes("lua/hidetargets.lua")
-- includes("lua/pack.lua")
-- some of the third-party use our own configurations
add_repositories("myrepo 3rd", {rootdir = os.scriptdir()})
-- header-only libraries
if not has_config("has_std_out_ptr") then
add_requires("out_ptr")
end
if not has_config("has_std_expected") then
add_requires("tl_expected")
end
add_requires("cxxopts", {version = "3.x.x"})
add_requires("vulkan-memory-allocator-hpp", {version = "3.1.0"})
add_requires("tinygltf", {version = "x.x.x"})
-- normal libraries
if not is_plat("android") then
add_requires("vulkansdk")
end
add_requires("libsdl3", {version = "3.x.x", configs = {shared = is_config("3rd_kind", "shared"), x11 = true, wayland = true}})
add_requires("imgui", {version = "1.x.x", configs = {shared = is_config("3rd_kind", "shared")}})
add_requires("spdlog", {version = "1.x.x", configs = {shared = is_config("3rd_kind", "shared"), header_only = false, fmt_external = not has_config("has_std_runtime_format"), std_format = has_config("has_std_runtime_format"), wchar = true, wchar_console = true}})
if not has_config("has_std_runtime_format") then
add_requires("fmt", {version = "11.x.x", configs = {shared = is_config("3rd_kind", "shared"), header_only = false}})
end
-- normal libraries' dependencies configurations
add_requireconfs("**.vulkan-memory-allocator", {override = true, version = "3.1.0"})
add_requireconfs("**.vulkan-headers", {override = true, version = "1.3.296"})
add_requireconfs("**.libxext", {system = true}) -- from libsdl3
add_requireconfs("**.libx11", {system = true}) -- from libsdl3
add_requireconfs("**.wayland", {system = true}) -- from libsdl3
add_requireconfs("**.fmt", {override = true, version = "11.x.x", configs = {shared = is_config("3rd_kind", "shared"), header_only = false}})
add_requireconfs("**.nlohmann_json", {override = true, version = "3.x.x"})
add_requireconfs("**.stb", {override = true, version = "x.x.x"})
-- subdirectories
includes("src/*/xmake.lua")
includes("exec/*/xmake.lua")
includes("test/*/xmake.lua")