当前位置: 首页 > 工具软件 > Qmake > 使用案例 >

qmake 脚本 常用变量

江志业
2023-12-01
qmake的常用变量主要解说查看帮助手册Qt 5.12->qmake Manual->Variables
参考:qmake 与 配置文件_丘上人的博客-CSDN博客 

E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::loadSpec()
单独解析.qmake.super,.qmake.conf,.qmake.cache,获取其中的XQMAKESPEC、QMAKESPEC、QMAKEPATH、QMAKEFEATURES这四个变量的值如果存在的话。解析后上下文立即消失,且对后续没有其他影响。
QMAKESPEC ,qmake采用的架构,根据配置qtcreator时所设置的编译器版本进行识别的
XQMAKESPEC ,目标架构
QMAKEPATH ,qmake 的绝对路径
QMAKEFEATURES ,qmake fetures的绝对路径,QtInstallDir\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\features
_QMAKE_SUPER_CACHE_ , .qmake.super的绝对路径
_QMAKE_CONF_ , .qmake.conf的绝对路径
_QMAKE_CACHE_ ,.qmake.cache的绝对路径
_QMAKE_STASH_ , .qmake.stash的绝对路径

E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::loadDefaults()
下面是qmake内置的变量,存放在evaluator的m_option中,
DIR_SEPARATOR  default value in windows \\  default value in linux /
DIRLIST_SEPARATOR default value in windows ;  default value in linux :
_DATE_ 初始化值QDateTime::currentDateTime().toString()
QMAKE_QMAKE  初始化值qmake.exe绝对路径
QMAKE_ARGS  初始化值qmake 传入参数(工程构建步骤中qmake之后的参数)
QMAKE_QTCONF 通过-qtconf参数指定的文件
下面是解析之前通过C++代码初始化的变量
QMAKE_HOST.cpu_count,qmake运行主机的cpu数量
QMAKE_HOST.os  ,qmake运行主机的操作系统名字,可选值有windows,linux
QMAKE_HOST.name ,qmake运行主机名字
QMAKE_HOST.version ,qmake运行主机的操作系统内核版本
QMAKE_HOST.version_string ,qmake运行主机的操作系统产品版本
QMAKE_HOST.arch  ,qmake运行主机的架构,可选值有x86_64,x86,IA64,Unknown
QMAKE_TARGET.arch ,目标架构(5.12.0只对windows有效)x86,x86_64(对于windows下配置vs编译器的qt,qmake会根据path中vs的bin下的架构名字进行解析)


E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::evaluateFile()
QMAKE_INTERNAL_INCLUDED_FILES   解析pro文件时背后所用到的配置文件列表,包括conf文件、prf文件、pri文件、prl文件等等脚本文件

E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::evaluateFeatureFile()
QMAKE_INTERNAL_INCLUDED_FEATURES  ,解析pro文件时,背后所用到的features文件(.prf文件)


E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::visitProFile()
PWD :当前路径

E:\workspace\QtWork\qmake\library\qmakeglobals.cpp:void QMakeGlobals::commitCommandLineArguments(),初始化参数的时候会用到
QMAKE_EXTRA_ARGS   


E:\workspace\QtWork\qmake\library\qmakeevaluator.cpp:QMakeEvaluator::setupProject()
TARGET     testEmpty
_PRO_FILE_  E:/workspace/QtWork/testEmpty/testEmpty.pro
_PRO_FILE_PWD_   E:/workspace/QtWork/testEmpty
OUT_PWD  E:/workspace/QtWork/build-testEmpty-Desktop_Qt_5_12_0_MSVC2015_64bit

CONFIG = file_copies qmake_use qt warn_on release link_prl
QT = core gui

BuildsMetaMakefileGenerator::processBuild(const ProString &build)
BUILD_PASS  =[debug|release]
BUILD_NAME =[debug|release]


MetaMakefileGenerator::createMakefileGenerator(QMakeProject *proj, bool noIO)
MAKEFILE_GENERATOR =[UNIX|MINGW|PROJECTBUILDER|XCODE|MSVC.NET|MSBUILD]

