How to force rcc-ing of a qrc file on each build in Visual Studio 2015? We are embedding the resources in the binary, so if something like qml or image assets change, we need to run rcc to get a fresh .cpp
file for the current state. I see several options - brutally touching the .qrc
file in a pre build event, running a script which checks everything in the asset folder before build and checking the timestamps and comparing them to a state at the previous build. Are there cleaner and more elegant options?
相关问题
- Sorting 3 numbers without branching [closed]
- QML: Cannot read property 'xxx' of undefin
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
相关文章
- ubuntu20.4中c#通过c++库调用python脚本
- Qt槽函数自动执行多遍
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
Since it was requested in the comments, I'm publishing the solution I came up with. So, in my case the
qrc
file is added to the Visual Studio solution, and has a proper Custom Build Tool set (but that is the common way and should be set up by the VS Qt plugin) like this:All I had to do was to make a trivial C# program which reads the contents of the
qrc
and updates the modification timestamp of theqrc
file, if any of the contained items was newer than theqrc
itself. This is all it takes:This tool takes the
qrc
file as the first argument. So I just added calling this tool as a pre build event, and if any changes have happened to the resources, theqrc
file is touched, and it's normal build command is invoked.If you were to use CMake, you could add a pre-build task to delete the
your-project-name_autogen
folder from the build directory. This forces CMake to rcc the qrc file each build.The command might look something like:
CMake does this by adding a Pre-Build Event to its generated Visual Studio project, so you can also replicate it with only Visual Studio. If you haven't found the pre-build event section already, right-click on the desired project (not solution), and select
Properties
. UnderBuild Events
, there should be a section calledPre-Build Events
. A command likedel your-files
would probably suffice.The answer linked below gave some other decent options.
How to delete files in Visual Studio Pre-build event command line
The CMake command was the solution to my issues with a Qt qrc file containing QML resources.