-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathproject_qt.lua
More file actions
111 lines (85 loc) · 2.95 KB
/
project_qt.lua
File metadata and controls
111 lines (85 loc) · 2.95 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
--
-- Zidar - Build system scripts
-- Copyright (c) 2025-2026 Milos Tosic, Rudji Games. All rights reserved.
-- License: https://github.com/RudjiGames/zidar/blob/master/LICENSE
--
local g_qtProjectFilesCache = {}
local g_qtHeaderUsesQObjectCache = {}
local function qtHeaderUsesQObject(_file)
local cached = g_qtHeaderUsesQObjectCache[_file]
if cached ~= nil then
return cached
end
local headerSrc = fileRead(_file)
cached = headerSrc:find("Q_OBJECT", 1, true) ~= nil
g_qtHeaderUsesQObjectCache[_file] = cached
return cached
end
local function getQtProjectFiles(_projectPath)
local cached = g_qtProjectFilesCache[_projectPath]
if cached ~= nil then
return cached.mocFiles, cached.uiFiles, cached.qrcFiles, cached.tsFiles
end
local headers = mergeTables(os.matchfiles(_projectPath .. "/inc/**.h"), os.matchfiles(_projectPath .. "/src/**.h"))
local uiFiles = os.matchfiles(_projectPath .. "/src/**.ui")
local qrcFiles = os.matchfiles(_projectPath .. "/src/**.qrc")
local tsFiles = os.matchfiles(_projectPath .. "/src/**.ts")
local mocFiles = {}
for _, header in ipairs(headers) do
if qtHeaderUsesQObject(header) then
table.insert(mocFiles, header)
end
end
g_qtProjectFilesCache[_projectPath] = {
mocFiles = mocFiles,
uiFiles = uiFiles,
qrcFiles = qrcFiles,
tsFiles = tsFiles,
}
return mocFiles, uiFiles, qrcFiles, tsFiles
end
function addProject_qt(_name, _libraryType, _includes, _prebuildcmds, _extraQtModules)
if _libraryType ~= nil then
group ( vpathStringFromLibraryType(_libraryType) )
else
group ( "tools" )
end
project ( _name )
project().kind = "WindowedApp"
if _libraryType == LibraryType.Tool then
project().kind = "StaticLib"
end
language "C++"
kind ( project().kind )
uuid ( os.uuid(project().name) )
flags { Flags_QtTool }
local projectPath = projectGetPath(project().name)
local sourceFiles = projectSourceFilesWildcard( projectPath )
local libsToLink = mergeTables({ "Core", "Gui", "Widgets", "Network"}, _extraQtModules)
sourceFiles = mergeTables(sourceFiles, { projectPath .. "/src/**.ui" },
{ projectPath .. "/src/**.qrc" },
{ projectPath .. "/src/**.ts" } )
if getTargetOS() == "windows" then
sourceFiles = mergeTables( sourceFiles, { projectPath .. "/src/**.rc" })
end
files { sourceFiles }
local mocFiles, uiFiles, qrcFiles, tsFiles = getQtProjectFiles(projectPath)
addPCH( projectPath .. "/src/", project().name )
configuration {} -- should remove ?
_includes = _includes or {}
includedirs {
path.getdirectory(projectGetScriptPath(project().name)),
projectPath .. "/src",
_includes
}
if os.is("linux") then
buildoptions { "-fPIC" }
end
_prebuildcmds = _prebuildcmds or {}
for _,cmd in ipairs( _prebuildcmds ) do
prebuildcommands { cmd }
end
-- true = isQtProject, adds extra defines and flags for qt projects
projectConfig(true, mocFiles, uiFiles, qrcFiles, tsFiles, libsToLink)
addDependencies(project().name)
end