Win32MakefileGenerator::findLibraries(bool linkPrl, bool mergeLflags)
QMAKE_LIB_EXTENSIONS
QMAKE_EXTENSION_STATICLIB
LIBS
LIBS_PRIVATE
QMAKE_LIBS
QMAKE_LIBS_PRIVATE
QMAKE_CURRENT_PRL_LIBS
"QMAKE_" + lib.toUpper() + "_VERSION_OVERRIDE"

MakefileGenerator::processPrlFileCore(QString &origFile, const QStringRef &origName,const QString &fixedFile)
QMAKE_CURRENT_PRL_LIBS
QMAKE_PRL_LIBS
PRL_EXPORT_DEFINES
QMAKE_PRL_DEFINES

prls
QMAKE_PRO_INPUT
QMAKE_PRL_TARGET
QMAKE_PRL_CONFIG
QMAKE_PRL_VERSION


Win32MakefileGenerator::processVars()
PRL_TARGET
QMAKE_ORIG_TARGET
QMAKE_PROJECT_NAME
MAKEFILE
QMAKE_INCDIR
QMAKE_LIBDIR
QMAKE_INCDIR_POST
QMAKE_LIBDIR_POST
VERSION
VER_MAJ
VER_MIN
TARGET_VERSION_EXT
#D:/Qt/Qt5.12.0/5.12.0/msvc2015_64/mkspecs/features/spec_pre.prf:
QMAKE_DIR_SEP           = $$DIR_SEPARATOR
QMAKE_DIRLIST_SEP       = $$DIRLIST_SEPARATOR
QMAKE_EXT_C             = .c
QMAKE_EXT_CPP           = .cpp .cc .cxx
QMAKE_EXT_OBJC          = .m
QMAKE_EXT_OBJCXX        = .mm
QMAKE_EXT_CPP_MOC       = .moc
QMAKE_EXT_H             = .h .hpp .hh .hxx
QMAKE_EXT_H_MOC         = .cpp
QMAKE_EXT_JS            = .js
QMAKE_EXT_LEX           = .l
QMAKE_EXT_LIBTOOL       = .la
QMAKE_EXT_PKGCONFIG     = .pc
QMAKE_EXT_PRL           = .prl
QMAKE_EXT_UI            = .ui
QMAKE_EXT_YACC          = .y
QMAKE_CPP_MOD_MOC       =
QMAKE_H_MOD_MOC         = moc_
QMAKE_MOD_LEX           = _lex
QMAKE_MOD_YACC          = _yacc
QMAKE_PATH_ENV  = $$(PATH)
QMAKE_EXT_OBJ 
QMAKE_EXT_RES
QMAKE_SH
equals(QMAKE_HOST.os, Windows) {
    QMAKE_EXT_OBJ       = .obj
    QMAKE_EXT_RES       = .res
    QMAKE_SH            =
    ensurePathEnv()
    for(dir, QMAKE_PATH_ENV) {
        exists($$dir/sh.exe) {
            QMAKE_SH = $$dir/sh.exe
            break()
        }
    }
} else {
    QMAKE_EXT_CPP      += .C
    QMAKE_EXT_H        += .H
    QMAKE_EXT_OBJ       = .o
    QMAKE_SH            = sh
}
D:\Qt\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\win32-msvc\qmake.conf
include(../common/msvc-desktop.conf)
QMAKE_CFLAGS           +=
QMAKE_CXXFLAGS         +=
load(qt_config)
#D:\Qt\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\common\msvc-desktop.conf
MAKEFILE_GENERATOR      = MSVC.NET
QMAKE_PLATFORM          = win32
QMAKE_COMPILER          = msvc
CONFIG                 += flat debug_and_release debug_and_release_target precompile_header autogen_precompile_source embed_manifest_dll embed_manifest_exe
# MSVC 2017 15.8+ fixed std::aligned_storage but compilation fails without
# _ENABLE_EXTENDED_ALIGNED_STORAGE flag since the fix breaks binary compatibility.
DEFINES                += UNICODE _UNICODE WIN32 _ENABLE_EXTENDED_ALIGNED_STORAGE
QMAKE_COMPILER_DEFINES += _WIN32
contains(QMAKE_TARGET.arch, x86_64) {
    DEFINES += WIN64
    QMAKE_COMPILER_DEFINES += _WIN64
}

