1 # this toolchain file works for cross compiling on Ubuntu when the following prerequisites are given:
2 # - all dependencies that would be needed for a normal build must be installed as i386 versions
3 # - building XZ/liblzma doesn't work yet, so one has to install liblzma-dev:i386 and set -DUSE_SYSTEM_XZ=ON
4 # - building GTest doesn't work yet, so one has to install libgtest-dev:i386 and set -DUSE_SYSTEM_GTEST=ON
5 # - building libarchive doesn't work yet, so one has to install liblzma-dev:i386 and set -DUSE_SYSTEM_LIBARCHIVE=ON (TODO: link system libarchive statically like liblzma)
6 # some of the packets interfere with their x86_64 version (e.g., libfuse-dev:i386, libglib2-dev:i386), so building on a
7 # normal system will most likely not work, but on systems like Travis it should work fine
9 set(CMAKE_SYSTEM_NAME Linux CACHE STRING "" FORCE)
10 set(CMAKE_SYSTEM_PROCESSOR i386 CACHE STRING "" FORCE)
12 set(CMAKE_C_FLAGS "-m32" CACHE STRING "" FORCE)
13 set(CMAKE_CXX_FLAGS "-m32" CACHE STRING "" FORCE)
15 # CMAKE_SHARED_LINKER_FLAGS, CMAKE_STATIC_LINKER_FLAGS etc. must not be set, but CMAKE_EXE_LINKER_FLAGS is necessary
16 set(CMAKE_EXE_LINKER_FLAGS "-m32" CACHE STRING "" FORCE)
18 set(DEPENDENCIES_CFLAGS "-m32" CACHE STRING "" FORCE)
19 set(DEPENDENCIES_CPPFLAGS "-m32" CACHE STRING "" FORCE)
20 set(DEPENDENCIES_LDFLAGS "-m32" CACHE STRING "" FORCE)
22 # host = target system
23 # build = build system
24 # both must be specified
25 set(EXTRA_CONFIGURE_FLAGS "--host=i686-pc-linux-gnu" "--build=x86_64-pc-linux-gnu" CACHE STRING "" FORCE)
27 # may help with some rare issues
28 set(CMAKE_PREFIX_PATH /usr/lib/i386-linux-gnu CACHE STRING "" FORCE)
30 # makes sure that at least on Ubuntu pkg-config will search for the :i386 packages
31 set(ENV{PKG_CONFIG_PATH} /usr/lib/i386-linux-gnu/pkgconfig/ CACHE STRING "" FORCE)