[cmake-developers] Cross compiling toolchain variables
Stephen Kelly
steveire at gmail.com
Mon Oct 21 16:23:34 EDT 2013
Hi,
I've pushed the cross-compiling-toolchain-variables topic to my clone. It is
the merger of several topics which were discussed during the CMake 2.8.12
feature cycle regarding CMAKE_SYSROOT etc.
I have reviewed how the features interact with try_compile and fixed that up
as described here:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7705
I have also addressed the issue from this thread:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7698
My QNX toolchain file is now very simple:
set(CMAKE_SYSTEM_NAME QNX)
# The --sysroot flag is not supported by qcc,
# set(CMAKE_SYSROOT /home/stephen/bbndk/target_10_1_0_1020/qnx6)
set(CMAKE_FIND_ROOT_PATH
/home/stephen/dev/build/qtbase-bb/qtbase-bb
/home/stephen/bbndk/target_10_1_0_1020/qnx6
/home/stephen/bbndk/target_10_1_0_1020/qnx6/armle-v7
)
set(CMAKE_C_COMPILER
/home/stephen/bbndk/host_10_1_0_132/linux/x86/usr/bin/qcc)
set(CMAKE_C_COMPILER_TARGET gcc_ntoarmv7le)
set(CMAKE_CXX_COMPILER
/home/stephen/bbndk/host_10_1_0_132/linux/x86/usr/bin/QCC)
set(CMAKE_CXX_COMPILER_TARGET gcc_ntoarmv7le_cpp)
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
compared to what is used in the wild currently:
https://trac.lcsr.jhu.edu/cisst/attachment/wiki/qnx/Toolchain-QNX-6.4.1.cmake
My clang toolchain file for the raspberryPi is also very simple:
set(CMAKE_SYSTEM_NAME Linux)
set(CMAKE_SYSROOT /home/stephen/rpi/rasp-pi-rootfs)
# Installation location of Qt 5
set(CMAKE_FIND_ROOT_PATH /home/stephen/dev/src/qtbase-rpi/extprefix)
set(triple arm-linux-gnueabihf)
set(gcc_toolchain /home/stephen/rpi/gcc-4.7-linaro-rpi-gnueabihf)
set(CMAKE_C_COMPILER
/home/stephen/dev/build/qtbase/llvm/bin/clang
# /home/stephen/dev/src/playground/cmake/arm-linux-gnueabihf-clang
)
set(CMAKE_C_COMPILER_TARGET ${triple})
set(CMAKE_C_COMPILER_EXTERNAL_TOOLCHAIN ${gcc_toolchain})
set(CMAKE_CXX_COMPILER
/home/stephen/dev/build/qtbase/llvm/bin/clang++
# /home/stephen/dev/src/playground/cmake/arm-linux-gnueabihf-clang++
)
set(CMAKE_CXX_COMPILER_TARGET ${triple})
set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN ${gcc_toolchain})
# Debian bug 708744
include_directories(SYSTEM "${CMAKE_SYSROOT}/usr/include/${triple}")
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
I have tested both toolchains with simple helloworld applications, a simple
executable which depends on zlib, and with gammaray with Qt 5, with both
Ninja and Unix Makefiles.
I have not worked on merging the CMAKE_OSX_SYSROOT feature with
CMAKE_SYSROOT as I don't have the required OSX knowledge
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7294/focus=7376
That also relates to this bug:
https://bugreports.qt-project.org/browse/QTBUG-32308
and this mail:
http://thread.gmane.org/gmane.comp.lib.qt.devel/13444/focus=13450
though I think the suggestion in that mail is incorrect. If anything is
needed there at all, then it can't be CMAKE_OSX_SYSROOT because that can be
an unresolved name. Also, if the resolved path of the CMAKE_OSX_SYSROOT is
used as the value of CMAKE_SYSROOT, then that will be a search prefix, and
the path modification suggested in that mail will not be needed.
I have also not yet addressed the INSTALL_PREFIX issues here:
http://thread.gmane.org/gmane.comp.programming.tools.cmake.devel/7292/focus=7373
I think the mail from Samuel Martin does not change any significant facts
about the design. It seems from my reading that in his case, he would set
CMAKE_EXTERNAL_INSTALL_PREFIX.
Can I go ahead and investigate implementing what is described in the above
linked mail with CMAKE_EXTERNAL_INSTALL_PREFIX? Any updated ideas for a name
for the variable?
Thanks,
Steve.
More information about the cmake-developers
mailing list