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?
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.: https://github.com/cocos2d/cocos2d-x-external.
$ git clone https://github.com/cocos2d/cocos2d-x-external.git
$ 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