aboutsummaryrefslogtreecommitdiff
path: root/contrib/depends/toolchain.cmake.in
blob: 50eaaa59373fb8bf026e0a8397b7d8966cbfa696 (plain) (blame)
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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
# Set the system name to one of Android, Darwin, FreeBSD, Linux, or Windows
SET(CMAKE_SYSTEM_NAME @cmake_system_name@)
SET(CMAKE_SYSTEM_PROCESSOR @arch@)
SET(CMAKE_BUILD_TYPE @release_type@)

OPTION(STATIC "Link libraries statically" ON)
OPTION(TREZOR_DEBUG "Main trezor debugging switch" OFF)
OPTION(BUILD_TESTS "Build tests." OFF)

SET(STATIC ON)
SET(UNBOUND_STATIC ON)
SET(ARCH "default")

SET(BUILD_TESTS @build_tests@)
SET(TREZOR_DEBUG @build_tests@)

# where is the target environment 
SET(CMAKE_FIND_ROOT_PATH @prefix@ /usr)

SET(ENV{PKG_CONFIG_PATH} @prefix@/lib/pkgconfig)

SET(Readline_ROOT_DIR @prefix@)
SET(Readline_INCLUDE_DIR @prefix@/include)
SET(Readline_LIBRARY @prefix@/lib/libreadline.a)
SET(Terminfo_LIBRARY @prefix@/lib/libtinfo.a)

SET(UNBOUND_INCLUDE_DIR @prefix@/include)
SET(UNBOUND_LIBRARIES @prefix@/lib/libunbound.a)

SET(LIBUSB-1.0_LIBRARY @prefix@/lib/libusb-1.0.a)
SET(LIBUDEV_LIBRARY @prefix@/lib/libudev.a)

SET(Protobuf_FOUND 1)
SET(Protobuf_PROTOC_EXECUTABLE @prefix@/native/bin/protoc CACHE FILEPATH "Path to the native protoc")
SET(Protobuf_INCLUDE_DIR @prefix@/include CACHE PATH "Protobuf include dir")
SET(Protobuf_INCLUDE_DIRS @prefix@/include CACHE PATH "Protobuf include dir")
SET(Protobuf_LIBRARY @prefix@/lib/libprotobuf.a CACHE FILEPATH "Protobuf library")

if(NOT CMAKE_SYSTEM_NAME STREQUAL "Android")
SET(LIBUNWIND_INCLUDE_DIR @prefix@/include)
SET(LIBUNWIND_LIBRARIES @prefix@/lib/libunwind.a)
SET(LIBUNWIND_LIBRARY_DIRS @prefix@/lib)
endif()

SET(ZMQ_INCLUDE_PATH @prefix@/include)
SET(ZMQ_LIB @prefix@/lib/libzmq.a)

SET(Boost_IGNORE_SYSTEM_PATH ON)
SET(BOOST_ROOT @prefix@)
SET(BOOST_INCLUDEDIR @prefix@/include)
SET(BOOST_LIBRARYDIR @prefix@/lib)
SET(Boost_IGNORE_SYSTEM_PATHS_DEFAULT OFF)
SET(Boost_NO_SYSTEM_PATHS ON)
SET(Boost_USE_STATIC_LIBS ON)
SET(Boost_USE_STATIC_RUNTIME ON)

SET(OPENSSL_ROOT_DIR @prefix@)
SET(ARCHITECTURE @arch@)

# for libraries and headers in the target directories
set (CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) # Find programs on host
set (CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) # Find libs in target
set (CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) # Find includes in target

