Work with the same CMake Qt project with both Visual Studio and Qt Creator
-
Hi all
My request is a bit strange but cause my inexperience with CMake I didn't find a solution to my problem yet. Basically I use Visual Studio to develop 90% of the app and then use Qt Creator to compile the final package for Android or Linux. At the moment I use two separate project files, one in VS .sln format and CMake for Qt Creator. I would like to use a unique CMake project file for both but I have the following problem. Qt Creator basically need only the CMakeLists.txt since the IDE already have all the paths to the Qt libraries and so on. On the contrary use CMake with Visual Studio require the two additional files CMakePresets.json and CMakeUserPresets.json generated by the QT Tools VS plugin. My problem is if I try to open the project working with Visual Studio (containing CMakeLists.txt, CMakePresets.json and CMakeUserPresets.json) with Qt Creator it detect the two .json files and set the environment based to the info contained in it with the result the compilation doesn't work.
Now my question is if there is a way to "exclude" the two additional json file in case of use of Qt Creator. Obviously a different working solutoon will be welcomed too.
Thank you -
Simply use the CMake Visual Studio Generator instead Ninja or whatever is configured in QtCreator.
-
I'm sorry but I don't understand very well your suggestion. Can you clarify better? Please note I develop my CMake project using Visual Studio under Windows but it could happen also I need to compile this same project using Qt Creator in a Linux machine, than I need the same CMake project filr work in both IDE...
-
I don't see what this has to do with Linux - you are using cmake which is cross platform. Cmake can create a visual studio solution which you use with MSVC. This can also used by QtCreator - simply specify the appropriate build tool in the QtCreator kit settings.
-
Il'' try to make a pratical example. I want to develop and Android app based to Qt. Since I prefer to use Visual Studio as main IDE I create a new project using the QT VS Tools plugin based to CMake. The wizard create a project with the files CMakeLists.txt, CMakePresets.json and CMakeUserPresets.json. Using this project files I develop the app under Windows using VS. Once is ready to start testing undert Android I use Qt Creator with Android SDK configured to compile the same app for Android. However if I open a projet with only CMakeLists.txt present Qt Creator correctly ask me which kits of those available I want to use for the compilation and in my case I select Android arm64_v8a. However if the files CMakePresets.json and CMakeUserPresets.json are present in the same folder Qt Creator want to directly use the paths configured insithe them and doesn't ask me nothing about other kits. So in this case I can not compile any Android app.
Basically this is my problem... -
The other Kits are still there. They are not presented in the right pane, but you can always click on the left an activate a Kit you want to have.
-
Correct, this solve my problem. Thank you and I'm sorry I didn't note this option before but I use Qt Creator only to compile for system different from Windows and I don't know very well the interface...
-
F FalsinSoft has marked this topic as solved on