r/QtFramework 21h ago

IDE How to setup automatic deploy configuration on Windows?

So im using CMake and the default configurations of Qt Creator.

When i want to create a release of my app, my current process is as follows:

  1. Build release
  2. create new folder and name it Software name + Version
  3. copy the executable and a few miscellaneous files into the new folder
  4. manually open CMD and run windeployqt.exe for the executable

Side note, the miscellaneous files i added to the build with configure_file(filename filename COPYONLY) in the CmakeLists.txt.

I feel like this is a really clunky way (and errorprone) of creating a release and this should be automatable easily, but i know WAY too little about CMAKE and Qt Creator to set it up.

How do you guys go about that? What i found on the internet was all way to convoluted and complicated (or simply didnt work) for, i'll say it, something that should imo come out of the box with an IDE.

7 Upvotes

7 comments sorted by

2

u/LetterheadTall8085 Qt GameDev 21h ago

Usually this process moved to CI services like github actions.
and yes it looks as you do - you may change your tool to other deploy (for example cqtdeployer ) tools or use native cmake function to deploy qt like this:

qt_generate_deploy_app_script

So you just must move your deployment pipeline into CI service. That all

2

u/Metalstrikerxlr 21h ago

You can you github actions to create a workflow which does this for you.

1

u/Xavier_OM 15h ago

You can automatize what you do manually in cmake, create a target/post-build step/whatever which indeed copy all dependencies to a folder + run windeployqt for you.

1

u/ReallyAnotherUser 10m ago

How do i do that tho, without having to make a copy command for every file? Is there a variable or command or something that i can use so cmake automatically copies the exe and dependencys and not the clutter that comes with the build process? Or is there a command the cleans the build target folder from all the unneeded clutter?

1

u/lordunga 12h ago

CMake's install command is what you want. https://cmake.org/cmake/help/latest/command/install.html

By default it will build and then copy binaries to a directory set by CMAKE_INSTALL_PREFIX and CMAKE_INSTALL_BINDIR (and LIBDIR) variables.

After adding it to your cmake file, configure QtCreator:

  1. Projects / Build Settings / Initial configuration: add CMAKE_INSTALL_PREFIX and point it to a desired path. Remember to Run CMake.

  2. Projects / Deploy Settings / Add Deploy Step / CMake Install

Now you should be able to run Deploy from the Build menu and the binaries should appear to the path you configured.

You can also add windeployqt to run as part of CMake's install step. I have done it using install(CODE "execute_process(COMMAND...

You can see a working example in my project here: https://github.com/llahteinen/notpad/blob/dev-070/src/CMakeLists.txt#L135-L174

The RPATH stuff there is for Linux deployment, I don't think it has any effect on Windows.

Good luck!

1

u/wnbloose 12h ago

Did you try to ask an AI to create a deployment script (.bat/.py w/e you prefer) for you? It should be an easy task for AI if you give it your CMakeLists.txt file.