# specify the cross compiler to be used. Darwin uses clang provided by the SDK.
if(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
  if(ARCHITECTURE STREQUAL "aarch64")
    SET(CLANG_TARGET "arm64-apple-darwin")
    SET(CONF_TRIPLE "aarch64-apple-darwin")
    SET(BUILD_TAG "mac-armv8")
    SET(CMAKE_OSX_ARCHITECTURES "arm64")
    set(ARM ON)
    set(ARM_ID "armv8-a")
  else()
    SET(CLANG_TARGET "x86_64-apple-darwin")
    SET(CONF_TRIPLE "x86_64-apple-darwin")
    SET(BUILD_TAG "mac-x64")
    SET(CMAKE_OSX_ARCHITECTURES "x86_64")
  endif()
  SET(_CMAKE_TOOLCHAIN_PREFIX @prefix@/native/bin/${CONF_TRIPLE}-)
  SET(CMAKE_C_COMPILER @prefix@/native/bin/clang)
  SET(CMAKE_C_COMPILER_TARGET ${CLANG_TARGET})
  SET(CMAKE_C_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
  SET(CMAKE_CXX_COMPILER @prefix@/native/bin/clang++ -stdlib=libc++)
  SET(CMAKE_CXX_COMPILER_TARGET ${CLANG_TARGET})
  SET(CMAKE_CXX_FLAGS_INIT -B${_CMAKE_TOOLCHAIN_PREFIX})
  SET(CMAKE_ASM_COMPILER_TARGET ${CLANG_TARGET})
  SET(CMAKE_ASM-ATT_COMPILER_TARGET ${CLANG_TARGET})
  SET(APPLE True)
  SET(BUILD_64 ON)
  SET(BREW OFF)
  SET(PORT OFF)
  SET(CMAKE_OSX_SYSROOT "@prefix@/native/SDK/")
  SET(CMAKE_OSX_DEPLOYMENT_TARGET "10.13")
  SET(CMAKE_CXX_STANDARD 17)
  SET(LLVM_ENABLE_PIC OFF)
  SET(LLVM_ENABLE_PIE OFF)
elseif(CMAKE_SYSTEM_NAME STREQUAL "Android")
  SET(ANDROID TRUE)
  if(ARCHITECTURE STREQUAL "arm")
    SET(CMAKE_ANDROID_ARCH_ABI "armeabi-v7a")
    SET(CMAKE_SYSTEM_PROCESSOR "armv7-a")
    SET(CMAKE_ANDROID_ARM_MODE ON)
    SET(CMAKE_C_COMPILER_TARGET arm-linux-androideabi)
    SET(CMAKE_CXX_COMPILER_TARGET arm-linux-androideabi)
    SET(_CMAKE_TOOLCHAIN_PREFIX arm-linux-androideabi-)
  elseif(ARCHITECTURE STREQUAL "aarch64")
    SET(CMAKE_ANDROID_ARCH_ABI "arm64-v8a")
    SET(CMAKE_SYSTEM_PROCESSOR "aarch64")
  endif()
  SET(CMAKE_ANDROID_STANDALONE_TOOLCHAIN @prefix@/native)
  SET(CMAKE_C_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang")
  SET(CMAKE_CXX_COMPILER "${_CMAKE_TOOLCHAIN_PREFIX}clang++")
else()
  SET(CMAKE_C_COMPILER @CC@)
  SET(CMAKE_CXX_COMPILER @CXX@)
endif()

if(ARCHITECTURE STREQUAL "arm")
  set(ARCH "armv7-a")
  set(ARM ON)
  set(ARM_ID "armv7-a")
  set(BUILD_64 OFF)
  set(CMAKE_BUILD_TYPE release)
  if(ANDROID)
    set(BUILD_TAG "android-armv7")
  else()
    set(BUILD_TAG "linux-armv7")
  endif()
  set(ARM7)
elseif(ARCHITECTURE STREQUAL "aarch64")
  set(ARCH "armv8-a")
  set(ARM ON)
  set(ARM_ID "armv8-a")
  if(ANDROID)
    set(BUILD_TAG "android-armv8")
  elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(BUILD_TAG "linux-armv8")
  endif()
  set(BUILD_64 ON)
endif()

if(ARCHITECTURE STREQUAL "riscv64")
  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(BUILD_TAG "linux-riscv64")
  endif()
  set(ARCH_ID "riscv64")
  set(ARCH "rv64gc")
endif()
if(ARCHITECTURE STREQUAL "loongarch64")
    set(ARCH_ID "loongarch64")
    set(ARCH "loongarch")
endif()

if(ARCHITECTURE STREQUAL "i686")
  SET(ARCH_ID "i386")
  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(BUILD_TAG "linux-x86")
    SET(LINUX_32 ON)
  elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    set(BUILD_TAG "win-x32")
  endif()
endif()

if(ARCHITECTURE STREQUAL "x86_64")
  if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
    set(BUILD_TAG "linux-x64")
  elseif(CMAKE_SYSTEM_NAME STREQUAL "FreeBSD")
    set(BUILD_TAG "freebsd-x64")
  elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
    set(BUILD_TAG "win-x64")
  endif()
  SET(ARCH_ID "x86_64")
endif()

#Create a new global cmake flag that indicates building with depends
set (DEPENDS true)