[CMake] cmake + ccache -> cross-compile -> toolchain wrapper

Haio Maio haiomaio2 at mailbox.org
Thu May 23 07:52:42 EDT 2019


How do you use cmake + ccache to cross compile in combination with a toolchain compiler wrapper (from crosstool-NG)?

The situation:
cross-compile for arm with a sdk + cmake + ccache

The sdk installation

$ sdk-dat-arm$ ll host/usr/bin/
arm-am3354-linux-gnueabihf-c++ -> ext-toolchain-wrapper*
arm-am3354-linux-gnueabihf-cc -> ext-toolchain-wrapper*
arm-am3354-linux-gnueabihf-cpp -> ext-toolchain-wrapper*
arm-am3354-linux-gnueabihf-g++ -> ext-toolchain-wrapper*
arm-am3354-linux-gnueabihf-gcc -> ext-toolchain-wrapper*
arm-am3354-linux-gnueabihf-gcc-4.9.4 -> ext-toolchain-wrapper*


ccache configuration

/usr/local/bin$ ls -al
arm-am3354-linux-gnueabihf-g++ -> ccache
arm-am3354-linux-gnueabihf-gcc -> ccache
cc -> ccache
ccache
g++ -> ccache
gcc -> ccache

/usr/local/bin/arm-am3354-linux-gnueabihf-gcc --version
arm-am3354-linux-gnueabihf-gcc (crosstool-NG ) 4.9.4 20150629 (prerelease)

cmake configuration

set(CMAKE_C_COMPILER_LAUNCHER ccache)
set(CMAKE_C_COMPILER arm-am3354-linux-gnueabihf-gcc)
set(CMAKE_CXX_COMPILER_LAUNCHER ccache)
set(CMAKE_CXX_COMPILER arm-am3354-linux-gnueabihf-g++)

Executing cmake

$ cmake ....
-- Check for working C compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-gcc
-- Check for working C compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-gcc -- works -- Check for working CXX compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-g++
-- Check for working CXX compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-g++ -- works

Compiling with the above cmake configuration fails ...

-- The CXX compiler identification is GNU 4.9.4
-- Check for working C compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-gcc
-- Check for working CXX compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-g++ -- Check for working CXX compiler: /usr/local/bin/arm-am3354-linux-gnueabihf-g++ -- works
In file included from ... fatal error: libudev.h: No such file or directory compilation terminated.

without the LAUNCHER it compiles successively.

The libudev.h is defined for inclusion in
path/CXX.includecache:libudev.h


Any idea of whats the reason for the compilation failure, i.e. why with the LAUNCHER it wont find the include?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://cmake.org/pipermail/cmake/attachments/20190523/94ca2c54/attachment.html>


More information about the CMake mailing list