summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-04-15 22:03:22 +0800
committerruki <[email protected]>2018-04-15 22:03:22 +0800
commit6c4f65481bb0df23d34d9e0815ca642804dbb412 (patch)
tree4d6ad11349d71e06a5e0876a329ff7e6069dcaac
parent4dab3917696d31139166ada278a9b4e4f4e9e4e6 (diff)
add qt static library
-rw-r--r--tests/projects/qt_static_library/src/demo.cpp5
-rw-r--r--tests/projects/qt_static_library/src/demo.h11
-rw-r--r--tests/projects/qt_static_library/xmake.lua13
-rw-r--r--xmake/modules/detect/sdks/find_qt.lua5
-rw-r--r--xmake/rules/qt/static/load.lua66
-rw-r--r--xmake/rules/qt/static/xmake.lua30
6 files changed, 129 insertions, 1 deletions
diff --git a/tests/projects/qt_static_library/src/demo.cpp b/tests/projects/qt_static_library/src/demo.cpp
new file mode 100644
index 000000000..a702ad253
--- /dev/null
+++ b/tests/projects/qt_static_library/src/demo.cpp
@@ -0,0 +1,5 @@
+#include "demo.h"
+
+QtDemo::QtDemo()
+{
+}
diff --git a/tests/projects/qt_static_library/src/demo.h b/tests/projects/qt_static_library/src/demo.h
new file mode 100644
index 000000000..51eb9be55
--- /dev/null
+++ b/tests/projects/qt_static_library/src/demo.h
@@ -0,0 +1,11 @@
+#ifndef QT_DEMO_H
+#define QT_DEMO_H
+
+class QtDemo
+{
+
+public:
+ QtDemo();
+};
+
+#endif // QT_DEMO_H
diff --git a/tests/projects/qt_static_library/xmake.lua b/tests/projects/qt_static_library/xmake.lua
new file mode 100644
index 000000000..e3d27c18a
--- /dev/null
+++ b/tests/projects/qt_static_library/xmake.lua
@@ -0,0 +1,13 @@
+
+-- add modes: debug and release
+add_rules("mode:debug", "mode:release")
+
+-- add target
+target("qt_demo")
+
+ -- add rules
+ add_rules("qt:static")
+
+ -- add files
+ add_files("src/*.cpp")
+
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua
index 6fb7d4b14..0ef499544 100644
--- a/xmake/modules/detect/sdks/find_qt.lua
+++ b/xmake/modules/detect/sdks/find_qt.lua
@@ -33,7 +33,10 @@ import("core.project.config")
function _find_sdkdir(sdkdir)
-- init the search directories
- local pathes = {path.join(sdkdir, "**", "bin")}
+ local pathes = {}
+ if sdkdir then
+ table.insert(pathes, path.join(sdkdir, "**", "bin"))
+ end
if os.host() == "macosx" then
table.insert(pathes, "~/Qt/**/bin")
elseif os.host() == "windows" then
diff --git a/xmake/rules/qt/static/load.lua b/xmake/rules/qt/static/load.lua
new file mode 100644
index 000000000..0d1ca8d54
--- /dev/null
+++ b/xmake/rules/qt/static/load.lua
@@ -0,0 +1,66 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file load.lua
+--
+
+-- imports
+import("core.project.config")
+import("detect.sdks.find_qt")
+
+-- the main entry
+function main(target)
+
+ -- check qt sdk
+ local qt = assert(find_qt(nil, {verbose = true}), "Qt SDK not found!")
+
+ -- set kind: static
+ target:set("kind", "static")
+
+ -- add defines for using gui and core libs
+ target:add("defines", "QT_GUI_LIB", "QT_CORE_LIB")
+
+ -- need c++11
+ target:set("languages", "cxx11")
+
+ -- add defines for the compile mode
+ if is_mode("debug") then
+ target:add("defines", "QT_QML_DEBUG")
+ elseif is_mode("release") then
+ target:add("defines", "QT_NO_DEBUG")
+ elseif is_mode("profile") then
+ target:add("defines", "QT_QML_DEBUG", "QT_NO_DEBUG")
+ end
+
+ -- The following define makes your compiler emit warnings if you use
+ -- any feature of Qt which as been marked deprecated (the exact warnings
+ -- depend on your compiler). Please consult the documentation of the
+ -- deprecated API in order to know how to port your code away from it.
+ target:add("defines", "QT_DEPRECATED_WARNINGS")
+
+ -- add frameworks
+ if is_plat("macosx") then
+ target:add("frameworkdirs", qt.linkdirs)
+ target:add("frameworks", "OpenGL", "AGL")
+ target:add("includedirs", path.join(qt.sdkdir, "lib/QtGui.framework/Headers"))
+ target:add("includedirs", path.join(qt.sdkdir, "lib/QtCore.framework/Headers"))
+ end
+end
diff --git a/xmake/rules/qt/static/xmake.lua b/xmake/rules/qt/static/xmake.lua
new file mode 100644
index 000000000..0d88967ce
--- /dev/null
+++ b/xmake/rules/qt/static/xmake.lua
@@ -0,0 +1,30 @@
+--!A cross-platform build utility based on Lua
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements. See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership. The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License. You may obtain a copy of the License at
+--
+-- http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing, software
+-- distributed under the License is distributed on an "AS IS" BASIS,
+-- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+-- See the License for the specific language governing permissions and
+-- limitations under the License.
+--
+-- Copyright (C) 2015 - 2018, TBOOX Open Source Group.
+--
+-- @author ruki
+-- @file xmake.lua
+--
+
+-- define rule
+rule("qt:static")
+
+ -- on load
+ on_load("load")
+