Plan: Use modern cmake to build all external libs

Plan: Use modern cmake to build all external libs


As we known, 3.17 have supported cmake build on all platforms, that make cross-platform compile more convenient. and for external we still supply prebuilt static libraries.

When hopping to custom external libraries, we have to learn how to use build tools in cocos2d-x-3rd-party-libs-src repo. That tool is a little complex, not a easy things to use it. And the build tool can’t works on windows.

To solve this issue, we want to use modern cmake to build all external libs. That will be convenient to custom external, meanwhile can works on windows platform. @CrazyHappyGame and I have done a beginning for this work. Created a new repo cocos2d-x-external , setup CI, add part cmake script. and now we both are pushing it move forward a little and a little.

We need help. hope someone can join us to push this feature together. This feature will be added into 3.18 release if things goes well.


PR examples


As I understand you correct, you are planning to create a full build chain without prebuilts, so if I want to add x86_64 for Android, it’s just (in best case) one setting? So I can use CLion to build my game for all needed ABIs?

That would be awesome and will help a lot, because I can update or debug external libs, if necessary.


Yes, everything will be compiled from sources, without prebuilds.

Also with CMake it is very easy to setup project in that way that once compiled external libs and cocos2d-x can be easy reused in many games.

Travis is set to build following Android ABIs: arm, x86, x86_64, arm64-v8a

Full procedure to build locally Android x86_64 external libs:

export ANDROID_NDK_ROOT=....
export ANDROID_SDK_ROOT=... //needed for test apk
git clone
cd cocos2d-x-external
mkdir build
cd build
cmake .. -DCMAKE_TOOLCHAIN_FILE=../tools/android_x86_64_toolchain.cmake -G Ninja
cmake --build .


I tried something similar sometime ago using Python. =)


I am working on a bigger cmake refactor to improve the link libraries logic. especially the old link external libs logic, which is confused. this improvenment will make module link logic more clear, and make it easier to connect pure source external next.

here is the PR