| 300 | } |
| 301 | |
| 302 | void cmStateSnapshot::SetDefaultDefinitions() |
| 303 | { |
| 304 | /* Up to CMake 2.4 here only WIN32, UNIX and APPLE were set. |
| 305 | With CMake must separate between target and host platform. In most cases |
| 306 | the tests for WIN32, UNIX and APPLE will be for the target system, so an |
| 307 | additional set of variables for the host system is required -> |
| 308 | CMAKE_HOST_WIN32, CMAKE_HOST_UNIX, CMAKE_HOST_APPLE. |
| 309 | WIN32, UNIX and APPLE are now set in the platform files in |
| 310 | Modules/Platforms/. |
| 311 | To keep cmake scripts (-P) and custom language and compiler modules |
| 312 | working, these variables are still also set here in this place, but they |
| 313 | will be reset in CMakeSystemSpecificInformation.cmake before the platform |
| 314 | files are executed. */ |
| 315 | cm::string_view hostSystemName = cmSystemTools::GetSystemName(); |
| 316 | this->SetDefinition("CMAKE_HOST_SYSTEM_NAME", hostSystemName); |
| 317 | if (hostSystemName == "Windows") { |
| 318 | this->SetDefinition("WIN32", "1"); |
| 319 | this->SetDefinition("CMAKE_HOST_WIN32", "1"); |
| 320 | this->SetDefinition("CMAKE_HOST_EXECUTABLE_SUFFIX", ".exe"); |
| 321 | } else { |
| 322 | this->SetDefinition("UNIX", "1"); |
| 323 | this->SetDefinition("CMAKE_HOST_UNIX", "1"); |
| 324 | this->SetDefinition("CMAKE_HOST_EXECUTABLE_SUFFIX", ""); |
| 325 | } |
| 326 | #if defined(__APPLE__) |
| 327 | this->SetDefinition("APPLE", "1"); |
| 328 | this->SetDefinition("CMAKE_HOST_APPLE", "1"); |
| 329 | #endif |
| 330 | #if defined(__sun__) |
| 331 | this->SetDefinition("CMAKE_HOST_SOLARIS", "1"); |
| 332 | #endif |
| 333 | |
| 334 | #if defined(__OpenBSD__) |
| 335 | this->SetDefinition("BSD", "OpenBSD"); |
| 336 | this->SetDefinition("CMAKE_HOST_BSD", "OpenBSD"); |
| 337 | #elif defined(__FreeBSD__) |
| 338 | this->SetDefinition("BSD", "FreeBSD"); |
| 339 | this->SetDefinition("CMAKE_HOST_BSD", "FreeBSD"); |
| 340 | #elif defined(__NetBSD__) |
| 341 | this->SetDefinition("BSD", "NetBSD"); |
| 342 | this->SetDefinition("CMAKE_HOST_BSD", "NetBSD"); |
| 343 | #elif defined(__DragonFly__) |
| 344 | this->SetDefinition("BSD", "DragonFlyBSD"); |
| 345 | this->SetDefinition("CMAKE_HOST_BSD", "DragonFlyBSD"); |
| 346 | #endif |
| 347 | |
| 348 | #if defined(__linux__) |
| 349 | this->SetDefinition("LINUX", "1"); |
| 350 | this->SetDefinition("CMAKE_HOST_LINUX", "1"); |
| 351 | #endif |
| 352 | |
| 353 | #if defined(_AIX) |
| 354 | this->SetDefinition("AIX", "1"); |
| 355 | this->SetDefinition("CMAKE_HOST_AIX", "1"); |
| 356 | #endif |
| 357 | |
| 358 | this->SetDefinition("CMAKE_MAJOR_VERSION", |
| 359 | std::to_string(cmVersion::GetMajorVersion())); |