2011-07-19 38 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