Qt: How to create a directory in project file?

Kroll

I just want to crossplatform make a single directory from *.pro file. I use some commands like $(COPY_DIR) and $(COPY_FILE) well. And I saw in internets a many examples with command $(MKDIR) but it did not work for me.

It prints: C:/Projects/installer/installer.pro(24): Extra characters after test expression.

when I used $$(MKDIR) on line 24.

Or: C:/Projects/installer/installer.pro(24): '$' is not a recognized test function.

when I $(MKDIR).

What the proper way to create a directory in qmake projects?

Benjamin T

Short answer

Use QMAKE_MKDIR like so:

mytarget.commands += $${QMAKE_MKDIR} $$shell_path($${OUT_PWD}/foo)

Long answer

qmake provides variables holding useful commands. Take a look at Undocumented QMake article on Qt Wiki. The one you are looking for is QMAKE_MKDIR, but you might also be interested in QMAKE_CHK_DIR_EXISTS.

If the values given by qmake do not suite you, you can use the environment to retrieve the mkdir command:

$(MKDIR) $$shell_path($${OUT_PWD}/foo)
$$(MKDIR) $$shell_path($${OUT_PWD}/foo)

The $(...) syntax retrieves the environment variable when make (or nmake...) is run while $$(...) retrieves it when qmake is run.

Also the mkdir command should be call in the context of a "make target" declared with QMAKE_EXTRA_TARGETS. See Adding custom targets in qmake documentation.

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

How to create a file from directory structure

how to create a gradle and spring project in intellij (ultimate)

How to run Maven from another directory (without cd to project dir)?

How to create an empty MVC 5 project in VS2013

Maven project.build.directory

create_directory()与create_directories()

Qt找不到适用于“ org.qt-project.qt.mediaplayer”的服务

使用 sed 抛出 No such file or directory

How to find a directory on linux?

Directory.Delete()/ .Create()是否同步?

How to move directory into a directory with the same name?

file.create语法

bat file - change directory and npm install in that directory, then switch again

PyQt5 QMediaPlayer defaultServiceProvider :: requestService():找不到针对“ org.qt-project.qt.mediaplayer”的服务

使用sudo运行PhpStorm的Create Project

上传位于Angular Project Directory中的文件/图像

如何在Project Directory中获取Python文件的真实路径

.NET Directory.Move()与File.Move()

Xcode 错误 Alamofire.framework: No such file or directory

Print line for word found in file in directory

bourne shell,如果[-e $ directory / file。$ suffix]

Python内的Django File-Directory

How to take a screenshot on Windows 7 and auto create screenshot file on desktop like Mac?

Copy a specific percentage of each file in a directory to a new file

QT + OpenCV取消对cv :: stereoBM :: create(int,int)的引用

无法在Qt中执行“ SHOW CREATE TABLE”查询

Where is the lint output file located in an android project?

在ubuntu上为Qt GUI脚本创建file.desktop

how to project field in array with mongodb