can i specify a pre_build step in my .pro file?
i know i can specify a QMAKE_POST_LINK in my pro file, but is there a QMAKE_PRE_BUILD or equivalent? i saw a method that uses target dependencies to achieve this, but that feels very hacky.
What would you need to do in that ore-build step ?
the question isn't about what i want to do with it, the question is "is there a way?"
but if you are just curious, there are several valid reasons to want this:
- generating a .cpp or .h file before the build starts
- modifying / updating a version file to be read in during build
- pre-cleaning previous build cruft
- deleting the exe to enforce re-linking (which will enforce post-link-step(s)) if some file NOT in the project has changed
- other, very valid reasons which i don't remember, as part of a very complex, multi-target build system
you can add a custom build step and move it to before all the other steps.
Does not that not serve your purpose?
it does not because that's not automatic when someone ELSE opens the pro file
plus if i have six targets and two bit depths, that's 12 targets i have to add that step to?
it's begging for automation, which the pro file is MADE for
sorry, i don't follow your meaning?
if another developer opens the .pro file, (ie: must generate their own .user file), then the knowledge to create the pre_build step must be made by the voice-to-ear network, rather than it being automatic. multiply by hundreds of developers and it's obviously an error prone method
ah, i see.
so, which is your favourite tool to work with that can do this kind of thing for you then?
i don't understand what you're getting at by asking this question?
to be clear, i'm asking "can this be done?"
the answer is "yes" or "no", right?
i am just asking you what tool you prefer to use or have used that can do what you want. I am just thinking that you are finding the Qt Creator pro file combination laking in that respect Hence your question to the forum.
This is after all an open forum and any one can ask any kind of question they like. I thought I might learn from your experience of better tools for doing the kind of things you are describing.
Excuse me for wasting your time!!
i had been using xcode, which already does the particular thing that i need (always does post-build steps regardless of whether a re-link is necessary), and MSDEV (which did not, causing me to need to delete the exe, by hand, every time)
also i do not know that Qt Creator is lacking this feature, since no definitive answer has been given
i did not intend to ruffle your feathers.
Thank you for your explanation. I hope someone on the forum will be able to help you with you question.
We use $$system to run scripts that does some tasks.
UNAME = $$system(uname -s)
contains( UNAME, [lL]inux ):message( This looks like Linux ($$UNAME) to me )
but when does that get run? any time the .pro is parsed? mine gets parsed THREE times when i "run qmake", and does NOT get parsed before running
Have a look by
[EDIT: Irrelevant link removed --JKSH]
before the big build Framework start... is a submodule dir that compile bevore all... only question from pro e pri file and comand....
or CMakeFile.txt... can do all in build order...
i'm not looking for a hack, i'm looking for official support.
i'm guessing at this point the answer is "no"
I have not tested myself, but see https://wiki.qt.io/Undocumented_QMake:
"And finally an example on how to call a batch file called "PreBuildEvent.bat" each time you compile your code (tested in VisualStudio, based on qt-creator-enterprise-src-3.1.0\share\qtcreator\static.pro):"
PRE_BUILD_FILE = ../Applications/PreBuildEvents.bat # must use a variable as input PHONY_DEPS = . PreBuildEvent.input = PHONY_DEPS # use non-existing file here to execute every time PreBuildEvent.output = phony.txt # the system call to the batch file PreBuildEvent.commands = call $$PRE_BUILD_FILE # some name that displays during execution PreBuildEvent.name = running Pre-Build steps... # "no_link" tells qmake we don’t need to add the output to the object files for linking, and "no_clean" means there is no clean step for them. # "target_predeps" tells qmake that the output of this needs to exist before we can do the rest of our compilation. PreBuildEvent.CONFIG += no_link no_clean target_predeps # Add the compiler to the list of 'extra compilers'. QMAKE_EXTRA_COMPILERS += PreBuildEvent
(Of course that is no official solution, but most likely will work nicely)