Qt Creator Compiler headers
-
I configured the kit with Compiler = No, because... my CMAKE project takes TOOLCHAIN_PATH to determine which compiler to use
I can't explicitly specify the compiler due to the project structure
The project is being assembled, there are no errors.
Cmake detects the compiler correctly:
[cmake] -- The ASM compiler identification is GNU
[cmake] -- Found assembler: C:/arm-gnu-toolchain-13.2/bin/arm-none-eabi-gcc.exe
[cmake] -- The C compiler identification is GNU 13.2.1
[cmake] -- Detecting C compiler ABI info
[cmake] -- Detecting C compiler ABI info - done
[cmake] -- Check for working C compiler: C:/arm-gnu-toolchain-13.2/bin/arm-none-eabi-gcc.exe - skipped
[cmake] -- Detecting C compile features
[cmake] -- Detecting C compile features - done
[cmake] -- The CXX compiler identification is GNU 13.2.1
[cmake] -- Detecting CXX compiler ABI info
[cmake] -- Detecting CXX compiler ABI info - done
[cmake] -- Check for working CXX compiler: C:/arm-gnu-toolchain-13.2/bin/arm-none-eabi-g++.exe - skipped
[cmake] -- Detecting CXX compile features
[cmake] -- Detecting CXX compile features - doneBut Qt Creator print a warning: ":-1: warning: The project contains C source files, but the currently active kit has no C compiler. The code model will not be fully functional."
And compiler header files are highlighted as undefined.
How can I force Qt Creator to use a compiler that has defined and uses the CMAKE script?
cmake script adds CMAKE_CXX_COMPILER to the cache -
I guess there is no harm in setting a compiler for the kit. If you want to use Qt Creator to build your project as well, you can provide your own command line to be used for compilation and check which environment variables are set during build (maybe removing any environment variables that specify the compiler path). This can all be found when clicking on Project on the left-hand pane.
-
@SimonSchroeder It is not comfortable. For me, CMAKE automatically finds the required compiler by name, version and OS type. You can specify it on different PCs each time, but this is unlikely to be correct.
The CMAKE project does not require kits; just create several Build configurations -
You could use
CMakePresets.json
file to specify a CMake Preset Kit.Qt Creator would then use the information from the
CMakePresets.json
file and create a kit for you.Something like:
{ "version": 4 }, "configurePresets": [ { "name": "arm-gnu-toolchain", "displayName": "Arm GNU GCC 13.2", "generator": "Ninja", "toolchainFile" : "C:/arm-gnu-toolchain-13.2/toolchain.cmake", "cacheVariables": { "CMAKE_C_COMPILER": "arm-none-eabi-gcc.exe", "CMAKE_CXX_COMPILER": "arm-none-eabi-g++.exe" } } ] }
See https://doc.qt.io/qtcreator/creator-build-settings-cmake-presets.html and various Qt Creator CMake blog entries for more details.