My Qt project structure is similar to this:
Directory Structure:
|
|--- dir
| |
| | - a.c
| | - a.h
| | - test.pro
|--- dir1
| | - b.c
| | - b.h
test.pro
SOURCES += a.c \
../dir1/*.c
HEADERS += a.h \
../dir1/*.h
When I try to build the project I get the error:
:-1: error: No rule to make target `../dir1/*.c'
Is there anyway to include source files which are outside the .pro file?
And also have them show in the Projects pane on the left in Qt Creator?
Wildcards in qmake (.pro file) work only for files in current project directory. For subfolders it does not work. So the proper solution is to add each file separately.
The issue was raised on the Qt bug tracker QTCREATORBUG-8925. The ticked is closed as a new feature request or due to multiple problems:
Using wildcards in .pro files creates multiple problems, e.g. adding a
additional file won't automatically compile it. Nor would deleting a
file automatically remove it from the Makefile
However, there is undocumented function listed on the wiki Undocumented_QMake
files(glob) — Returns a list of files which match the specified glob
pattern.
So, if the above problems of using globbing patterns are acceptable it can be used as
SOURCES += $$files(../dir1/*.c)
Related
I want to reset LIBS variable of my project without touching pro file itself.
qmake fileName.pro LIBS=
this will not work, because "LIBS=" is performed before loading fileName.pro.
cat fileName.pro | grep -v "LIBS.*=" | qmake /dev/stdin
will not work too, qmake seems to NOT be intended for PIPE-ing.
so is there some other option for editing/ignoring/reseting variable insade qmake command line, without changing pro file.
it was the -after option that i was looking for:
qmake fileName.pro -after LIBS=
works well.
I have a structure of dirs with a couple of projects. Some of the projects depend on others ones which may in turn depend on others.
Dir
+-Proj1
| +-Debug
| | makefile
| +-Release
| makefile
| <sources>
+-Proj2
| +-Debug
| | makefile
| +-Release
| makefile
| <sources>
...
The makefiles automatically generated (by the Eclipse CDT) so I could not change it because in case of some changes in projects my changes will go away.
Now, every project must be built in the corresponding Debug or Release dirs. Each of the makefiles has a relative refers to the sources that's why I need to build every project in the Debug or Release dirs.
The makefiles which generated by the Eclipse contain a possibility to include a user makefiles. I use this feature to cause the make build projects which others depend on earlier. Suppose the Proj1 depends on the Proj2. Then I added dependency on the ../../Proj2/<Debug or Release>/proj2.so for the result file of the Proj1 and added this rule for the Proj1:
$(USER_DEPS): # (*)
$(MAKE) -C "$(dir $#)" all
Here the USER_DEPS contains a list of a files which this project depends on. For example
USER_DEPS:=../../Proj2/Debug/proj2.so \
../../Proj3/Debug/proj3.so
And all of this works until I change something in the sources in the Proj2. Now if I run make for the Proj1 it see that the ../../Proj2/Debug/proj2.so is here but it does not see that it is not actual. There could be ideal simply to include the makefile of the Proj2 into Proj1 instead of writing the rule marked with the (*), but the makefile of the Proj2 contains a relative references to its sources. Ie if I will try to include them into Proj1 the make will try to find a Proj2's sources in the Proj1's dir.
Has someone any ideas?
I use macro to specify the output directory in .pro file which works fine. but my local directory still have debug and release folders created. How could I stop creating those 2 empty folders?
EDIT: this is on my Windows 7. I use qt 5.5 creator 3.6.0. same setup on Windows 10 behaves differently. On Windows 10 it output to folder at the same level as bin, called build-configuration-details.
debug {
DESTDIR = ../../bin/debug
MOC_DIR = ../../build/lib/debug
OBJECTS_DIR = ../../build/lib/debug
}
release {
DESTDIR = ../../bin/release
MOC_DIR = ../../build/lib/release
OBJECTS_DIR = ../../build/lib/release
}
original structure
app
|
lib
|
.pro
after compile
bin
| |
debug (libs)
| |
release (libs)
|
build
| |
debug (objects)
| |
release (objects)
|
app
|
lib
|
.pro
|
debug (empty)
|
release (empty)
To avoid creating extra debug and release folders in source tree you should enable Shadow build in Qt Creator.
When it is not enabled the Qt Creator creates debug and release folders in the source tree (more precisely saying qmake creates them). What you set in .pro files only says to qmake where you want to put some specific folders. But the qmake itself is running in your source tree and creates there debug and release folders. When you enable shadow build then qmake runs in the folder that you set in shadow build path.
I have the following project structure:
/
general.pro
a/
a.pro
some files
b/
b.pro
some files
c/
Makefile
some files
general.pro is a TEMPLATE=subdirs style qmake-project. The two other project files are normal/common qmake project files (folder a and b). The third folder (folder c) contains a kernel module with the following Makefile: http://pastebin.com/Bv39D6KK
I'm wondering if that Makefile can be translated somehow to a qmake project file.
If not, is there a way to the the general.pro project file that there is a "c" folder containing a Makefile which should be ran too?
Regards
I really doubt, you can include Makefile in a .pro file.
Here is my thoughts about what you can do:
If c is your project, you could simply create one more .pro file for it.
If it is not, and you don't need to edit it, you could build it without including into subdirs (if it's a library, you are using in a or b, you still can build it, and then create a .pri file and add includes and libs etc).
If you need it for a build machine or for deploying, you could use build script.
You could use cmake.
Update:
It turns out, there is a solution.
Though, I could not make it work myself, I hope it helps. What you need is to add following lines to a top-level pro file:
mytarget.commands = make -C c
QMAKE_EXTRA_TARGETS += mytarget
PRE_TARGETDEPS += mytarget
Where c is a name of sub-directory, containing Makefile.
I've been reading for a couple days on how to copy/update external resources, plugins or frameworks to my App's Mac Bundle using Qt creator or qmake.
Right now I have found two main solutions. One is to use qmake together with some commands on the ".pro" file. The other one is to do a "Custom Deployment Step" script.
I was hoping to use the second option cause I already had a small make script that did what I wanted. The problem is that Qt Creator offers so little variables to work with that the script lost its usefulness. For instance, my script uses the "Target App Path" as a parameter so it can do all its work from there. But please correct me if I'm wrong, Qt Creator only offers %{buildDir} and %{sourceDir} variables...
The other option is using qmake. These are the things that I have tried so far on my ".pro" file:
1) Using the INSTALL command. I did a small test where I tried copying some files this way:
MediaFiles.path = test/media
MediaFiles.files = media/*
INSTALL += MediaFiles
And basically nothing happend. I was hopping to find the same "media" folder on the "test" folder but nothing. Don't know if I'm doing something wrong.
Please note that the "media" folder is beside the "test" folder and the ".pro" file. (They all have the same hierarchy position.)
2) Then I tried QMAKE_BUNDLE_DATA:
MediaFiles.path = Contents/MacOS
MediaFiles.files = media/*
QMAKE_BUNDLE_DATA += MediaFiles
But this gave me the following error:
usage: cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file target_file
cp [-R [-H | -L | -P]] [-fi | -n] [-apvX] source_file ... target_directory
make: *** [PathToApp] Error 64
None of the solutions seem to be pleasing so far. If I wanted to do a good custom make script I will need to hardcode every target path separately. In my case I have 8 different target path depending on some "CONFIG" variables.
I'm sure the qmake solution are the official way of doing this. If someone can point me out the solution to the Error 64 would be cool.
Some further question:
Do I have to do a qmake every time I want to update my bundle?
Can I execute my make script with the qmake?
QMAKE_BUNDLE_DATA started working flawlessly after putting the command on the end of the .pro script.
mac{
MediaFiles.files = media
MediaFiles.path = Contents/MacOS
QMAKE_BUNDLE_DATA += MediaFiles
}