使用 qmake 处理子目录

发布于 2024-11-25 05:19:11 字数 597 浏览 0 评论 0原文

你好,我想在我的项目中做这样的事情

project/
--sources/ -- cpp, h
--forms/ -- ui
--build/ -- object files, mocs
--bin/ -- execute file will appear here
--scripts/ -- this folder should be copied in the bin/ folder after make
project.pro - pro-file

,我使用 qtcreator,但我没有找到类似的东西。所以我尝试自己编写 *.pro 文件。现在我有类似的东西

QT       += core gui

TARGET = project
TEMPLATE = app


SOURCES += src/main.cpp\
        src/mainwindow.cpp

HEADERS  += src/mainwindow.h

FORMS    += src/mainwindow.ui

但这还不够。所以我寻求帮助。

UPD:另外,.pro.user 中有一些用于构建目录的内容,但我认为这是错误的方式。

Hello I want to do something like this in my project

project/
--sources/ -- cpp, h
--forms/ -- ui
--build/ -- object files, mocs
--bin/ -- execute file will appear here
--scripts/ -- this folder should be copied in the bin/ folder after make
project.pro - pro-file

I use qtcreator, but I find nothing like this stuff. So I've tried to write *.pro file myself. Now I have something like

QT       += core gui

TARGET = project
TEMPLATE = app


SOURCES += src/main.cpp\
        src/mainwindow.cpp

HEADERS  += src/mainwindow.h

FORMS    += src/mainwindow.ui

But this is not enough. So I'm asking for help.

UPD: Also, there is some stuff for build dir in .pro.user, but I think it's wrong way.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

不醒的梦 2024-12-02 05:19:11

将其添加到文件的底部。这可以满足您所需的一切。我列出了两种将脚本复制到 bin 目录的方法。第二种方法归功于jwernerny。如果您有任何疑问,请询问。

DESTDIR= ./bin          #adds the exe to bin
MOC_DIR = ./build       # Deals with MOCS
OBJECTS_DIR = ./build   #deals with objects

#复制脚本的两种方法。

dist.commands += cp -r ./scrpits ./bin 

或者

script_install.path = ./build
script_install.files = ./scripts/*
INSTALLS += script_install

Add this to the bottom of your file. This does everything you need. I listed two methods of copying the scripts to the bin directory. Credit for the second method goes to jwernerny. Ask if you have any questions.

DESTDIR= ./bin          #adds the exe to bin
MOC_DIR = ./build       # Deals with MOCS
OBJECTS_DIR = ./build   #deals with objects

#Two Methods for Copying the scripts over.

dist.commands += cp -r ./scrpits ./bin 

OR

script_install.path = ./build
script_install.files = ./scripts/*
INSTALLS += script_install
与风相奔跑 2024-12-02 05:19:11

我认为 qmake INSTALLS 提供了一个很好的、交叉的问题的平台解决方案,而不依赖于系统上可用的特定命令(即 cp)。它只需要运行make install

script_install.path = ./build
script_install.files = ./scripts/*
INSTALLS += script_install

I think qmake INSTALLS provides a good, cross platform solution to the problem without relying on specific commands (i.e. cp) being available on the system. It only requires running make install.

script_install.path = ./build
script_install.files = ./scripts/*
INSTALLS += script_install
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文