platform.inc 4.6 KB
Newer Older
S
[TD-58]  
slguan 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
PROJECT(TDengine)

#
# If it is a Windows operating system
#   1.Use command line tool of VS2013 or higher version
#     mkdir build; cd build;
#     cmake -G "NMake Makefiles" ..
#     nmake install
#   2.Use the VS development interface tool
#     mkdir build; cd build;
#     cmake -A x64 ..
#     open the file named TDengine.sln
#

# Set macro definitions according to os platform
S
Shengliang Guan 已提交
17
SET(TD_LINUX FALSE)
S
TD-1057  
Shengliang Guan 已提交
18 19 20 21 22 23 24
  SET(TD_LINUX_64 FALSE)
  SET(TD_LINUX_32 FALSE)
  SET(TD_ARM_64 FALSE)
  SET(TD_ARM_32 FALSE)
  SET(TD_MIPS_64 FALSE)
  SET(TD_MIPS_32 FALSE)
  SET(TD_APLHINE FALSE)
H
Hui Li 已提交
25 26 27
  SET(TD_NINGSI FALSE)
  SET(TD_NINGSI_60 FALSE)
  SET(TD_NINGSI_80 FALSE)
S
Shengliang Guan 已提交
28
SET(TD_WINDOWS FALSE)
S
TD-1057  
Shengliang Guan 已提交
29 30 31 32
  SET(TD_WINDOWS_64 FALSE)
  SET(TD_WINDOWS_32 FALSE)
SET(TD_DARWIN FALSE)
  SET(TD_DARWIN_64 FALSE)
S
[TD-58]  
slguan 已提交
33 34

IF (${CMAKE_SYSTEM_NAME} MATCHES "Linux")
S
slguan 已提交
35 36 37 38 39 40 41
  #
  # Get OS information and store in variable TD_OS_INFO.
  #
  execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh)
  execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO)
  MESSAGE(STATUS "The current os is " ${TD_OS_INFO})

S
Shengliang Guan 已提交
42
  SET(TD_LINUX TRUE)
S
[TD-58]  
slguan 已提交
43 44 45 46
  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    SET(TD_LINUX_64 TRUE)
    MESSAGE(STATUS "The current platform is Linux 64-bit")
  ELSEIF (${CMAKE_SIZEOF_VOID_P} MATCHES 4)
S
Shengliang Guan 已提交
47
    SET(TD_LINUX_32 TRUE)
S
TD-1057  
Shengliang Guan 已提交
48
    MESSAGE(STATUS "The current platform is Linux 32-bit")
S
[TD-58]  
slguan 已提交
49 50 51 52
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet")
    EXIT ()
  ENDIF ()
S
Shengliang Guan 已提交
53 54 55 56 57

  IF (${TD_OS_INFO} MATCHES "Alpine")
    SET(TD_APLHINE TRUE)
    MESSAGE(STATUS "The current OS is Alpine, append extra flags")
  ENDIF()
S
[TD-58]  
slguan 已提交
58
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
S
TD-1057  
Shengliang Guan 已提交
59
  SET(TD_DARWIN TRUE)
S
[TD-58]  
slguan 已提交
60 61 62 63 64 65 66 67
  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    SET(TD_DARWIN_64 TRUE)
    MESSAGE(STATUS "The current platform is Darwin 64-bit")
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Darwin 32-bit, not supported yet")
    EXIT ()
  ENDIF ()
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Windows")
S
Shengliang Guan 已提交
68
  SET(TD_WINDOWS TRUE)
S
[TD-58]  
slguan 已提交
69 70 71 72
  IF (${CMAKE_SIZEOF_VOID_P} MATCHES 8)
    SET(TD_WINDOWS_64 TRUE)
    MESSAGE(STATUS "The current platform is Windows 64-bit")
  ELSE ()
S
Shengliang Guan 已提交
73
    SET(TD_WINDOWS_32 TRUE)
S
TD-1090  
Shengliang Guan 已提交
74
    MESSAGE(STATUS "The current platform is Windows 32-bit")
S
[TD-58]  
slguan 已提交
75 76 77 78 79
  ENDIF ()
ELSE()
  MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile")
  EXIT ()
ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
80

81
IF ("${CPUTYPE}" STREQUAL "")
82
  MESSAGE(STATUS "The current platform " ${CMAKE_SYSTEM_PROCESSOR} " is detected")
83 84 85 86 87 88

  IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
    MESSAGE(STATUS "The current platform is amd64")
    MESSAGE(STATUS "Set CPUTYPE to x64")
    SET(CPUTYPE "x64")
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
89
    MESSAGE(STATUS "The current platform is x86")
90 91
    MESSAGE(STATUS "Set CPUTYPE to x86")
    SET(CPUTYPE "x32")
92
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
93
    MESSAGE(STATUS "Set CPUTYPE to aarch32")
94
    SET(CPUTYPE "aarch32")
95
    MESSAGE(STATUS "Set CPUTYPE to aarch32")
96 97 98
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_32 FALSE)
    SET(TD_ARM_32 TRUE)
99
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
100
    SET(CPUTYPE "aarch64")
101
    MESSAGE(STATUS "Set CPUTYPE to aarch64")
102 103 104
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_ARM_64 TRUE)
105 106
  ENDIF ()

107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132
ELSE ()
  # if generate ARM version:
  #   cmake -DCPUTYPE=aarch32 .. or cmake -DCPUTYPE=aarch64
  IF (${CPUTYPE} MATCHES "aarch32")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_32 FALSE)
    SET(TD_ARM_32 TRUE)
    MESSAGE(STATUS "input cpuType: aarch32")
  ELSEIF (${CPUTYPE} MATCHES "aarch64")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_ARM_64 TRUE)
    MESSAGE(STATUS "input cpuType: aarch64")
  ELSEIF (${CPUTYPE} MATCHES "mips64")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_MIPS_64 TRUE)
    MESSAGE(STATUS "input cpuType: mips64")
  ELSEIF (${CPUTYPE} MATCHES "x64")
    MESSAGE(STATUS "input cpuType: x64")
  ELSEIF (${CPUTYPE} MATCHES "x86")
    MESSAGE(STATUS "input cpuType: x86")
  ELSE ()
    MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE})
  ENDIF ()
  
S
TD-1057  
Shengliang Guan 已提交
133
ENDIF ()
H
Hui Li 已提交
134 135 136 137 138 139 140 141 142 143 144 145

#   cmake -DOSTYPE=Ningsi
IF (${OSTYPE} MATCHES "Ningsi60")
  SET(TD_NINGSI TRUE)
  SET(TD_NINGSI_60 TRUE)
  MESSAGE(STATUS "input osType: Ningsi60")
ELSEIF (${OSTYPE} MATCHES "Ningsi80")
  SET(TD_NINGSI TRUE)
  SET(TD_NINGSI_80 TRUE)
  MESSAGE(STATUS "input osType: Ningsi80")
ELSEIF (${OSTYPE} MATCHES "Linux")
  MESSAGE(STATUS "input osType: Linux")
H
Hui Li 已提交
146 147 148
ELSEIF (${OSTYPE} MATCHES "Alpine")
  MESSAGE(STATUS "input osType: Alpine")
  SET(TD_APLHINE TRUE)
H
Hui Li 已提交
149 150
ELSE ()
  MESSAGE(STATUS "input osType unknown: " ${OSTYPE})
H
Hui Li 已提交
151
ENDIF ()