platform.inc 5.8 KB
Newer Older
1
CMAKE_MINIMUM_REQUIRED(VERSION 3.0...3.20)
S
[TD-58]  
slguan 已提交
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
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
  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)
24
  SET(TD_ALPINE 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
  #
  # Get OS information and store in variable TD_OS_INFO.
  #
  execute_process(COMMAND chmod 777 ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh)
39 40 41 42 43 44 45
  execute_process(COMMAND readlink /bin/sh OUTPUT_VARIABLE SHELL_LINK)
  MESSAGE(STATUS "The shell is: " ${SHELL_LINK})
  IF (${SHELL_LINK} MATCHES "dash")
    execute_process(COMMAND ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO)
  ELSE ()
    execute_process(COMMAND sh ${TD_COMMUNITY_DIR}/packaging/tools/get_os.sh "" OUTPUT_VARIABLE TD_OS_INFO)
  ENDIF()
S
slguan 已提交
46 47
  MESSAGE(STATUS "The current os is " ${TD_OS_INFO})

S
Shengliang Guan 已提交
48
  SET(TD_LINUX TRUE)
S
[TD-58]  
slguan 已提交
49 50 51 52
  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 已提交
53
    SET(TD_LINUX_32 TRUE)
S
TD-1057  
Shengliang Guan 已提交
54
    MESSAGE(STATUS "The current platform is Linux 32-bit")
S
[TD-58]  
slguan 已提交
55 56 57 58
  ELSE ()
    MESSAGE(FATAL_ERROR "The current platform is Linux neither 32-bit nor 64-bit, not supported yet")
    EXIT ()
  ENDIF ()
S
Shengliang Guan 已提交
59 60

  IF (${TD_OS_INFO} MATCHES "Alpine")
61 62 63 64 65 66
    SET(TD_ALPINE TRUE)
    MESSAGE(STATUS "The current OS is Alpine Linux, append extra flags")
  ELSEIF (${TD_OS_INFO} MATCHES "Arch")
    SET(TD_ARCHLINUX TRUE)
    MESSAGE(STATUS "The current OS is Arch Linux")
  ELSE ()
67
    MESSAGE(STATUS "The distro is " ${TD_OS_INFO})
S
Shengliang Guan 已提交
68
  ENDIF()
S
[TD-58]  
slguan 已提交
69
ELSEIF (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
S
TD-1057  
Shengliang Guan 已提交
70
  SET(TD_DARWIN TRUE)
S
[TD-58]  
slguan 已提交
71 72 73 74 75 76 77 78
  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 已提交
79
  SET(TD_WINDOWS TRUE)
S
[TD-58]  
slguan 已提交
80 81 82 83
  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 已提交
84
    SET(TD_WINDOWS_32 TRUE)
S
TD-1090  
Shengliang Guan 已提交
85
    MESSAGE(STATUS "The current platform is Windows 32-bit")
S
[TD-58]  
slguan 已提交
86 87 88 89 90
  ENDIF ()
ELSE()
  MESSAGE(FATAL_ERROR "The current platform is not Linux/Darwin/Windows, stop compile")
  EXIT ()
ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
91

92
IF ("${CPUTYPE}" STREQUAL "")
93
  MESSAGE(STATUS "The current platform " ${CMAKE_SYSTEM_PROCESSOR} " is detected")
94 95 96 97 98

  IF (CMAKE_SYSTEM_PROCESSOR MATCHES "(amd64)|(AMD64)")
    MESSAGE(STATUS "The current platform is amd64")
    MESSAGE(STATUS "Set CPUTYPE to x64")
    SET(CPUTYPE "x64")
99
    SET(PLATFORM_ARCH_STR "amd64")
100
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)")
101
    MESSAGE(STATUS "The current platform is x86")
102 103
    MESSAGE(STATUS "Set CPUTYPE to x86")
    SET(CPUTYPE "x32")
104
    SET(PLATFORM_ARCH_STR "i386")
105
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "armv7l")
106
    MESSAGE(STATUS "Set CPUTYPE to aarch32")
107
    SET(CPUTYPE "aarch32")
108
    MESSAGE(STATUS "Set CPUTYPE to aarch32")
109 110 111
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_32 FALSE)
    SET(TD_ARM_32 TRUE)
112
    SET(PLATFORM_ARCH_STR "arm")
113
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "aarch64")
114
    SET(CPUTYPE "aarch64")
115
    MESSAGE(STATUS "Set CPUTYPE to aarch64")
116 117 118
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_ARM_64 TRUE)
119
    SET(PLATFORM_ARCH_STR "arm64")
120 121 122 123 124 125
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "mips64")
    SET(CPUTYPE "mips64")
    MESSAGE(STATUS "Set CPUTYPE to mips64")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_MIPS_64 TRUE)
126 127 128 129
  ELSEIF (CMAKE_SYSTEM_PROCESSOR MATCHES "arm64")
    SET(CPUTYPE "apple_m1")
    MESSAGE(STATUS "Set CPUTYPE to apple silicon m1")
    SET(TD_ARM_64 TRUE)
130
  ENDIF ()
131 132 133 134 135 136 137
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)
138
    SET(PLATFORM_ARCH_STR "arm")
139 140 141 142 143
    MESSAGE(STATUS "input cpuType: aarch32")
  ELSEIF (${CPUTYPE} MATCHES "aarch64")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_ARM_64 TRUE)
144
    SET(PLATFORM_ARCH_STR "arm64")
145 146 147 148 149
    MESSAGE(STATUS "input cpuType: aarch64")
  ELSEIF (${CPUTYPE} MATCHES "mips64")
    SET(TD_LINUX TRUE)
    SET(TD_LINUX_64 FALSE)
    SET(TD_MIPS_64 TRUE)
150
    SET(PLATFORM_ARCH_STR "mips")
151 152
    MESSAGE(STATUS "input cpuType: mips64")
  ELSEIF (${CPUTYPE} MATCHES "x64")
153
    SET(PLATFORM_ARCH_STR "amd64")
154 155
    MESSAGE(STATUS "input cpuType: x64")
  ELSEIF (${CPUTYPE} MATCHES "x86")
156
    SET(PLATFORM_ARCH_STR "i386")
157 158 159 160
    MESSAGE(STATUS "input cpuType: x86")
  ELSE ()
    MESSAGE(STATUS "input cpuType unknown " ${CPUTYPE})
  ENDIF ()
S
TD-1057  
Shengliang Guan 已提交
161
ENDIF ()
H
Hui Li 已提交
162

163 164
MESSAGE(STATUS "platform arch:" ${PLATFORM_ARCH_STR})

H
Hui Li 已提交
165 166 167 168 169 170 171 172 173 174 175
#   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 已提交
176 177
ELSEIF (${OSTYPE} MATCHES "Alpine")
  MESSAGE(STATUS "input osType: Alpine")
178
  SET(TD_ALPINE TRUE)
H
Hui Li 已提交
179
ELSE ()
180
  MESSAGE(STATUS "The user specified osType is unknown: " ${OSTYPE})
H
Hui Li 已提交
181
ENDIF ()