2019-08-30 16:50:43 +00:00
if ( CMAKE_SYSTEM_NAME MATCHES "Linux" )
set ( OS_LINUX 1 )
2019-09-24 00:22:05 +00:00
add_definitions ( -D OS_LINUX )
2020-07-15 11:16:00 +00:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "Android" )
# This is a toy configuration and not in CI, so expect it to be broken.
# Use cmake flags such as: -DCMAKE_TOOLCHAIN_FILE=~/ch2/android-ndk-r21d/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DANDROID_PLATFORM=28
set ( OS_ANDROID 1 )
add_definitions ( -D OS_ANDROID )
2019-08-30 16:50:43 +00:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "FreeBSD" )
set ( OS_FREEBSD 1 )
2019-09-24 00:22:05 +00:00
add_definitions ( -D OS_FREEBSD )
2019-08-30 16:50:43 +00:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "Darwin" )
set ( OS_DARWIN 1 )
2019-09-24 00:22:05 +00:00
add_definitions ( -D OS_DARWIN )
2023-12-24 08:28:24 +00:00
# For MAP_ANON/MAP_ANONYMOUS
add_definitions ( -D _DARWIN_C_SOURCE )
2021-04-28 23:32:41 +00:00
elseif ( CMAKE_SYSTEM_NAME MATCHES "SunOS" )
set ( OS_SUNOS 1 )
add_definitions ( -D OS_SUNOS )
2022-05-10 08:54:48 +00:00
else ( )
message ( FATAL_ERROR "Platform ${CMAKE_SYSTEM_NAME} is not supported" )
2019-08-30 16:50:43 +00:00
endif ( )
2023-08-22 11:26:25 +00:00
# Since we always use toolchain files to generate hermetic builds, cmake will
# always think it's a cross-compilation, See
2023-08-21 10:05:52 +00:00
# https://cmake.org/cmake/help/latest/variable/CMAKE_CROSSCOMPILING.html
#
# This will slow down cmake configuration and compilation. For instance, LLVM
# will try to configure NATIVE LLVM targets with all tests enabled (You'll see
# Building native llvm-tblgen...).
#
2023-08-22 11:26:25 +00:00
# Here, we set it manually by checking the system name and processor.
2023-08-22 02:38:03 +00:00
if ( ${ CMAKE_SYSTEM_NAME } STREQUAL ${ CMAKE_HOST_SYSTEM_NAME } AND ${ CMAKE_SYSTEM_PROCESSOR } STREQUAL ${ CMAKE_HOST_SYSTEM_PROCESSOR } )
2023-08-21 10:05:52 +00:00
set ( CMAKE_CROSSCOMPILING 0 )
endif ( )
2019-08-30 16:50:43 +00:00
if ( CMAKE_CROSSCOMPILING )
2019-10-05 19:25:31 +00:00
if ( OS_DARWIN )
2019-09-25 18:51:09 +00:00
# FIXME: broken dependencies
2020-08-14 21:45:37 +00:00
set ( ENABLE_GRPC OFF CACHE INTERNAL "" ) # no protobuf -> no grpc
2019-10-05 19:25:31 +00:00
set ( ENABLE_ICU OFF CACHE INTERNAL "" )
set ( ENABLE_FASTOPS OFF CACHE INTERNAL "" )
2020-07-15 11:16:00 +00:00
elseif ( OS_LINUX OR OS_ANDROID )
2024-05-17 20:52:25 +00:00
if ( ARCH_PPC64LE )
2021-10-11 22:47:34 +00:00
set ( ENABLE_GRPC OFF CACHE INTERNAL "" )
2021-11-13 23:48:38 +00:00
elseif ( ARCH_RISCV64 )
2021-11-13 21:56:52 +00:00
# RISC-V support is preliminary
set ( GLIBC_COMPATIBILITY OFF CACHE INTERNAL "" )
set ( ENABLE_LDAP OFF CACHE INTERNAL "" )
set ( OPENSSL_NO_ASM ON CACHE INTERNAL "" )
set ( ENABLE_JEMALLOC ON CACHE INTERNAL "" )
set ( ENABLE_PARQUET OFF CACHE INTERNAL "" )
set ( ENABLE_GRPC OFF CACHE INTERNAL "" )
set ( ENABLE_HDFS OFF CACHE INTERNAL "" )
set ( ENABLE_MYSQL OFF CACHE INTERNAL "" )
2023-07-05 23:17:41 +00:00
# It might be ok, but we need to update 'sysroot'
set ( ENABLE_RUST OFF CACHE INTERNAL "" )
2023-02-17 21:18:30 +00:00
elseif ( ARCH_S390X )
set ( ENABLE_GRPC OFF CACHE INTERNAL "" )
2023-08-12 02:04:13 +00:00
set ( ENABLE_RUST OFF CACHE INTERNAL "" )
2024-03-15 03:11:24 +00:00
elseif ( ARCH_LOONGARCH64 )
set ( GLIBC_COMPATIBILITY OFF CACHE INTERNAL "" )
set ( ENABLE_LDAP OFF CACHE INTERNAL "" )
set ( OPENSSL_NO_ASM ON CACHE INTERNAL "" )
set ( ENABLE_JEMALLOC OFF CACHE INTERNAL "" )
set ( ENABLE_PARQUET OFF CACHE INTERNAL "" )
set ( ENABLE_GRPC OFF CACHE INTERNAL "" )
set ( ENABLE_HDFS OFF CACHE INTERNAL "" )
set ( ENABLE_MYSQL OFF CACHE INTERNAL "" )
set ( ENABLE_RUST OFF CACHE INTERNAL "" )
set ( ENABLE_LIBPQXX OFF CACHE INTERNAL "" )
set ( ENABLE_EMBEDDED_COMPILER OFF CACHE INTERNAL "" )
set ( ENABLE_DWARF_PARSER OFF CACHE INTERNAL "" )
set ( ENABLE_BLAKE3 OFF CACHE INTERNAL "" )
2019-10-30 07:01:53 +00:00
endif ( )
2020-04-07 08:33:49 +00:00
elseif ( OS_FREEBSD )
# FIXME: broken dependencies
2021-10-12 19:25:45 +00:00
set ( ENABLE_PARQUET OFF CACHE INTERNAL "" )
set ( ENABLE_ORC OFF CACHE INTERNAL "" )
2020-08-14 10:29:51 +00:00
set ( ENABLE_GRPC OFF CACHE INTERNAL "" )
2021-10-12 22:14:47 +00:00
set ( ENABLE_EMBEDDED_COMPILER OFF CACHE INTERNAL "" )
2023-10-17 00:00:07 +00:00
set ( ENABLE_DWARF_PARSER OFF CACHE INTERNAL "" )
2019-10-02 14:35:07 +00:00
else ( )
2019-10-30 07:01:53 +00:00
message ( FATAL_ERROR "Trying to cross-compile to unsupported system: ${CMAKE_SYSTEM_NAME}!" )
2019-08-30 16:50:43 +00:00
endif ( )
2019-09-11 10:01:38 +00:00
2024-07-05 14:31:00 +00:00
message ( STATUS "Cross-compiling for target: ${CMAKE_CXX_COMPILER_TARGET}" )
2019-08-30 16:50:43 +00:00
endif ( )