diff options
| author | ruki <[email protected]> | 2018-04-14 23:19:18 +0800 |
|---|---|---|
| committer | ruki <[email protected]> | 2018-04-14 23:19:18 +0800 |
| commit | c2534e6c6bee1c54e0dbd7f54d06444d1835c69c (patch) | |
| tree | ee6de4055a7f510bdf1c92e9736cdf4a8c82df9f | |
| parent | 79c1eb71af25e810d421a790b5e9eab463450cfe (diff) | |
impl find_qt
| -rw-r--r-- | xmake/modules/detect/sdks/find_qt.lua | 25 | ||||
| -rw-r--r-- | xmake/rules/qt/console/load.lua | 79 | ||||
| -rw-r--r-- | xmake/rules/qt/console/xmake.lua | 24 |
3 files changed, 101 insertions, 27 deletions
diff --git a/xmake/modules/detect/sdks/find_qt.lua b/xmake/modules/detect/sdks/find_qt.lua index 73f037315..0eb856994 100644 --- a/xmake/modules/detect/sdks/find_qt.lua +++ b/xmake/modules/detect/sdks/find_qt.lua @@ -31,12 +31,17 @@ function _find_sdkdir() -- init the search directories local pathes = {} if os.host() == "macosx" then - table.insert(pathes, "~/Qt") + table.insert(pathes, "~/Qt/**/bin") elseif os.host() == "windows" then else - table.insert(pathes, "~/Qt") + table.insert(pathes, "~/Qt/**/bin") end + -- attempt to find qmake + local qmake = find_file(os.host() == "windows" and "qmake.exe" or "qmake", pathes) + if qmake then + return path.directory(path.directory(qmake)) + end end -- find qt sdk toolchains @@ -48,7 +53,7 @@ end -- -- @code -- --- local toolchains = find_qt("/Developer/NVIDIA/qt-9.1") +-- local toolchains = find_qt("~/Qt/5.10.1/clang_64") -- -- @endcode -- @@ -67,6 +72,18 @@ function main(sdkdir, opt) return nil end + -- get the bin directory + local bindir = path.join(sdkdir, "bin") + if not os.isexec(path.join(bindir, "qmake")) then + return nil + end + + -- get linkdirs + local linkdirs = {path.join(sdkdir, "lib")} + + -- get includedirs + local includedirs = {path.join(sdkdir, "include")} + -- get toolchains - return {} + return {sdkdir = sdkdir, bindir = bindir, linkdirs = linkdirs, includedirs = includedirs} end diff --git a/xmake/rules/qt/console/load.lua b/xmake/rules/qt/console/load.lua new file mode 100644 index 000000000..d93f5e425 --- /dev/null +++ b/xmake/rules/qt/console/load.lua @@ -0,0 +1,79 @@ +--!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") + +-- check the qt sdk directory +function check_qt() + + -- get the qt sdk + local qt_sdkdir = config.get("qt_sdkdir") + if not qt_sdkdir then + + -- check ok? update it + local qt = find_qt() + if qt then + + -- save it + config.set("qt_sdkdir", qt.sdkdir) + + -- trace + cprint("checking for the Qt SDK directory ... ${green}%s", qt.sdkdir) + else + + -- trace + cprint("checking for the Qt SDK directory ... ${red}no") + end + end +end + +-- the main entry +function main(target) + + -- check qt sdk + check_qt() + + -- set kind: binary + target:set("kind", "binary") + + -- add defines for using core lib + target:add("defines", "QT_CORE_LIB") + + -- 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") +end diff --git a/xmake/rules/qt/console/xmake.lua b/xmake/rules/qt/console/xmake.lua index 2c315abf0..0b3149222 100644 --- a/xmake/rules/qt/console/xmake.lua +++ b/xmake/rules/qt/console/xmake.lua @@ -26,27 +26,5 @@ rule("qt:console") -- on load - on_load(function (target) - - -- set kind: binary - target:set("kind", "binary") - - -- add defines for using core lib - target:add("defines", "QT_CORE_LIB") - - -- 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") - end) + on_load("load") |
