-
Notifications
You must be signed in to change notification settings - Fork 6
/
armv7l-toolchain.cmake
94 lines (82 loc) · 4.57 KB
/
armv7l-toolchain.cmake
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
# CMake Toolchain file to cross compile WebKit2GTK+ for ARM (tested with 2.14.0)
#
# Environment:
# * Ubuntu Xenial chroot (amd64)
# * Root FS for the target device (e.g. /schroot/eos-master-armhf)
# * Usual WebKit build deps installed in the Root FS
# * Build dependencies in the host (xenial chroot):
# gawk cmake debhelper gperf bison flex ruby
# * Cross compiler packages in the host (xenial chroot):
# cpp-4.9-arm-linux-gnueabihf g++-4.9-arm-linux-gnueabihf \
# gcc-4.9-arm-linux-gnueabihf gcc-4.9-arm-linux-gnueabihf-base \
# libasan1-armhf-cross libgcc-4.9-dev-armhf-cross \
# libstdc++-4.9-dev-armhf-cross
#
# How to build:
# 1. Write this file to disk (e.g. armv7l-toolchain.cmake)
# 2. From WebKit top source directory, create a BUILD dir:
# $ mkdir BUILD && cd BUILD
# 3. Configure the build, passing any extra parameter you need:
# $ cmake -DCMAKE_TOOLCHAIN_FILE=$(pwd)/../armv7l-toolchain.cmake \
# -DPORT=GTK \
# -DCMAKE_BUILD_TYPE=Release \
# -DCMAKE_INSTALL_SYSCONFDIR=/etc \
# -DCMAKE_INSTALL_LOCALSTATEDIR=/var \
# -DCMAKE_INSTALL_PREFIX=/usr \
# -DCMAKE_INSTALL_LIBDIR=lib/arm-linux-gnueabihf \
# -DCMAKE_INSTALL_LIBEXECDIR=lib/arm-linux-gnueabihf \
# -DENABLE_PLUGIN_PROCESS_GTK2=OFF \
# -DENABLE_GEOLOCATION=OFF \
# -DENABLE_GLES2=ON \
# -DUSE_LD_GOLD=OFF \
# ..
# 4. Build the thing:
# $ make VERBOSE=1 -j12 # Or anything else, this is just what I use
# Path to the target RootFS (adjust as needed)
SET(ROOTFS "/schroot/eos-master-armhf")
SET(MULTIARCH "arm-linux-gnueabihf")
# Setting the system name to "Linux" sets CMAKE_CROSSCOMPILING to true
SET(CMAKE_SYSTEM_NAME "Linux")
SET(CMAKE_SYSTEM_PROCESSOR "armv7l")
# Specify the cross compilers
SET(CMAKE_C_COMPILER /usr/bin/${MULTIARCH}-gcc-4.9)
SET(CMAKE_CXX_COMPILER /usr/bin/${MULTIARCH}-g++-4.9)
# This is very important, so that we find the right headers and libraries
# without explicitly listing the default include directories (e.g. JSC)
SET(CMAKE_SYSROOT "${ROOTFS}")
# Ensure that FIND_PACKAGE() functions and friends look in the rootfs
# only for libraries and header files, but not for programs (e.g perl)
SET(CMAKE_FIND_ROOT_PATH "${ROOTFS}")
SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
# Add include directories from the rootfs matching the current toolchain
INCLUDE_DIRECTORIES(SYSTEM
"${ROOTFS}/usr/include"
"${ROOTFS}/usr/include/c++/4.9"
"${ROOTFS}/usr/include/arm-linux-gnueabihf/c++/4.9"
)
# CMake does not pick CPPFLAGS, so we add it manually into CFLAGS and CXXFLAGS
# Note: I have no idea why the first include directory from the previous list
# gets ignored when building some components, so I pass it here as well.
SET(CPPFLAGS "-DG_DISABLE_CAST_CHECKS")
SET(ENV{CFLAGS} "${CPPFLAGS} -fstack-protector-strong -Wall -Wformat -Werror=format-security -I${ROOTFS}/usr/include -isystem ${ROOTFS}/usr/include")
SET(ENV{CXXFLAGS} "${CPPFLAGS} -fstack-protector-strong -Wall -Wformat -Werror=format-security -I${ROOTFS}/usr/include -isystem ${ROOTFS}/usr/include")
# CMake does not pick LDFLAGS, so we add it manually too
SET(ENV{LDFLAGS} "-Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,--as-needed -Wl,-rpath-link,${ROOTFS}/lib/arm-linux-gnueabihf")
# This setup is meant for development so make sure we build without optimizations
# and with some debug symbols (-g2 is too much in our ARM platform).
SET(CMAKE_C_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used by the compiler during release builds." FORCE)
SET(CMAKE_CXX_FLAGS_RELEASE "-O2 -DNDEBUG" CACHE STRING "Flags used by the compiler during release builds." FORCE)
SET(CMAKE_C_FLAGS_DEBUG "-g1 -O0" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
SET(CMAKE_CXX_FLAGS_DEBUG "-g1 -O0" CACHE STRING "Flags used by the compiler during debug builds." FORCE)
# Need to export this variables for pkg-config to pick them up, so that it
# sets the right search path and prefixes the result paths with the rootfs.
SET(ENV{PKG_CONFIG_PATH} "${ROOTFS}/usr/share/pkgconfig")
SET(ENV{PKG_CONFIG_LIBDIR} "${ROOTFS}/usr/lib/${MULTIARCH}/pkgconfig:${ROOTFS}/usr/lib/pkgconfig")
SET(ENV{PKG_CONFIG_SYSROOT_DIR} "${ROOTFS}")
# These variables make sure that pkg-config does never discard standard
# include and library paths from the compile and linking flags.
SET(ENV{PKG_CONFIG_ALLOW_SYSTEM_CFLAGS} 1)
SET(ENV{PKG_CONFIG_ALLOW_SYSTEM_LIBS} 1)
SET(PKG_CONFIG_USE_CMAKE_PREFIX_PATH TRUE)