QMAKE_CFLAGS_OPTIMIZE_DEBUG = -Od
QMAKE_CFLAGS_OPTIMIZE      = -O2
QMAKE_CFLAGS_OPTIMIZE_SIZE = -O1

QMAKE_CC                = cl
QMAKE_LEX               = flex
QMAKE_LEXFLAGS          =
QMAKE_YACC              = bison -y
QMAKE_YACCFLAGS         = -d
QMAKE_CFLAGS            = -nologo -Zc:wchar_t
QMAKE_CFLAGS_WARN_ON    = -W3
QMAKE_CFLAGS_WARN_OFF   = -W0
QMAKE_CFLAGS_RELEASE    = $$QMAKE_CFLAGS_OPTIMIZE -MD
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MD
QMAKE_CFLAGS_DEBUG      = -Zi -MDd
QMAKE_CFLAGS_YACC       =
QMAKE_CFLAGS_LTCG       = -GL

contains(QMAKE_TARGET.arch, x86_64) {
    # SSE2 is mandatory on 64-bit mode, so skip the option. It triggers:
    # cl : Command line warning D9002 : ignoring unknown option '-arch:SSE2'
    QMAKE_CFLAGS_SSE2   =
} else {
    QMAKE_CFLAGS_SSE2   = -arch:SSE2
}
QMAKE_CFLAGS_SSE3       = $$QMAKE_CFLAGS_SSE2
QMAKE_CFLAGS_SSSE3      = $$QMAKE_CFLAGS_SSE2
QMAKE_CFLAGS_SSE4_1     = $$QMAKE_CFLAGS_SSE2
QMAKE_CFLAGS_SSE4_2     = $$QMAKE_CFLAGS_SSE2
QMAKE_CFLAGS_AESNI      = $$QMAKE_CFLAGS_SSE2
QMAKE_CFLAGS_SHANI      = $$QMAKE_CFLAGS_SSE2

QMAKE_CXX               = $$QMAKE_CC
QMAKE_CXXFLAGS          = $$QMAKE_CFLAGS
QMAKE_CXXFLAGS_WARN_ON  = $$QMAKE_CFLAGS_WARN_ON -w34100 -w34189 -w44996
QMAKE_CXXFLAGS_WARN_OFF = $$QMAKE_CFLAGS_WARN_OFF
QMAKE_CXXFLAGS_RELEASE  = $$QMAKE_CFLAGS_RELEASE
QMAKE_CXXFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO
QMAKE_CXXFLAGS_DEBUG    = $$QMAKE_CFLAGS_DEBUG
QMAKE_CXXFLAGS_YACC     = $$QMAKE_CFLAGS_YACC
QMAKE_CXXFLAGS_LTCG     = $$QMAKE_CFLAGS_LTCG
QMAKE_CXXFLAGS_STL_ON   = -EHsc
QMAKE_CXXFLAGS_STL_OFF  =
QMAKE_CXXFLAGS_RTTI_ON  = -GR
QMAKE_CXXFLAGS_RTTI_OFF =
QMAKE_CXXFLAGS_EXCEPTIONS_ON = -EHsc
QMAKE_CXXFLAGS_EXCEPTIONS_OFF =

QMAKE_INCDIR            =

QMAKE_RUN_CC            = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$obj $src
QMAKE_RUN_CC_IMP        = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ $<
QMAKE_RUN_CC_IMP_BATCH  = $(CC) -c $(CFLAGS) $(INCPATH) -Fo$@ @<<
QMAKE_RUN_CXX           = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$obj $src
QMAKE_RUN_CXX_IMP       = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ $<
QMAKE_RUN_CXX_IMP_BATCH = $(CXX) -c $(CXXFLAGS) $(INCPATH) -Fo$@ @<<

