$(MKDIR) 和 $(COPY_DIR) 等变量在哪里定义?

Where are variables such as $(MKDIR) and $(COPY_DIR) defined?

提问人:aybe 提问时间:12/2/2013 更新时间:2/15/2017 访问量:10643

问:

我试图获取这些变量包含的值,但我在网络上找不到有关它们的任何信息,并且在 C:\Qt 文件夹中搜索此类字符串一无所获。

这些变量在哪里定义?

qt-creator qmake

评论


答:

-2赞 C. S. 12/2/2013 #1

使用Mac上的终端

mkdir 在当前目录下创建一个目录。假设我当前的目录是 username:~/parent_directory $,如果您键入并按 Enter,它将创建一个名称代码mkdir code

17赞 Bill 12/2/2013 #2

在处理 .pro 文件并通过 qmake 生成 Makefile 之前,会根据您的编译器和平台对其他几个文件进行预处理。这些文件的扩展名为 .prf 和 .conf,并从名为 mkspecs 的目录中加载。

Makefile 中的 MKDIR 和 COPY_DIR 变量的值由以下文件中定义的 QMAKE_MKDIR 和 QMAKE_COPY_DIR 变量的值生成:

C:\Qt\Qt5.0.2\5.0.2\msvc2010\mkspecs\common\shell-unix.conf:

QMAKE_TAR              = tar -cf
QMAKE_GZIP             = gzip -9f

QMAKE_COPY             = cp -f
QMAKE_COPY_FILE        = $$QMAKE_COPY
QMAKE_COPY_DIR         = $$QMAKE_COPY -R
QMAKE_MOVE             = mv -f
QMAKE_DEL_FILE         = rm -f
QMAKE_DEL_DIR          = rmdir
QMAKE_CHK_EXISTS       = test -e %1 ||
QMAKE_CHK_DIR_EXISTS   = test -d    # legacy
QMAKE_MKDIR            = mkdir -p   # legacy
QMAKE_MKDIR_CMD        = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR    = sed

C:\Qt\Qt5.0.2\5.0.2\msvc2010\mkspecs\common\shell-win32.conf:

QMAKE_ZIP              = zip -r -9

QMAKE_COPY             = copy /y
QMAKE_COPY_DIR         = xcopy /s /q /y /i
QMAKE_MOVE             = move
QMAKE_DEL_FILE         = del
QMAKE_DEL_DIR          = rmdir
QMAKE_CHK_EXISTS       = if not exist %1
QMAKE_CHK_DIR_EXISTS   = if not exist   # legacy
QMAKE_MKDIR            = mkdir          # legacy
QMAKE_MKDIR_CMD        = if not exist %1 mkdir %1 & if not exist %1 exit 1

# xcopy copies the contained files if source is a directory. Deal with it.
CONFIG += copy_dir_files

(正如你所看到的,我正在使用Qt 5.0.2,所以你的机器上的路径可能不同。

评论

0赞 kayleeFrye_onDeck 4/2/2016
巨大的警告:看起来QMAKE_MKDIR_CMD在Qt 5.6中不起作用,但QMAKE_MKDIR确实如此。我在这个 x.x 上浪费了很多时间 拯救自己!
3赞 Zitrax 10/12/2016
在Qt 5.7中,该文件存在,但只是一条消息表明它们已被弃用。知道它们现在在哪里定义吗?此外,我在Qt文档中没有看到有关变量本身的任何信息。
11赞 yalov 2/15/2017 #3

Qt 5.8更新

c:\Qt\5.8\mingw53_32\mkspecs\features\spec_post.prf

类似 Windows:

QMAKE_ZIP               = zip -r -9

QMAKE_CD                = cd /d
QMAKE_COPY              = copy /y
QMAKE_COPY_FILE         = $$QMAKE_COPY
QMAKE_COPY_DIR          = xcopy /s /q /y /i
# xcopy copies the contained files if source is a directory. Deal with it.
CONFIG                 += copy_dir_files
QMAKE_MOVE              = move
QMAKE_DEL_FILE          = del
QMAKE_DEL_DIR           = rmdir
QMAKE_DEL_TREE          = rmdir /s /q
QMAKE_CHK_EXISTS        = if not exist %1
QMAKE_CHK_DIR_EXISTS    = if not exist   # legacy
QMAKE_MKDIR             = mkdir          # legacy
QMAKE_MKDIR_CMD         = if not exist %1 mkdir %1 & if not exist %1 exit 1
QMAKE_STREAM_EDITOR     = $(QMAKE) -install sed
QMAKE_INSTALL_FILE      = copy /y
QMAKE_INSTALL_PROGRAM   = copy /y

类 Linux:

QMAKE_TAR               = tar -cf
QMAKE_GZIP              = gzip -9f

QMAKE_CD                = cd
QMAKE_COPY              = cp -f
QMAKE_COPY_FILE         = $$QMAKE_COPY
QMAKE_COPY_DIR          = $$QMAKE_COPY -R
QMAKE_MOVE              = mv -f
QMAKE_DEL_FILE          = rm -f
QMAKE_DEL_DIR           = rmdir
QMAKE_DEL_TREE          = rm -rf
QMAKE_CHK_EXISTS        = test -e %1 ||
QMAKE_CHK_DIR_EXISTS    = test -d    # legacy
QMAKE_MKDIR             = mkdir -p   # legacy
QMAKE_MKDIR_CMD         = test -d %1 || mkdir -p %1
QMAKE_STREAM_EDITOR     = sed

equals(QMAKE_HOST.os, Windows) {
    MINGW_IN_SHELL = 1   # legacy
    # Override built-ins.
    QMAKE_DIR_SEP = /
    QMAKE_DIRLIST_SEP = :
    # Because install's ability to set permissions is not relevant on Windows,
    # and git's msys does not provide it to start with.
    QMAKE_INSTALL_FILE      = cp -f
    QMAKE_INSTALL_PROGRAM   = cp -f
} else {
    QMAKE_INSTALL_FILE      = install -m 644 -p
    QMAKE_INSTALL_PROGRAM   = install -m 755 -p
}