Improve Qt packages

This commit is contained in:
Jérôme Leclercq 2021-08-27 13:04:28 +02:00
parent 39d8cc4933
commit 3653e9136d
5 changed files with 43 additions and 26 deletions

View File

@ -23,7 +23,7 @@ rule("qt5.moc")
set_extensions(".h", ".hpp")
before_buildcmd_file(function (target, batchcmds, sourcefile, opt)
local qtbase = target:dep("qt5core")
local qt = assert(qtbase:data("qtdir"), "qt not found!")
local qt = assert(qtbase:fetch().qtbase, "qt not found!")
-- imports
import("core.tool.compiler")
@ -96,7 +96,9 @@ target("NazaraShaderNodes")
add_deps("NazaraShader")
add_packages("nodeeditor")
add_packages("qt5core", "qt5gui", "qt5widgets")
add_cxflags("-fPIC")
if not is_plat("windows") then
add_cxflags("-fPIC")
end
add_includedirs("../src")
add_headerfiles("../src/ShaderNode/**.hpp", "../src/ShaderNode/**.inl")

View File

@ -13,21 +13,18 @@ package("qt5base")
on_fetch(function (package, opt)
local qt = package:data("qtdir")
if qt then
return {
qtdir = qt
}
return qt
end
if os.isfile(package:manifest_file()) then
local qt = package:installdir()
package:data_set("qtdir", {
bindir = path.join(qt, "bin"),
includedir = path.join(qt, "include"),
libdir = path.join(qt, "lib")
})
return {
qtdir = qt
local installdir = package:installdir()
local qt = {
bindir = path.join(installdir, "bin"),
includedir = path.join(installdir, "include"),
libdir = path.join(installdir, "lib")
}
package:data_set("qtdir", qt)
return qt
end
if not opt.system then
@ -41,10 +38,7 @@ package("qt5base")
end
package:data_set("qtdir", qt)
return {
version = qt.sdkver,
qtdir = qt,
}
return qt
end)
on_install("windows", "linux", "macosx", "mingw", "android", "iphoneos", function (package)

View File

@ -10,16 +10,16 @@ package("qt5core")
on_fetch(function (package)
local base = package:dep("qt5base")
local qt = base:data("qtdir")
local qt = base:fetch()
if not qt then
return
end
return {
qtdir = qt,
includedirs = {qt.includedir, path.join(qt.includedir, "QtCore")},
links = table.wrap("Qt5Core" .. (package:is_plat("windows") and package:is_debug() and "d" or "")),
linkdirs = table.wrap(qt.libdir),
includedirs = table.wrap(qt.includedir)
linkdirs = table.wrap(qt.libdir)
}
end)
@ -30,5 +30,10 @@ package("qt5core")
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
int test(int argc, char** argv) {
QCoreApplication app (argc, argv);
return app.exec();
}
]]}, {configs = {languages = "c++14", cxflags = not package:is_plat("windows") and "-fPIC" or nil}, includes = {"QCoreApplication"}}))
end)

View File

@ -10,23 +10,29 @@ package("qt5gui")
on_fetch(function (package)
local base = package:dep("qt5base")
local qt = base:data("qtdir")
local qt = base:fetch()
if not qt then
return
end
return {
includedirs = {qt.includedir, path.join(qt.includedir, "QtGui")},
links = table.wrap("Qt5Gui" .. (package:is_plat("windows") and package:is_debug() and "d" or "")),
linkdirs = table.wrap(qt.libdir),
includedirs = table.wrap(qt.includedir)
}
end)
on_install(function (package)
local base = package:dep("qt5base")
local qt = base:data("qtdir")
local qt = base:fetch()
assert(qt, "qt5base is required")
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
int test(int argc, char** argv) {
QGuiApplication app (argc, argv);
return app.exec();
}
]]}, {configs = {languages = "c++14", cxflags = not package:is_plat("windows") and "-fPIC" or nil}, includes = {"QGuiApplication"}}))
end)

View File

@ -16,9 +16,9 @@ package("qt5widgets")
end
return {
includedirs = {qt.includedir, path.join(qt.includedir, "QtWidgets")},
links = table.wrap("Qt5Widgets" .. (package:is_plat("windows") and package:is_debug() and "d" or "")),
linkdirs = table.wrap(qt.libdir),
includedirs = table.wrap(qt.includedir)
linkdirs = table.wrap(qt.libdir)
}
end)
@ -29,4 +29,14 @@ package("qt5widgets")
end)
on_test(function (package)
assert(package:check_cxxsnippets({test = [[
int test(int argc, char** argv) {
QApplication app (argc, argv);
QPushButton button ("Hello world !");
button.show();
return app.exec();
}
]]}, {configs = {languages = "c++14", cxflags = not package:is_plat("windows") and "-fPIC" or nil}, includes = {"QApplication", "QPushButton"}}))
end)