How to properly deal with _WIN32_WINNT and WINVER in modern CMake

Viewed 181

I wonder what the "modern" (read: property-based) way is to set _WIN32_WINNT and WINVER for a CMake project.

The problem I want to solve is how to set the version to the highest value that is required by any of the libraries or subcomponents of my project. For example, if my project code by itself needs WINVER to be at least 0x0601 (Windows 7), but it uses library A that needs at least 0x0603 (Windows 8.1) and library B that needs at least 0x0A00 (Windows 10), it is clear that my overall product needs the highest of those.

If I just define appropriate settings as target_compile_definitions, I may end up having the same macro definition on the command line several times, with the last taking precedence, which may be the wrong one.

How do I arrange for the highest version to be taken automatically?

I have tried to find other answers to this question, but they seem to be fairly old, and hence don't seem to reflect modern practice.

0 Answers
Related