Details
-
Bug
-
Resolution: Done
-
P3: Somewhat important
-
None
-
Qt Creator 4.2.0-beta1
Description
If I use gcc, my toolchain file has those lines amongst others:
set(CMAKE_SYSROOT "<sysroot_path>") set(CMAKE_CXX_COMPILER ${CMAKE_SYSROOT}/usr/bin/arm-poky-linux-gnueabi-g++) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-a15 -mfloat-abi=hard -mthumb -m32" CACHE STRING "")
When I want to use clang, those lines change to:
set(CMAKE_SYSROOT "<sysroot_path>") set(CMAKE_CXX_COMPILER /opt/clang/3.9.0/bin/clang++) set(CMAKE_CXX_COMPILER_TARGET "arm-poky-linux-gnueabi") set(CMAKE_CXX_COMPILER_EXTERNAL_TOOLCHAIN ${CMAKE_SYSROOT}/usr) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mcpu=cortex-a15 -mfloat-abi=hard -mthumb -m32" CACHE STRING "")
Building process works in both cases without any visible issues in both QtCreator and by manually launching cmake with proper arguments (cmake -H. -Bbuild -DCMAKE_TOOLCHAIN_FILE=arm_(gcc|clang).cmake). However, if I inspect code model in QtCreator, the version with clang doesn't add the following include directories:
CMAKE_SYSROOT/usr/include/c++/5.4.0
CMAKE_SYSROOT/usr/include/c++/5.4.0/arm-poky-linux-gnueabi
CMAKE_SYSROOT/usr/include/c++/5.4.0/backward
CMAKE_SYSROOT/usr/lib/gcc/arm-poky-linux-gnueabi/5.4.0/include
CMAKE_SYSROOT/usr/include
Manually adding the mentioned directories is possible only for the first four as adding the last one has no effect on code model.
The effect is that clang code model cannot find stdlib headers and, for instance, finds incorrect boost headers (from /usr/include/boost instead of CMAKE_SYSROOT/usr/include/boost)
Kits have rather standard options with only one cmake variable CMAKE_TOOLCHAIN_FILE (as CMAKE_<LANG>_COMPILER are defined inside CMAKE_TOOLCHAIN_FILE) pointing to various toolchain files (either gcc which works find or clang which doesn't).
So basically, cross compiling with clang that uses non standard gcc location (so --gcc-toolchain parameter must be set) works but clang code model doesn't cope with it.
Is there any workaround for this problem?
Attachments
Issue Links
- relates to
-
QTCREATORBUG-20392 CMake: Qt Creator is unable to configure and build a project with CMAKE_TOOLCHAIN_FILE
- Closed
-
QTCREATORBUG-16155 Cmake compiler check does not seem to take into account sysroot settings
- Closed