File: FindOS.cmake

package info (click to toggle)
sdformat 4.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 4,492 kB
  • ctags: 6,349
  • sloc: cpp: 26,300; python: 1,633; ruby: 217; ansic: 79; sh: 77; makefile: 18
file content (45 lines) | stat: -rw-r--r-- 1,440 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# Check the OS type.

# CMake does not distinguish Linux from other Unices.
STRING (REGEX MATCH "Linux" PLAYER_OS_LINUX ${CMAKE_SYSTEM_NAME})
# Nor *BSD
STRING (REGEX MATCH "BSD" PLAYER_OS_BSD ${CMAKE_SYSTEM_NAME})
# Or Solaris. I'm seeing a trend, here
STRING (REGEX MATCH "SunOS" PLAYER_OS_SOLARIS ${CMAKE_SYSTEM_NAME})

# Windows is easy (for once)
IF (WIN32)
    SET (PLAYER_OS_WIN TRUE BOOL INTERNAL)
ENDIF (WIN32)

# Check if it's an Apple OS
IF (APPLE)
    # Check if it's OS X or another MacOS (that's got to be pretty unlikely)
    STRING (REGEX MATCH "Darwin" PLAYER_OS_OSX ${CMAKE_SYSTEM_NAME})
    IF (NOT PLAYER_OS_OSX)
        SET (PLAYER_OS_MACOS TRUE BOOL INTERNAL)
    ENDIF (NOT PLAYER_OS_OSX)
ENDIF (APPLE)

# QNX
IF (QNXNTO)
    SET (PLAYER_OS_QNX TRUE BOOL INTERNAL)
ENDIF (QNXNTO)

IF (PLAYER_OS_LINUX)
    MESSAGE (STATUS "Operating system is Linux")
ELSEIF (PLAYER_OS_BSD)
    MESSAGE (STATUS "Operating system is BSD")
ELSEIF (PLAYER_OS_WIN)
    MESSAGE (STATUS "Operating system is Windows")
ELSEIF (PLAYER_OS_OSX)
    MESSAGE (STATUS "Operating system is Apple MacOS X")
ELSEIF (PLAYER_OS_MACOS)
    MESSAGE (STATUS "Operating system is Apple MacOS (not OS X)")
ELSEIF (PLAYER_OS_QNX)
    MESSAGE (STATUS "Operating system is QNX")
ELSEIF (PLAYER_OS_SOLARIS)
    MESSAGE (STATUS "Operating system is Solaris")
ELSE (PLAYER_OS_LINUX)
    MESSAGE (STATUS "Operating system is generic Unix")
ENDIF (PLAYER_OS_LINUX)