aboutsummaryrefslogtreecommitdiff
path: root/tools/depends/target/Toolchain.cmake.in
blob: 7b5ea6ab0e027ea613077eb68da0fa44d47f5275 (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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
set(DEPENDS_PATH "@prefix@/@deps_dir@")
set(NATIVEPREFIX "@prefix@/@tool_dir@")

set(OS "@platform_os@")
set(CMAKE_SYSTEM_PROCESSOR @host_cpu@)
set(CPU "@use_cpu@")
set(PLATFORM "@target_platform@")

# set CORE_SYSTEM_NAME and CMAKE_SYSTEM_NAME (sets CMAKE_CROSSCOMPILING)
if(OS STREQUAL linux)
  set(CMAKE_SYSTEM_NAME Linux)
  set(CORE_SYSTEM_NAME linux)
  if(PLATFORM STREQUAL raspberry-pi)
    set(CORE_PLATFORM_NAME rbpi)
    # wrapping libdvd fails with gold on rbpi
    # todo: revisit after toolchain bump
    set(ENABLE_LDGOLD OFF CACHE BOOL "Disabling Gnu Gold Linker" FORCE)
  elseif(NOT "@target_platform@" STREQUAL "")
    set(CORE_PLATFORM_NAME @target_platform@)
  endif()
  if(NOT "@app_rendersystem@" STREQUAL "")
    set(X11_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with X11: \"gl\" or \"gles\"")
    set(WAYLAND_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"")
    set(GBM_RENDER_SYSTEM @app_rendersystem@ CACHE STRING "Render system to use with GBM: \"gl\" or \"gles\"")
  else()
    set(X11_RENDER_SYSTEM gl CACHE STRING "Render system to use with X11: \"gl\" or \"gles\"")
    set(WAYLAND_RENDER_SYSTEM gl CACHE STRING "Render system to use with Wayland: \"gl\" or \"gles\"")
    set(GBM_RENDER_SYSTEM gles CACHE STRING "Render system to use with GBM: \"gl\" or \"gles\"")
  endif()
elseif(OS STREQUAL android)
  set(CMAKE_SYSTEM_NAME Android)
  set(CORE_SYSTEM_NAME android)
elseif(OS STREQUAL osx)
  set(CMAKE_SYSTEM_NAME Darwin)
  set(CORE_SYSTEM_NAME osx)
elseif(OS STREQUAL darwin_embedded)
  set(CMAKE_SYSTEM_NAME Darwin)
  set(CORE_SYSTEM_NAME darwin_embedded)
  if(PLATFORM STREQUAL appletvos)
    set(CORE_PLATFORM_NAME tvos)
  else()
    set(CORE_PLATFORM_NAME ios)
  endif()
endif()

if(CORE_SYSTEM_NAME STREQUAL darwin_embedded)
  # Necessary to build the main Application (but not other dependencies)
  # with Xcode (and a bundle with Makefiles) (https://cmake.org/Bug/view.php?id=15329)
  if(NOT PROJECT_SOURCE_DIR MATCHES "tools/depends")
    message(STATUS "Toolchain enabled ${CORE_PLATFORM_NAME} bundle for project ${PROJECT_NAME}")
    set(CMAKE_MACOSX_BUNDLE YES)
    set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGNING_REQUIRED "NO")
    # Need to set this attribute to "" in order to
    # complety disable code signing
    # see: https://gitlab.kitware.com/cmake/cmake/issues/19112
    set(CMAKE_XCODE_ATTRIBUTE_CODE_SIGN_IDENTITY "")
    if(CORE_PLATFORM_NAME STREQUAL tvos)
      set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "YES")
      set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "3")
      set(CMAKE_XCODE_ATTRIBUTE_TVOS_DEPLOYMENT_TARGET 11.0)
    else()
      # set this to YES once we have a deployment target of at least iOS 6.0
      set(CMAKE_XCODE_ATTRIBUTE_ENABLE_BITCODE "NO")
      set(CMAKE_XCODE_ATTRIBUTE_TARGETED_DEVICE_FAMILY "1,2")
      set(CMAKE_XCODE_ATTRIBUTE_IPHONEOS_DEPLOYMENT_TARGET 11.0)
    endif()
  endif()
endif()

if(CMAKE_SYSTEM_NAME STREQUAL Darwin)
  set(CMAKE_OSX_SYSROOT @use_sdk_path@)
  set(CMAKE_XCODE_ATTRIBUTE_ARCHS ${CPU})
