1 # ---------------------------------------------------------------------------
3 # Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
4 # ---------------------------------------------------------------------------
5 # SquirrelJME is under the Mozilla Public License Version 2.0.
6 # See license.mkd for licensing and copyright information.
7 # ---------------------------------------------------------------------------
8 # DESCRIPTION: Platform information
10 # Determine the host platform, if not set
11 if(NOT DEFINED SQUIRRELJME_HOST_PLATFORM)
12 squirreljme_util(platformExePath platform)
13 execute_process(COMMAND "${platformExePath}" "-p"
14 OUTPUT_VARIABLE SQUIRRELJME_HOST_PLATFORM
15 ERROR_VARIABLE platformExeIgnore
17 execute_process(COMMAND "${platformExePath}" "-a"
18 OUTPUT_VARIABLE SQUIRRELJME_HOST_ARCH
19 ERROR_VARIABLE platformExeIgnore
23 # Some compile definitions which may shine light on the target platform
24 string(FIND "${COMPILE_DEFINITIONS}" "-D_3DS"
25 SQUIRRELJME_CHECK_CDEF_3DS)
28 if(NOT DEFINED SQUIRRELJME_ARCH)
29 message(STATUS "Input CPU: ${CMAKE_SYSTEM_PROCESSOR}")
31 if("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "AMD64" OR
32 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "EM64T" OR
33 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86_64" OR
34 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86-64" OR
35 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "amd64")
36 set(SQUIRRELJME_ARCH "amd64")
37 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv6k" OR
38 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm32" OR
39 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armel" OR
40 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armbe" OR
41 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm" OR
42 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "armv5l" OR
43 "${SQUIRRELJME_CHECK_CDEF_3DS}" GREATER_EQUAL 0)
44 set(SQUIRRELJME_ARCH "arm32")
45 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "arm64" OR
46 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64" OR
47 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "aarch64_be")
48 set(SQUIRRELJME_ARCH "arm64")
49 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i286" OR
50 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "I86" OR
51 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ia16")
52 set(SQUIRRELJME_ARCH "ia16")
53 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i386" OR
54 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i486" OR
55 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i586" OR
56 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "i686" OR
57 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "X86" OR
58 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "x86" OR
59 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ia32")
60 set(SQUIRRELJME_ARCH "ia32")
61 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "IA64" OR
62 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ia64" OR
63 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Itanium" OR
64 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "Itanic")
65 set(SQUIRRELJME_ARCH "ia64")
66 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips" OR
67 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mipsel" OR
68 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mipseb" OR
69 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips32" OR
70 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips32el" OR
71 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips32eb")
72 set(SQUIRRELJME_ARCH "mips32")
73 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips64" OR
74 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips64el" OR
75 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "mips64eb")
76 set(SQUIRRELJME_ARCH "mips64")
77 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc" OR
78 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "powerpc")
79 set(SQUIRRELJME_ARCH "powerpc32")
80 elseif("${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "ppc64" OR
81 "${CMAKE_SYSTEM_PROCESSOR}" STREQUAL "powerpc64")
82 set(SQUIRRELJME_ARCH "powerpc64")
84 set(SQUIRRELJME_ARCH "${SQUIRRELJME_HOST_ARCH}")
88 # Determine the platform we are targeting
89 # https://cmake.org/cmake/help/latest/variable/CMAKE_SYSTEM_NAME.html
90 if(NOT DEFINED SQUIRRELJME_PLATFORM)
91 message(STATUS "Input Platform: ${CMAKE_SYSTEM_NAME}")
93 if("${SQUIRRELJME_CHECK_CDEF_3DS}" GREATER_EQUAL 0)
94 set(SQUIRRELJME_PLATFORM "3ds")
95 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "BeOS")
96 set(SQUIRRELJME_PLATFORM "beos")
97 elseif(BSD OR CMAKE_SYSTEM_NAME STREQUAL "FreeBSD" OR
98 CMAKE_SYSTEM_NAME STREQUAL "OpenBSD" OR
99 CMAKE_SYSTEM_NAME STREQUAL "NetBSD")
100 set(SQUIRRELJME_PLATFORM "bsd")
101 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "CYGWIN" OR
102 "${CMAKE_SYSTEM_NAME}" STREQUAL "MSYS2")
103 set(SQUIRRELJME_PLATFORM "cygwin")
104 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "DOS")
105 set(SQUIRRELJME_PLATFORM "dos")
106 elseif(EMSCRIPTEN OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Emscripten")
107 set(SQUIRRELJME_PLATFORM "emscripten")
108 elseif(LINUX OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Linux")
109 set(SQUIRRELJME_PLATFORM "linux")
110 elseif(APPLE OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Darwin")
111 set(SQUIRRELJME_PLATFORM "macosx")
112 elseif(WIN32 OR "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
113 if("${SQUIRRELJME_ARCH}" STREQUAL "ia16")
114 set(SQUIRRELJME_PLATFORM "win16")
116 set(SQUIRRELJME_PLATFORM "win32")
118 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "WindowsCE")
119 set(SQUIRRELJME_PLATFORM "wince")
120 elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Generic")
121 set(SQUIRRELJME_PLATFORM "unknown")
123 set(SQUIRRELJME_PLATFORM "${SQUIRRELJME_HOST_PLATFORM}")
127 if (NOT "${SQUIRRELJME_HOST_PLATFORM}" STREQUAL "${SQUIRRELJME_PLATFORM}" OR
128 NOT "${SQUIRRELJME_HOST_ARCH}" STREQUAL "${SQUIRRELJME_ARCH}")
129 set(SQUIRRELJME_IS_CROSS_COMPILE YES)
131 set(SQUIRRELJME_IS_CROSS_COMPILE NO)
134 # It's a UNIX system! I know this!
135 if(SQUIRRELJME_PLATFORM STREQUAL "bsd" OR
136 SQUIRRELJME_PLATFORM STREQUAL "linux" OR
137 SQUIRRELJME_PLATFORM STREQUAL "macosx")
138 set(SQUIRRELJME_IS_UNIX YES)
140 set(SQUIRRELJME_IS_UNIX NO)
143 # It's a Windows system? Must be another flavor of UNIX!
144 if(SQUIRRELJME_HOST_PLATFORM STREQUAL "win16" OR
145 SQUIRRELJME_HOST_PLATFORM STREQUAL "win32" OR
146 SQUIRRELJME_HOST_PLATFORM STREQUAL "wince")
147 set(SQUIRRELJME_IS_WINDOWS YES)
149 set(SQUIRRELJME_IS_WINDOWS NO)
152 # Is this RetroArch? Any kind of RetroArch build?
153 if(RETROARCH OR ENV{RETROARCH} OR
154 LIBRETRO_STATIC OR ENV{LIBRETRO_STATIC} OR
155 LIBRETRO_SUFFIX OR ENV{LIBRETRO_SUFFIX} OR
157 set(SQUIRRELJME_IS_LIBRETRO YES)
159 set(SQUIRRELJME_IS_LIBRETRO NO)
163 message(STATUS "Host: ${SQUIRRELJME_HOST_PLATFORM}/${SQUIRRELJME_HOST_ARCH}")
164 message(STATUS "Target: ${SQUIRRELJME_PLATFORM}/${SQUIRRELJME_ARCH}")
165 message(STATUS "Cross Compiled? ${SQUIRRELJME_IS_CROSS_COMPILE}")
166 message(STATUS "Is UNIX? ${SQUIRRELJME_IS_UNIX}")
167 message(STATUS "Is Windows? ${SQUIRRELJME_IS_WINDOWS}")
168 message(STATUS "Is libretro? ${SQUIRRELJME_IS_LIBRETRO}")
171 ## Dynamic libraries?
172 if("${SQUIRRELJME_PLATFORM}" STREQUAL "dos" OR
173 "${SQUIRRELJME_PLATFORM}" STREQUAL "emscripten" OR
174 "${SQUIRRELJME_PLATFORM}" STREQUAL "palmos" OR
175 "${SQUIRRELJME_PLATFORM}" STREQUAL "wince" OR
176 LIBRETRO_STATIC OR ENV{LIBRETRO_STATIC})
177 set(SQUIRRELJME_ENABLE_DYLIB_DEFAULT OFF)
179 set(SQUIRRELJME_ENABLE_DYLIB_DEFAULT ON)
183 if("${SQUIRRELJME_PLATFORM}" STREQUAL "dos" OR
184 "${SQUIRRELJME_PLATFORM}" STREQUAL "classicmac" OR
185 "${SQUIRRELJME_PLATFORM}" STREQUAL "emscripten" OR
186 "${SQUIRRELJME_PLATFORM}" STREQUAL "palmos" OR
187 "${SQUIRRELJME_PLATFORM}" STREQUAL "wince" OR
188 "${SQUIRRELJME_ARCH}" STREQUAL "ia16")
189 set(SQUIRRELJME_ENABLE_LUA_DEFAULT OFF)
191 set(SQUIRRELJME_ENABLE_LUA_DEFAULT ON)
194 ## Netscape JRI Interface?
195 if(SQUIRRELJME_ENABLE_DYLIB_DEFAULT AND
196 ("${SQUIRRELJME_PLATFORM}" STREQUAL "classicmac" OR
197 "${SQUIRRELJME_PLATFORM}" STREQUAL "win16"))
198 set(SQUIRRELJME_ENABLE_FRONTEND_JRI_DEFAULT ON)
200 set(SQUIRRELJME_ENABLE_FRONTEND_JRI_DEFAULT OFF)
204 if("${SQUIRRELJME_ARCH}" STREQUAL "ia16" OR
205 "${SQUIRRELJME_PLATFORM}" STREQUAL "classicmac" OR
206 "${SQUIRRELJME_PLATFORM}" STREQUAL "palmos" OR
207 "${SQUIRRELJME_PLATFORM}" STREQUAL "win16" OR
208 "${SQUIRRELJME_PLATFORM}" STREQUAL "wince")
209 set(SQUIRRELJME_ENABLE_FRONTEND_LIBRETRO_DEFAULT OFF)
211 set(SQUIRRELJME_ENABLE_FRONTEND_LIBRETRO_DEFAULT ON)
215 if(SQUIRRELJME_IS_CROSS_COMPILE OR
216 ${CMAKE_VERSION} VERSION_LESS_EQUAL "3.12")
217 set(SQUIRRELJME_ENABLE_TESTING_DEFAULT OFF)
219 set(SQUIRRELJME_ENABLE_TESTING_DEFAULT ON)
224 set(SQUIRRELJME_ENABLE_FPIC_DEFAULT OFF)
226 set(SQUIRRELJME_ENABLE_FPIC_DEFAULT ON)
229 # Option flags which are available
230 option(SQUIRRELJME_ENABLE_DYLIB "Enable Dynamic Libraries"
231 ${SQUIRRELJME_ENABLE_DYLIB_DEFAULT})
232 option(SQUIRRELJME_ENABLE_FPIC "Enable FPIC"
233 ${SQUIRRELJME_ENABLE_FPIC_DEFAULT})
234 option(SQUIRRELJME_ENABLE_FRONTEND_JRI "Enable Front End: JRI"
235 ${SQUIRRELJME_ENABLE_FRONTEND_JRI_DEFAULT})
236 option(SQUIRRELJME_ENABLE_FRONTEND_LIBRETRO "Enable Front End: LibRetro"
237 ${SQUIRRELJME_ENABLE_FRONTEND_LIBRETRO_DEFAULT})
238 option(SQUIRRELJME_ENABLE_LUA "Enable Lua"
239 ${SQUIRRELJME_ENABLE_LUA_DEFAULT})
240 option(SQUIRRELJME_ENABLE_TESTING "Enable Host System Tests"
241 ${SQUIRRELJME_ENABLE_TESTING_DEFAULT})
244 message(STATUS "ENABLE_DYLIB: ${SQUIRRELJME_ENABLE_DYLIB}")
245 message(STATUS "ENABLE_FPIC: ${SQUIRRELJME_ENABLE_FPIC}")
246 message(STATUS "ENABLE_FRONTEND_JRI: ${SQUIRRELJME_ENABLE_FRONTEND_JRI}")
247 message(STATUS "ENABLE_FRONTEND_LIBRETRO: ${SQUIRRELJME_ENABLE_FRONTEND_LIBRETRO}")
248 message(STATUS "ENABLE_LUA: ${SQUIRRELJME_ENABLE_LUA}")
249 message(STATUS "ENABLE_TESTING: ${SQUIRRELJME_ENABLE_TESTING}")