解决qmake重复执行的问题

每次我们执行qmake时候都会很慢,是因为CONFIG存在重复的属性导致qmake重复执行。

  由于项目文件在添加时候系统会自动加入debug,release,debug_and_release变量,导致qmake遇到这些变量会再执行一次qmake,有打印函数message也会重复输出。这就导致qmake变得很慢。解决方法是:移除CONFIG内多余的的变量

  qmake函数remove_extra_config_parameter主要作用是移除重复的debug,Debug,release,Release,debug_and_release属性,仅会保留最后出现的属性。这样就避免了多次重复qmake的问题。

defineReplace(remove_extra_config_parameter) {
    configs = $$1
    debug_and_release_params = # 匹配预选队列
    keys = debug Debug release Release debug_and_release
    for (iter, configs) {
        contains(keys, $$iter) {
            debug_and_release_params += $$iter
        }
    }

    for (iter, debug_and_release_params) {
        configs -= $$iter # 移除预选队列的属性
    }

    configs += $$last(debug_and_release_params) # 添加(保留)预选队列的最后属性

    return($$configs)
}

# 使用
CONFIG = $$remove_extra_config_parameter($$CONFIG)
发布了354 篇原创文章 · 获赞 80 · 访问量 15万+

猜你喜欢

转载自blog.csdn.net/nicai_xiaoqinxi/article/details/103729119
今日推荐