简体   繁体   English

如何使用QtCreator为Android / iOS构建基于CMake的项目

[英]How to Build CMake based project for Android/iOS using QtCreator

I have created a Non-Qt C++ (CMake) project using Qt, and I am able to build it using MinGW, MSVC compiler. 我使用Qt创建了一个非Qt C ++(CMake)项目,我可以使用MinGW,MSVC编译器构建它。

So in short, when I am opening my test project I can select the generators under Run CMake Window. 所以简而言之,当我打开我的测试项目时,我可以在Run CMake Window下选择生成器。 I have issue with other platforms. 我有其他平台的问题。

When I am trying to Add a kit for Android, there are no generators available in the list. 当我尝试为Android添加套件时,列表中没有可用的生成器。 I tried the same thing on Macbook, there also the same problem. 我在Macbook上尝试过同样的事情,也有同样的问题。

I need help on this issue, I couldn't get the proper steps to build the CMake based project for Android/iOS using QtCreator. 我在这个问题上需要帮助,我无法使用QtCreator为Android / iOS构建基于CMake的项目。

PS Installed CMake version is 3.2.1 and Qt Version is 5.5, I have installed Android SDK, NDK , and and Java PS安装的CMake版本是3.2.1,Qt版本是5.5,我安装了Android SDK,NDK和Java

I would love to tell you "just check this box in the options dialog and it will work", but, unfortunately, there is no generator that you can use to build an Android/iOS project from a CMakeLists.txt file. 我很乐意告诉你“只需在选项对话框中选中此框即可”,但遗憾的是,没有可用于从CMakeLists.txt文件构建Android / iOS项目的生成器。

I found alternatives, in all cases, I don't think your have a chance to port a whole huge CMake-based project that used to work on Windows (with lots of libraries and 3rd party libraries) work on Android in less than a few days of work....;-) 我找到了替代方案,在所有情况下,我认为你没有机会移植一个基于CMake的大型项目,这个项目曾经在Windows上工作(有很多库和第三方库)在Android上运行的不到一些工作日...... ;-)

  • Personnaly, I wrote a small CMake function generating the .pro file manually from my CMake scripts. Personnaly,我写了一个小的CMake函数,从我的CMake脚本手动生成.pro文件。 It started small but is now huge and it's difficult to share it with you. 它开始很小但现在很大,很难与你分享。 But, basically, I started from this post on a Qt forum. 但是,基本上,我是从Qt论坛上的这篇文章开始的。 It creates a simple .pro file that does not work that bad and then you can extend it for your own needs. 它创建了一个简单的.pro文件,该文件无法正常工作,然后您可以根据自己的需要进行扩展。 I like this solution because I have full control on generated .pro file (mine can now build on PC, Android and iOS...but I had a hard time to have this fully work). 我喜欢这个解决方案,因为我可以完全控制生成的.pro文件(我现在可以在PC,Android和iOS上构建......但我很难完全使用它)。

  • Apparently, there's also a way to add a Qt-android CMake support using this open source stuff: https://github.com/LaurentGomila/qt-android-cmake . 显然,还有一种方法可以使用这个开源软件添加Qt-android CMake支持: https//github.com/LaurentGomila/qt-android-cmake But I never tried it. 但我从未尝试过。 You may want to have a look to it. 你可能想看看它。 If it works, it may be more convenient that writting your own script generating .pro files. 如果它工作,编写自己的脚本生成.pro文件可能会更方便。 Apparently, it builds an Android apk using androidqtdeploy but without using QtCreator. 显然,它使用androidqtdeploy构建了一个Android apk,但没有使用QtCreator。 There's also an iOS support. 还有iOS支持。

  • Finally, the best may be to have CMake propose a QtCreator "generator" (it would generate .pro files, like CMake generates sln/vcproj files when using Visual Studio generator or makefiles for g++ generator....), but there is no such generator supported. 最后,最好的可能是让CMake提出一个QtCreator“生成器”(它会生成.pro文件,就像CMake在使用Visual Studio生成器时生成sln / vcproj文件或者生成文件用于g ++生成器....),但是没有这种发电机支持。 I reported this to CMake team some time ago hoping they could fix that. 我前段时间向CMake团队报告过,希望能解决这个问题。 I understood that there was and would be no plan to do that because CMake targets only "compilers" as "generators" and "QtCreator" is not really a "compiler", it's a "IDE" using external "compilers" to build (MinGW, MSVC, CLang, Android's NDK g++...). 我明白有没有计划这样做,因为CMake只将“编译器”定位为“生成器”而“QtCreator”实际上不是“编译器”,它是使用外部“编译器”构建的“IDE”(MinGW) ,MSVC,CLang,Android的NDK g ++ ...)。 It's a shame because CMake known all your project information and could easily generate a .pro file....so, as, CMake is opensource, one may extend CMake with a custom QtCreator file generator...and share it with the whole world,it would be wonderful! 这很遗憾,因为CMake知道你所有的项目信息并且可以很容易地生成.pro文件....因此,CMake是开源的,可以使用自定义QtCreator文件生成器扩展CMake ......并与全世界分享,这太棒了!

Hope this will help you! 希望这个能对您有所帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM