I have some C code for a library that I'd like to test using googletest. I intend to build the library for multiple architectures including x86, x86-64, ARM and ARM64.
As the library would export some functionality that is architecture specific, I'd like to test the library for each architecture.
In order to test the ARM64 build of the library, I'm trying to compile googletest for ARM64.
googletest uses cmake. I tried using the following cmake script to indicate that I want to cross compile google test.
$ cat toolchain-arm64.cmake
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_CROSSCOMPILING TRUE)
set(CMAKE_CXX_COMPILER /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++)
set(CMAKE_C_COMPILER /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc)
set(CMAKE_FIND_ROOT_PATH /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
$ mkdir build && cd build
$ cmake .. -DCMAKE_TOOLCHAIN_FILE=../toolchain-arm64.cmake
I get the following output :-
-- The CXX compiler identification is GNU 6.1.1
-- The C compiler identification is GNU 6.1.1
-- Check for working CXX compiler: /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++
-- Check for working CXX compiler: /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-g++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Check for working C compiler: /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc
-- Check for working C compiler: /home/asdf/repos/toolchains/gcc-linaro-6.1.1-2016.08-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-gcc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Found PythonInterp: /usr/bin/python (found version "2.7.12")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Check if compiler accepts -pthread
CMake Error: TRY_RUN() invoked in cross-compiling mode, please set the following cache variables appropriately:
THREADS_PTHREAD_ARG (advanced)
For details see /home/asdf/repos/misc/googletest/googletest/build/TryRunResults.cmake
-- Check if compiler accepts -pthread - no
-- Found Threads: TRUE
-- Configuring incomplete, errors occurred!
See also "/home/asdf/repos/misc/googletest/googletest/build/CMakeFiles/CMakeOutput.log".
See also "/home/asdf/repos/misc/googletest/googletest/build/CMakeFiles/CMakeError.log".
Why does this error occur? How can I fix this?