2011-07-19 35 views
1

你好,我想要做这样的事情在我的项目与子目录正与QMAKE

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中有一些用于构建目录的东西,但我认为这是错误的方式。

+1

将您的可执行文件添加到该行:DESTDIR = bin – kmdent

+0

谢谢,但主要问题在于将dir脚本移动到bin /中。 Make可以做到这一点,但我并不真正了解qmake。 – Ximik

回答

4

将其添加到您的文件的底部。这可以满足您的一切需求。我列出了将脚本复制到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 

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

这可能适用于具有'cp'的系统。 $$ QMAKE_COPY或$$ QMAKE_COPY_DIR(在当前QMAKESPEC的qmake.conf中定义)将更具可移植性。另一种解决方案是使用INSTALLS。 – jwernerny

3

我认为qmake INSTALLS提供了良好的跨平台解决问题的方法不依赖于特定的命令(即CP)是在系统上可用。它只需要运行make install

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