aboutsummaryrefslogtreecommitdiff
path: root/cmake/scripts/osx/ArchSetup.cmake
blob: ec72737894d78a8d300e70ce1b72639a9ffc828f (plain)
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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
if(NOT CMAKE_TOOLCHAIN_FILE)
  message(FATAL_ERROR "CMAKE_TOOLCHAIN_FILE required for osx. See ${CMAKE_SOURCE_DIR}/cmake/README.md")
endif()

list(APPEND CORE_MAIN_SOURCE ${CMAKE_SOURCE_DIR}/xbmc/platform/darwin/osx/XBMCApplication.h)

set(ARCH_DEFINES -DTARGET_POSIX -DTARGET_DARWIN -DTARGET_DARWIN_OSX)
list(APPEND SYSTEM_DEFINES -D_REENTRANT -D_FILE_OFFSET_BITS=64 -D_LARGEFILE64_SOURCE
                           -D__STDC_CONSTANT_MACROS)
set(PLATFORM_DIR platform/darwin)
set(PLATFORMDEFS_DIR platform/posix)
set(CMAKE_SYSTEM_NAME Darwin)
if(WITH_ARCH)
  set(ARCH ${WITH_ARCH})
else()
  if(CPU STREQUAL x86_64 OR CPU STREQUAL i386)
    set(ARCH x86-osx)
    set(NEON False)
  elseif(CPU STREQUAL arm64)
    set(ARCH aarch64)
  else()
    message(SEND_ERROR "Unknown CPU: ${CPU}")
  endif()
endif()

# m1 macs can execute x86_64 code via rosetta
if(CMAKE_HOST_SYSTEM_PROCESSOR STREQUAL "arm64" AND
   CMAKE_HOST_SYSTEM_NAME STREQUAL "Darwin")
  set(HOST_CAN_EXECUTE_TARGET TRUE)
endif()

if(NOT TARBALL_DIR)
  set(TARBALL_DIR "/Users/Shared/xbmc-depends/xbmc-tarballs")
endif()

set(CMAKE_OSX_ARCHITECTURES ${CPU})

if(CMAKE_GENERATOR STREQUAL Xcode)
  set(DEBUG_POSTFIX d CACHE STRING "Debug library postfix.")
endif()

# Additional SYSTEM_DEFINES
list(APPEND SYSTEM_DEFINES -DHAS_POSIX_NETWORK -DHAS_OSX_NETWORK -DHAS_ZEROCONF)

list(APPEND CMAKE_SYSTEM_PREFIX_PATH ${NATIVEPREFIX})

list(APPEND DEPLIBS "-framework DiskArbitration" "-framework IOKit"
                    "-framework IOSurface" "-framework SystemConfiguration"
                    "-framework ApplicationServices" "-framework AppKit"
                    "-framework CoreAudio" "-framework AudioToolbox"
                    "-framework CoreGraphics" "-framework CoreMedia"
                    "-framework VideoToolbox" "-framework Security"
                    "-framework GameController")

if(ARCH STREQUAL aarch64)
  set(CMAKE_OSX_DEPLOYMENT_TARGET 11.0)
else()
  set(CMAKE_OSX_DEPLOYMENT_TARGET 10.13)
endif()
set(CMAKE_XCODE_ATTRIBUTE_CLANG_LINK_OBJC_RUNTIME OFF)

include(cmake/scripts/darwin/Macros.cmake)
enable_arc()