I am bit confused about which of PLATFORM_ID vs. WIN32 vs. CMAKE_SYSTEM_NAME to use.

My build system supports Windows and macOS, so it looks like:

  • for normal branching in the CMake scripts, I have the choice between CMAKE_SYSTEM_NAME=“Windows/Darwin” and the variables WIN32/APPLE
  • in generator expressions, I have the choice between PLATFORM_ID and WIN32/APPLE

WIN32/APPLE has the advantage of being universal in this context, but they look like legacy variables and not very clean (APPLE could also mean iOS, WIN32 is also true for Windows 64bit).

What’s the modern way to do this?


The WIN32, APPLE, UNIX, etc. variables are “soft” deprecated due to this. We’ll never actually get them removed in the wider ecosystem, so they mean what they mean with all the conflations and ambiguities they come with. CMAKE_SYSTEM_NAME is what I’d use in CMake code, PLATFORM_ID is needed in generator expressions. A bit unfortunate about the naming difference if there isn’t some other difference, but I guess that needs documented if so?

1 Like

OK, thanks