In cocos2d-x 3.17 release, we try to support prebuilt libs in cmake build, by 3 options supplied:
GEN_COCOS_PREBUILT / USE_COCOS_PREBUILT / COCOS_PREBUILT_ROOT
As far as I know, CMake official didn’t builtin prebuilt feature, that similar with gen-libs . So that this feature is a really hack method, and make the cmake scripts more bloated. To simply the cmake scripts, make it easy understand ,we removed it. also with @CrazyHappyGame strongly suggest to do this simplification.
what’s your options, and do existed any elegant method to do this?
history comments:
remove un-elegant prebuilt feature in cmake by drelaptop · Pull Request #19109 · cocos2d/cocos2d-x · GitHub
R101
November 28, 2018, 5:40am
2
Does this info help?
c++, build, cmake
Where the example uses ExternalProject_Add
https://cmake.org/cmake/help/latest/module/ExternalProject.html
thanks for this info, it will helps that build only once, and reuse it in different cocos2dx games build.
I will try this way later. but 3.17.1 is coming, afraid that I cant finish it before this release, so I want to put it into next milestone.
One of the many ways to build library once and reuse it in multiple games is to create root CMakeLists.txt which will contains all games. For example please check.: GitHub - cocos2d/cocos2d-x-external: use CMake to build external 3rd party modules for cocos2d-x .
$ git clone GitHub - cocos2d/cocos2d-x-external: use CMake to build external 3rd party modules for cocos2d-x
$ cd cocos2d-x-external
$ mkdir build
$ cd build
$ cmake …
$ time cmake --build . --target game1
real 2m1.080s
~2 minutes - builds all deps and game1
$ time cmake --build . --target game 2
real 0m2.080s
~2 seconds only! - builds only game2. deps were built with game1