2

I've started digging in under the hood so that I can better understand the inner workings of CMake. I've been going through the files in the Modules directory in order to understand how/why/when things happen when running CMake.

I've so far been unable to determine how/where the CMAKE_HOST_APPLE/CMAKE_HOST_UNIX/CMAKE_HOST_WIN32 variables are set.

Can anyone enlighten me?

On a related note, I've been going through the Modules files in a haphazard manner since I don't know the order in which they are initiated/processed.

Is there anywhere that describes this flow or at the very least indicates a starting point so that I can figure out the rest from there?

Florian
  • 39,996
  • 9
  • 133
  • 149
WXB13
  • 1,046
  • 3
  • 11
  • 17

1 Answers1

1

Those variables are set in CMake's code surrounded by platform dependent #ifdef checks, so you can say they are set during compile time of CMake itself.

I also had some difficulties locating the source file in question, because the code to add those default variable definitions has just recently moved from cmMakefile::AddDefaultDefinitions() to cmState::Snapshot::SetDefaultDefinitions() (see this commit).

Here is an example from cmState.cxx:

#if defined(__APPLE__)
  this->SetDefinition("APPLE", "1");
  this->SetDefinition("CMAKE_HOST_APPLE", "1");
#endif

For more information on how CMake does work see:

Community
  • 1
  • 1
Florian
  • 39,996
  • 9
  • 133
  • 149