QMAKE_LINK              = link
QMAKE_LFLAGS            = /NOLOGO /DYNAMICBASE /NXCOMPAT
QMAKE_LFLAGS_RELEASE    = /INCREMENTAL:NO
QMAKE_LFLAGS_RELEASE_WITH_DEBUGINFO = /DEBUG /OPT:REF /INCREMENTAL:NO
QMAKE_LFLAGS_DEBUG      = /DEBUG
QMAKE_LFLAGS_CONSOLE    = /SUBSYSTEM:CONSOLE
QMAKE_LFLAGS_WINDOWS    = /SUBSYSTEM:WINDOWS
QMAKE_LFLAGS_EXE        = \"/MANIFESTDEPENDENCY:type=\'win32\' name=\'Microsoft.Windows.Common-Controls\' version=\'6.0.0.0\' publicKeyToken=\'6595b64144ccf1df\' language=\'*\' processorArchitecture=\'*\'\"
QMAKE_LFLAGS_DLL        = /DLL
QMAKE_LFLAGS_LTCG       = /LTCG
QMAKE_PREFIX_SHLIB      =
QMAKE_EXTENSION_SHLIB   = dll
QMAKE_PREFIX_STATICLIB  =
QMAKE_EXTENSION_STATICLIB = lib

QMAKE_LIBS              =
QMAKE_LIBS_GUI          = gdi32.lib comdlg32.lib oleaut32.lib imm32.lib winmm.lib ws2_32.lib ole32.lib uuid.lib user32.lib advapi32.lib
QMAKE_LIBS_NETWORK      = ws2_32.lib
QMAKE_LIBS_OPENGL       = glu32.lib opengl32.lib gdi32.lib user32.lib
QMAKE_LIBS_OPENGL_ES2   = gdi32.lib user32.lib
QMAKE_LIBS_OPENGL_ES2_DEBUG = gdi32.lib user32.lib
QMAKE_LIBS_COMPAT       = advapi32.lib shell32.lib comdlg32.lib user32.lib gdi32.lib ws2_32.lib
QMAKE_LIBS_QT_ENTRY     = -lqtmain

QMAKE_IDL               = midl /NOLOGO
QMAKE_LIB               = lib /NOLOGO
QMAKE_RC                = rc /NOLOGO

VCPROJ_EXTENSION        = .vcproj
VCSOLUTION_EXTENSION    = .sln
VCPROJ_KEYWORD          = Qt4VSv1.0
#D:\Qt\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\common\angle.conf
LIBEGL_NAME = libEGL
LIBGLESV2_NAME = libGLESv2
LIBQTANGLE_NAME = QtANGLE
#D:\Qt\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\common\windows-vulkan.conf
QMAKE_INCDIR_VULKAN     = $$(VULKAN_SDK)\\include
QMAKE_LIBS_VULKAN       =
#D:\Qt\Qt5.12.0\5.12.0\msvc2015_64\mkspecs\qconfig.pri
QT_ARCH = x86_64
QT_BUILDABI = x86_64-little_endian-lp64
QT.global.enabled_features = shared debug_and_release build_all c++11 thread future concurrent
QT.global.disabled_features = cross_compile framework rpath appstore-compliant c++14 c++1z c99 c11 pkg-config force_asserts separate_debug_info simulator_and_device static
QT_CONFIG += shared debug_and_release debug release build_all c++11 concurrent dbus no-pkg-config stl
CONFIG += shared release no_plugin_manifest
QT_VERSION = 5.12.0
QT_MAJOR_VERSION = 5
QT_MINOR_VERSION = 12
QT_PATCH_VERSION = 0
QT_MSVC_MAJOR_VERSION = 19
QT_MSVC_MINOR_VERSION = 0
QT_MSVC_PATCH_VERSION = 24215
QT_EDITION = OpenSource
QT_LICHECK =
QT_RELEASE_DATE = 2018-12-03

mkspecs/modules/qt_lib_{module}.pri

qmake 与 配置文件_丘上人的博客-CSDN博客

 类似资料: