QT 5.2: using different kits in the same project -> CMake wizard not working as expected
-
Hi,
Windows XP, home edition, SP3.
I have the following situation:
- I create a project with Qt Creator
- I want to have 2 versions of the application: one build for the i386 architecture, one build for the ARM architecture
- I do have the ARM cross compiler (both gcc and g++), so no need for a toolchain build
- I want to create two kits for the above: one kit that uses the standard gcc/g++ compiler (i386) and one kit that uses the cross compiler (arm-linux-gnueabi-gcc/g++).
When creating the kits, I want to specify different compilation arguments for CMake in the CMake wizard:
- For the i386 build, I want to specify -DCMAKE_BUILD_TYPE=Debug
- For the ARM build, I want to specify -DCMAKE_BUILD_TYPE=Debug -DCROSS_COMPILE=arm-linux-gnueabi
Note: I cannot add the last hyphen sign to the compiler prefix in the above cross compile string "arm-linux-gnueabi", otherwise the complete string is stroked through because of the way this forum acts on parts of a sentence starting and stopping with a hyphen...
In the CMakeLists.txt file, I specify the following for the cross compiler variable:
@SET(CMAKE_C_COMPILER ${CROSS_COMPILE}gcc)
SET(CMAKE_CXX_COMPILER ${CROSS_COMPILE}g++)@What I'm expecting, is that when I switch kits, I do see different CMake arguments.
- For the i386 build, I don't want to fill in the env variable CROSS_COMPILE, so the CMAKE_C_COMPILER should be gcc (and the like for the CXX flag). Therefore, I only specify -DCMAKE_BUILD_TYPE=Debug in the CMake wizard.
- For the ARM build, I want the CROSS_COMPILE env var to be defined as "arm-linux-gnueabi-", so that the correct compiler is taken to cross compile. Therefore, I additionally specify -DCROSS_COMPILE=arm-linux-gnueabi in the CMake wizard.
However, when switching kits, I do see that the arguments in the CMake wizard do NOT change. I always see -DCMAKE_BUILD_TYPE -DCROSS_COMPILE=arm-linux-gnueabi.
This is not what I'm expecting.
What's causing this behaviour? Is this a flaw in the CMake wizard? It looks like Qt Creator is caching its variables and does not update the files based on the kit selected.
Best rgds,
--Geert -
Hi Geert,
i have been looking to this. Following is what i discovered:
The cmake params are stored in the history of the m_argumentsLineEdit . There is only one instance for all kits.
It contains a history of all params that have tried out ( entered in the arguments editline input field ). I have noticed also that a change of these params is not always taken into account when re-run cmake.
I propose to store the cmake parameters also in the cbp file, and no longer in the history of the editline.
I will give it a try!? as i don't know if there is a forum to propose solutions before starting to implement (contribute to ) it.
Best regards,
Wim
-
Hi Geert,
it seems al the processing and ( not correct) updating of cbp file and cache file is done by cmake itself,...
So in qtcreator there is a need to store the cmake parameters per kit,... and apply them per kit.
Best regards,
Wim
-
Hi Geert,
some update.
Cmake uses a CMakeCache file to add all options. Every time you add an option to cmake, it will be added to the cache file.
To remove a certain cmake option, you can use cmake -U<cmake option>
How ever this becomes complicated.
What i propose to do, is when asked to rerun cmake, remove the cache file and rerun cmake with the correct option for your targer and kit.
As such you can apply cross compiling.
Qtcreator can be update to have some info on removing it, or by default completely remove the cache.
Kind regards,
Wim