BR: Binary file version not updated on rebuild

Hi, I have an issue when building a gui app on Windows where the version of the .exe-file doesn’t always reflect the CMake project version. It seems the issue is that the MyApp_resources.rc file is not rewritten when the project is reconfigured.
I’ve just reproduced in a minimal example to check that it’s not just some weirdness in my project.
On the first build the file version is correct, but if I change the project version in CMakeLists.txt then the app window shows the correct version, but the version of the file is unchanged.
Deleting the .exe, doesn’t help.
Deleting MyApp_resources.rc does.

Try deleting the CMake cache before running CMake again.
build/CMakeCache.txt.

If you’re using CLion, there’s a shortcut for that: Tools->CMake->Reset Cache. I’ve assigned a keyboard shortcut for it because it’s so useful.

1 Like

Thanks, that works! I am indeed using CLion and I almost never use reset cache, I just reload. When do you usually use reset cache instead of just reload? :slight_smile:

Anyways, I still feel like it should detect that the .rc file needs to be regenerated when the project version changes. Or is that to be expected?

I just ‘reset cache and reload’ whenever I change anything in the CMake file or something that the CMake file depends on, like binary resources that are globbed.

I never use reload because it’s (IMO) error prone and can miss updates.

1 Like

If you touch CMakeLists.txt in any way whatsoever, always delete the cache before you re-run cmake.

Remember, cmake is a ‘meta-make make tool’, which ‘makes the Makefile used to build the project’ - if you change any of the meta data in CMakeFiles.txt you have thus invalidated the contents of CMakes’ “cache” (imho, this is horribly named), and have to apply the new meta- data again, fresh. Think of it not as a ‘cache’, but as a generated set of tools for building your project - these tools have to be updated whenever you make a change to the metadata.

Yeah, I guess I assumed rerunning CMake actually did it… Thanks for the tips! I’ve added a shortcut key now :slight_smile: