summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorruki <[email protected]>2018-04-15 22:26:41 +0800
committerruki <[email protected]>2018-04-15 22:26:41 +0800
commitacee17158d13b1779d9be23b42e8ce2e72e60746 (patch)
treeaacb3fa92be00429582d0868423b45142b39157e
parent60c09804728f333500a353610b100a3b59632646 (diff)
add qt shared library
-rw-r--r--tests/projects/qt_shared_library/src/demo.cpp6
-rw-r--r--tests/projects/qt_shared_library/src/demo.h13
-rw-r--r--tests/projects/qt_shared_library/src/demo_global.h12
-rw-r--r--tests/projects/qt_shared_library/xmake.lua19
-rw-r--r--tests/projects/qt_static_library/xmake.lua3
-rw-r--r--xmake/rules/qt/shared/load.lua66
-rw-r--r--xmake/rules/qt/shared/xmake.lua30
7 files changed, 149 insertions, 0 deletions
diff --git a/tests/projects/qt_shared_library/src/demo.cpp b/tests/projects/qt_shared_library/src/demo.cpp
new file mode 100644
index 000000000..bd791c271
--- /dev/null
+++ b/tests/projects/qt_shared_library/src/demo.cpp
@@ -0,0 +1,6 @@
+#include "demo.h"
+
+
+QtDemo::QtDemo()
+{
+}
diff --git a/tests/projects/qt_shared_library/src/demo.h b/tests/projects/qt_shared_library/src/demo.h
new file mode 100644
index 000000000..d88dc29ee
--- /dev/null
+++ b/tests/projects/qt_shared_library/src/demo.h
@@ -0,0 +1,13 @@
+#ifndef QT_DEMO_H
+#define QT_DEMO_H
+
+#include "demo_global.h"
+
+class QT_DEMOSHARED_EXPORT QtDemo
+{
+
+public:
+ QtDemo();
+};
+
+#endif // QT_TEST5_H
diff --git a/tests/projects/qt_shared_library/src/demo_global.h b/tests/projects/qt_shared_library/src/demo_global.h
new file mode 100644
index 000000000..25abfb05c
--- /dev/null
+++ b/tests/projects/qt_shared_library/src/demo_global.h
@@ -0,0 +1,12 @@
+#ifndef QT_DEMO_GLOBAL_H
+#define QT_DEMO_GLOBAL_H
+
+#include <QtCore/qglobal.h>
+
+#if defined(QT_DEMO_LIBRARY)
+# define QT_DEMOSHARED_EXPORT Q_DECL_EXPORT
+#else
+# define QT_DEMOSHARED_EXPORT Q_DECL_IMPORT
+#endif
+
+#endif // QT_TEST5_GLOBAL_H
diff --git a/tests/projects/qt_shared_library/xmake.lua b/tests/projects/qt_shared_library/xmake.lua
new file mode 100644
index 000000000..f858b266c
--- /dev/null
+++ b/tests/projects/qt_shared_library/xmake.lua
@@ -0,0 +1,19 @@
+
+-- add modes: debug and release
+add_rules("mode:debug", "mode:release")
+
+-- add target
+target("qt_demo")
+
+ -- add rules
+ add_rules("qt:shared")
+
+ -- add headers
+ add_headers("src/*.h")
+
+ -- add files
+ add_files("src/*.cpp")
+
+ -- add defines
+ add_defines("QT_DEMO_LIBRARY")
+
diff --git a/tests/projects/qt_static_library/xmake.lua b/tests/projects/qt_static_library/xmake.lua
index e3d27c18a..e69538015 100644
--- a/tests/projects/qt_static_library/xmake.lua
+++ b/tests/projects/qt_static_library/xmake.lua
@@ -8,6 +8,9 @@ target("qt_demo")
-- add rules
add_rules("qt:static")
+ -- add headers
+ add_headers("src/*.h")
+
-- add files
add_files("src/*.cpp")
diff --git a/xmake/rules/qt/shared/load.lua b/xmake/rules/qt/shared/load.lua
new file mode 100644
index 000000000..821c4b981
--- /dev/null
+++ b/xmake/rules/qt/shared/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: shared
+ target:set("kind", "shared")
+
+ -- 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", "QtCore", "DiskArbitration", "IOKit")
+ target:add("includedirs", path.join(qt.sdkdir, "lib/QtCore.framework/Headers"))
+ target:add("rpathdirs", "@executable_path/Frameworks", qt.linkdirs)
+ end
+end
diff --git a/xmake/rules/qt/shared/xmake.lua b/xmake/rules/qt/shared/xmake.lua
new file mode 100644
index 000000000..7dbbe5913
--- /dev/null
+++ b/xmake/rules/qt/shared/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:shared")
+
+ -- on load
+ on_load("load")
+