diff options
author | Stephen Kyle <stephen.kyle@arm.com> | 2018-09-27 10:00:33 +0100 |
---|---|---|
committer | Eugene Kliuchnikov <eustas@google.com> | 2018-09-27 11:00:33 +0200 |
commit | 67f059eaf5eb6cf9201ffe7776b48229a442d864 (patch) | |
tree | 0c92d35c51c1194bd3ac5fee0afc65547e42eec1 /CMakeLists.txt | |
parent | 6eba239a5bb553fd557b7d78f7da8f0059618b9e (diff) | |
download | brotli-67f059eaf5eb6cf9201ffe7776b48229a442d864.zip brotli-67f059eaf5eb6cf9201ffe7776b48229a442d864.tar.gz brotli-67f059eaf5eb6cf9201ffe7776b48229a442d864.tar.bz2 |
Cross compilation support (#709)
* build: add cross-compilation support to make
Set CROSS_COMPILE when running make to use the selected cross
compilation toolchain, such as arm-linux-gnueabihf, or
aarch64-linux-gnu.
Testing requires the presence of qemu - 'qemu-$(ARCH)' will be executed,
where ARCH is the first part of the toolchain triplet.
* build: add cross-compilation support to cmake
If C_COMPILER/CXX_COMPILER/CC/CXX are found to have cross-compilation
triplets in front of the compiler, then qemu will be used to execute the
tests.
* CI: add arm-linux-gnueabihf-gcc builder to Travis
The version of qemu available in Ubuntu trusty (as provided by Travis)
appears to have a bug in qemu-aarch64, which leads to the compatibility
tests failing on some inputs, erroneously rejecting the input as
corrupt.
Once Travis supports xenial, we could add an aarch64-gnu-linux-gcc
builder as well.
* CI: propagate cmake errors out of .travis.sh
Seems like even if cmake fails, the error isn't picked up by Travis.
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r-- | CMakeLists.txt | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 6f1c5a2..fc45f80 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -218,15 +218,37 @@ endif() # to run the tests... if(NOT BROTLI_DISABLE_TESTS) if(WIN32 AND NOT CMAKE_HOST_WIN32) - find_program(BROTLI_WINE NAMES wine) + find_program(BROTLI_WRAPPER NAMES wine) - if(NOT BROTLI_WINE) + if(NOT BROTLI_WRAPPER) message(STATUS "wine not found, disabling tests") set(BROTLI_DISABLE_TESTS TRUE) endif() endif() endif() +# If our compiler is a cross-compiler that we know about (arm/aarch64), +# then we need to use qemu to execute the tests. +if(NOT BROTLI_DISABLE_TESTS) + if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabihf-.*$") + message(STATUS "Detected arm-linux-gnueabihf cross-compilation") + set(BROTLI_WRAPPER "qemu-arm") + set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabihf") + endif() + + if ("${CMAKE_C_COMPILER}" MATCHES "^.*/arm-linux-gnueabi-.*$") + message(STATUS "Detected arm-linux-gnueabi cross-compilation") + set(BROTLI_WRAPPER "qemu-arm") + set(BROTLI_WRAPPER_LD_PREFIX "/usr/arm-linux-gnueabi") + endif() + + if ("${CMAKE_C_COMPILER}" MATCHES "^.*/aarch64-linux-gnu-.*$") + message(STATUS "Detected aarch64-linux-gnu cross-compilation") + set(BROTLI_WRAPPER "qemu-aarch64") + set(BROTLI_WRAPPER_LD_PREFIX "/usr/aarch64-linux-gnu") + endif() +endif() + if(NOT BROTLI_DISABLE_TESTS) include(CTest) enable_testing() @@ -249,7 +271,8 @@ if(NOT BROTLI_DISABLE_TESTS) foreach(quality 1 6 9 11) add_test(NAME "${BROTLI_TEST_PREFIX}roundtrip/${INPUT}/${quality}" COMMAND "${CMAKE_COMMAND}" - -DBROTLI_WRAPPER=${BROTLI_WINE} + -DBROTLI_WRAPPER=${BROTLI_WRAPPER} + -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX} -DBROTLI_CLI=$<TARGET_FILE:brotli> -DQUALITY=${quality} -DINPUT=${INPUT_FILE} @@ -266,7 +289,8 @@ if(NOT BROTLI_DISABLE_TESTS) foreach(INPUT ${COMPATIBILITY_INPUTS}) add_test(NAME "${BROTLI_TEST_PREFIX}compatibility/${INPUT}" COMMAND "${CMAKE_COMMAND}" - -DBROTLI_WRAPPER=${BROTLI_WINE} + -DBROTLI_WRAPPER=${BROTLI_WRAPPER} + -DBROTLI_WRAPPER_LD_PREFIX=${BROTLI_WRAPPER_LD_PREFIX} -DBROTLI_CLI=$<TARGET_FILE:brotli> -DINPUT=${CMAKE_CURRENT_SOURCE_DIR}/${INPUT} -P ${CMAKE_CURRENT_SOURCE_DIR}/tests/run-compatibility-test.cmake) |