endif()
set(CMAKE_SYSTEM_VERSION 1)

# specify the cross compiler
set(CMAKE_C_COMPILER @CC@)
set(CMAKE_CXX_COMPILER @CXX@)
set(CMAKE_AR @AR@ CACHE FILEPATH "Archiver")
set(CMAKE_LINKER @LD@ CACHE FILEPATH "Linker")
set(CMAKE_NM @NM@ CACHE FILEPATH "Nm")
set(CMAKE_STRIP @STRIP@ CACHE PATH "strip binary" FORCE)
set(CMAKE_OBJDUMP @OBJDUMP@ CACHE FILEPATH "Objdump")
set(CMAKE_RANLIB @RANLIB@ CACHE FILEPATH "Ranlib")

if(PROJECT_SOURCE_DIR MATCHES "tools/depends")
  if(@use_ccache@ STREQUAL "yes")
    set_property(GLOBAL PROPERTY RULE_LAUNCH_COMPILE "@CCACHE@")
  endif()
endif()

# where is the target environment
set(CMAKE_FIND_ROOT_PATH @prefix@/@deps_dir@)
set(CMAKE_LIBRARY_PATH @prefix@/@deps_dir@/lib)
if(NOT "@use_toolchain@" STREQUAL "")
  list(APPEND CMAKE_FIND_ROOT_PATH @use_toolchain@ @use_toolchain@/@use_host@ @use_toolchain@/@use_host@/sysroot @use_toolchain@/@use_host@/sysroot/usr @use_toolchain@/@use_host@/libc @use_toolchain@/lib/@use_host@/sysroot @use_toolchain@/usr @use_toolchain@/sysroot/usr)
  set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH}:@use_toolchain@/usr/lib/@use_host@:@use_toolchain@/lib/@use_host@")
endif()
if(NOT "@use_sdk_path@" STREQUAL "")
  list(APPEND CMAKE_FIND_ROOT_PATH @use_sdk_path@ @use_sdk_path@/usr)
endif()

# add RBPI's firmware directories
if(CORE_PLATFORM_NAME STREQUAL rbpi)
  list(APPEND CMAKE_FIND_ROOT_PATH @use_firmware@/opt/vc)
  list(APPEND CMAKE_LIBRARY_PATH @use_firmware@/opt/vc/lib)
  list(APPEND CMAKE_INCLUDE_PATH @use_firmware@/opt/vc/include)
endif()

# add Android directories and tools
if(CORE_SYSTEM_NAME STREQUAL android)
  set(NDKROOT @use_ndk_path@)
  set(SDKROOT @use_sdk_path@)
  set(TOOLCHAIN @use_toolchain@)
  set(HOST @use_host@)
  list(APPEND CMAKE_LIBRARY_PATH ${TOOLCHAIN}/sysroot/usr/lib/${HOST}/@use_ndk_api@)
  string(REPLACE ":" ";" SDK_BUILDTOOLS_PATH "@build_tools_path@")
endif()

set(CMAKE_C_FLAGS "@platform_cflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_CXX_FLAGS "@platform_cxxflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_C_FLAGS_RELEASE "@platform_cflags_release@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_CXX_FLAGS_RELEASE "@platform_cxxflags_release@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_C_FLAGS_DEBUG "@platform_cflags_debug@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_CXX_FLAGS_DEBUG "@platform_cxxflags_debug@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_CPP_FLAGS "@platform_cflags@ @platform_includes@ -isystem @prefix@/@deps_dir@/include")
set(CMAKE_EXE_LINKER_FLAGS "-L@prefix@/@deps_dir@/lib @platform_ldflags@")
set(ENV{CFLAGS} ${CMAKE_C_FLAGS})
set(ENV{CXXFLAGS} ${CMAKE_CXX_FLAGS})
set(ENV{CPPFLAGS} ${CMAKE_CPP_FLAGS})
set(ENV{LDFLAGS} ${CMAKE_EXE_LINKER_FLAGS})
# search for programs in the build host directories
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
# for libraries and headers in the target directories
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_FRAMEWORK LAST)
set(ENV{PKG_CONFIG_LIBDIR} @prefix@/@deps_dir@/lib/pkgconfig:@prefix@/@deps_dir@/share/pkgconfig)

# Binary Addons
if(NOT CORE_SYSTEM_NAME STREQUAL linux)
  set(ADDONS_PREFER_STATIC_LIBS ON)
endif()

set(KODI_DEPENDSBUILD 1)