Is there a way to tell QMake to run a script after the build has finished?
-
Hello,
I want to run a deployment script after the build has finished, if the build was set to the RELEASE setting.
Is it possible to somehow tell QMake to run a script after it's done building? -
-
Could you please elaborate? I don't quite understand what I should do.
Let's say I have a python script called
myscript.py
in the$PWD
of the project. What do I need to do to run it after the build is finished?I want to do something like
ONCE_BUILDING_FINISHED_RUN_COMMAND ( $$system(python "$${PWD}/myscript.py" SOME_ARG)
I admit that I don't quite understand how to do that from the link you provided.
-
Thank you for the link. I still fail to understand what I have to do.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/__header.h ${CMAKE_CURRENT_BINARY_DIR}/header.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h COMMAND python ${py_cmd} )
As far as I understand, the relevant command here is
COMMAND python ${py_cmd}
and what tells it to run is the custom target? Also, I'm using QMake, is it the same? -
Thank you for the link. I still fail to understand what I have to do.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/__header.h ${CMAKE_CURRENT_BINARY_DIR}/header.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h COMMAND python ${py_cmd} )
As far as I understand, the relevant command here is
COMMAND python ${py_cmd}
and what tells it to run is the custom target? Also, I'm using QMake, is it the same?@Curtwagner1984 Sorry that is for cmake.
-
@Curtwagner1984 Sorry that is for cmake.
-
Thank you for the link. I still fail to understand what I have to do.
add_custom_command( OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/__header.h ${CMAKE_CURRENT_BINARY_DIR}/header.h DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/OriginalHeader.h COMMAND python ${py_cmd} )
As far as I understand, the relevant command here is
COMMAND python ${py_cmd}
and what tells it to run is the custom target? Also, I'm using QMake, is it the same? -
@JoeCFD
From what I understand, QMAKE_POST_LINK will run a script after linking. but not after building. (IE, before the .exe file is generated).The other solution there involves making an extra build target with a dummy
cpp
file like so:TEMPLATE = lib SOURCES = placeholder.cpp # <== dummy cpp CONFIG += no_link staticlib batch_runner.target = placeholder.cpp batch_runner.commands = my_batch_file.bat # <== script to be run QMAKE_EXTRA_TARGETS = batch_runner
Is this the optimal solution?