Android Studio External Native Build Precompiled Headers

I'm porting a project from NDK build to Android Studio.

Currently the project has a precompiled header attached (with NDK build), which speeds up compilation time a lot.

I'm looking for a way to add precompiled header (.pch) to my external native build within Android Studio project. I'm using CMake.


I am in the same situation and I have found several user-made script to do that.

I would recommend this one:

https://github.com/larsch/cmake-precompiled-header

In order to make it work for the latest ndk-tools which uses clang, copy paste the content of this pull request:

https://gist.github.com/leeor/316168500765cf51ae97

into the PrecompiledHeader.cmake file (replace everything in this file, except if you want to keep GCC/ MSVC compatibility, then just you will have to merge the two files which shouldn't be hard).

It should work, except some special CMAKE_CXX_FLAGS that triggers an error in the export_all_flags function, and that I don't know how to fix yet. I'll keep you updated with my progress.

链接地址: http://www.djcxy.com/p/40256.html

上一篇: 了解如何存储Web推送端点

下一篇: Android Studio外部本机构建预编译头