-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpremake5.lua
145 lines (111 loc) · 3.75 KB
/
premake5.lua
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
require 'submodules/premake-qt/qt'
newoption {
trigger = "qt-root",
value = "path",
description = "Path of qt root (contains lib/libQt5Core.a include/Qt5Core bin)",
category = "script"
}
newoption {
trigger = "qt-version",
value = "version",
description = "Version of Qt",
default = "5.15.0",
category = "script"
}
local qt = premake.extensions.qt
if _OPTIONS["qt-root"] ~= nil then
QtRoot = _OPTIONS["qt-root"]
end
print("Environment variable Qt5_Dir:", os.getenv("Qt5_Dir"))
print("Environment variable Qt6_Dir:", os.getenv("Qt6_Dir"))
print("Environment variable QT_ROOT_DIR:", os.getenv("QT_ROOT_DIR"))
print("Environment variable QTDIR:", os.getenv("QTDIR"))
print("Environment variable QT_DIR:", os.getenv("QT_DIR"))
print("QtRoot: ", QtRoot)
workspace "qt-json-editor"
location "solution/%{_ACTION}"
configurations { "Debug", "Release" }
platforms { "x32", "x64" }
cppdialect "C++17"
warnings "Extra"
externalanglebrackets "On"
externalwarnings "Off"
objdir "obj/%{_ACTION}" -- premake adds $(platformName)/$(configName)/$(AppName)
targetdir "bin/%{_ACTION}/%{cfg.platform}/%{cfg.buildcfg}"
qt.enable(string.sub(_OPTIONS["qt-version"], 1, 1))
qtuseexternalinclude ( true )
if (QtRoot ~= nil and QtRoot ~= "") then
qtpath(QtRoot)
end
qtversion ( _OPTIONS["qt-version"] )
if premake.checkVersion(_OPTIONS["qt-version"], '>=6.0 <6.1') and os.target() ~= premake.WINDOWS then
forceincludes "src/Qt6_0_workaround.h"
end
filter "platforms:x32"
architecture "x32"
filter "platforms:x64"
architecture "x64"
filter "configurations:Debug"
optimize "Off"
symbols "On"
defines "DEBUG"
qtsuffix "d"
filter "configurations:Release"
optimize "On"
symbols "Off"
defines { "NDEBUG", "QT_NO_DEBUG" }
filter "toolset:gcc"
buildoptions {"-Wno-unused-parameter"}
filter "toolset:clang"
buildoptions {"-Wno-unused-parameter"}
defines {"__STDC_LIMIT_MACROS", "__STDC_CONSTANT_MACROS"}
filter "system:windows"
defines "WIN32"
filter "toolset:not msc*"
pic "On" -- position independent code required when Qt was built with -reduce-relocations
filter {}
startproject "qt-json-editor"
project "qt-json-editor"
kind "WindowedApp"
files { "src/QtJsonEditor/**.*" }
includedirs "src"
qtmodules { "core", "gui", "widgets" }
qtmain(true)
links { "qt-json-editor-dialog", "qt-json-widget" }
filter { "system:windows" }
postbuildcommands { '"%{cfg.qtpath}/bin/windeployqt.exe" "%{cfg.buildtarget.abspath}"' }
filter {}
project "qt-json-editor-dialog"
kind "StaticLib"
files { "src/QtJsonEditorDialog/**.*" }
files { "ts/*.ts" }
qtlreleaseargs { "-nounfinished" }
qtqmgenerateddir "%{cfg.targetdir}"
qtmodules { "core", "gui", "widgets" }
if _ACTION == "gmake" or _ACTION == "gmake2" or _ACTION == "codeblocks" then
-- qrelease doesn't create intermediate directory
-- and those actions don't create sub-directories neither for custombuild
-- So do it as pre-build step
prebuildcommands { "{MKDIR} %{cfg.qtqmgenerateddir}" }
end
includedirs "src"
includedirs "submodules/valijson/include"
filter {"files:ts/*_en.ts"}
qtlreleaseargs { "-removeidentical" }
filter {}
project "qt-json-widget"
kind "StaticLib"
files { "src/QtJsonWidget/**.*" }
includedirs "src"
includedirs "submodules/valijson/include"
qtmodules { "core", "gui", "widgets" }
project "qt-json-designer-plugin"
kind "SharedLib"
files { "src/QtDesignerPlugin/**.*" }
includedirs "src"
qtmodules { "core", "gui", "widgets" }
links "qt-json-widget"
qtmocargs { "-I%{cfg.qtincludepath}" }
filter { "configurations:release" }
targetdir "%{cfg.qtpath}/plugins/designer"
filter {}