|
|
There are several different ways to check the current system/platform in
|
|
|
CMake, and each interacts with cross-compiling in different ways.
|
|
|
|
|
|
## Platform Variables
|
|
|
|
|
|
CMake sets certain variables to true depending on the current platform
|
|
|
and toolchain in use. These always describe the *target* platform.
|
|
|
|
|
|
- UNIX : is TRUE on all UNIX-like OS's, including Apple OS X and
|
|
|
*CygWin*
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- WIN32 : is TRUE on Windows. Prior to 2.8.4 this included *CygWin*
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- APPLE : is TRUE on Apple systems. Note this does *not* imply the
|
|
|
system is Mac OS X, only that __APPLE__ is \#defined in C/C++
|
|
|
header files.
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- MINGW : is TRUE when using the MinGW compiler in Windows
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- MSYS : is TRUE when using the MSYS developer environment in Windows
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- CYGWIN : is TRUE on Windows when using the *CygWin* version of cmake
|
|
|
|
|
|
## CMake System
|
|
|
|
|
|
A cleaner and more cross-compiling-compatible way to check the current
|
|
|
platform is through the CMAKE_SYSTEM variables.
|
|
|
|
|
|
- CMAKE_SYSTEM : the complete system name, e.g. "Linux-2.4.22",
|
|
|
"FreeBSD-5.4-RELEASE" or "Windows 5.1"
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- CMAKE_SYSTEM_NAME : The name of the system targeted by the build. Unfortunately, these values depend on CMake's internal platform files, and are not documented anywhere. An incomplete list is below:
|
|
|
|
|
|
|Value|Environments Seen|
|
|
|
|---|---|
|
|
|
|`Windows`|Windows (Visual Studio, MinGW GCC)|
|
|
|
|`Darwin`|macOS/OS X (Clang, GCC)|
|
|
|
|`Linux`|Linux (GCC, Intel, PGI)|
|
|
|
|`Android`|Android NDK (GCC, Clang)|
|
|
|
|`FreeBSD`|FreeBSD|
|
|
|
|`CrayLinuxEnvironment`|Cray supercomputers (Cray compiler)|
|
|
|
|`MSYS`|Windows (MSYS2 shell native GCC)|
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- CMAKE_SYSTEM_VERSION : Version of the operating system. Generally
|
|
|
the *kernel* version.
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- CMAKE_SYSTEM_PROCESSOR : the processor name (e.g. "Intel(R)
|
|
|
Pentium(R) M processor 2.00GHz")
|
|
|
|
|
|
<!-- end list -->
|
|
|
|
|
|
- CMAKE_HOST_SYSTEM_NAME : The name of the system hosting the
|
|
|
build. Has the same possible values as **CMAKE_SYSTEM_NAME**. |
|
|
_content moved to [How to Write Platform Checks](doc/tutorials/How-To-Write-Platform-Checks)_ |
|
|
\ No newline at end of file |