add CMake build system support
Summary
enhance cmake build system (Enhance #3704)
- Update all CMakeLists.txt to adapt to new layout
- Fix cmake build break
- Update all new file license
- Fully compatible with current compilation environment(use configure.sh or cmake as you choose)
How to test
From within nuttx/. Configure:
$ cmake -B build -DNUTTX_BOARD=arm/imx6/sabre-6quad -DNUTTX_CONFIG=smp -GNinja
$ cmake -B build -DNUTTX_BOARD=arm/tiva/lm3s6965-ek -DNUTTX_CONFIG=qemu-flat -GNinja
$ cmake -B build -DNUTTX_BOARD=sim/sim/sim -DNUTTX_CONFIG=nsh -GNinja
This uses ninja generator (install with sudo apt install ninja-build). To build:
$ cmake --build build
menuconfig:
$ cmake --build build -t menuconfig
Compilation speed:
| lm3s6965-ek/qemu-flat:
| Orignal : $ time `./tools/configure.sh lm3s6965-ek/qemu-flat > /dev/null && make -j16 > /dev/null`
| CMake : $ time `cmake -B build -DNUTTX_BOARD=arm/tiva/lm3s6965-ek -DNUTTX_CONFIG=qemu-flat > /dev/null;cmake --build build -j16 > /dev/null`
| CMake(Ninja): $ time `cmake -B build -DNUTTX_BOARD=arm/tiva/lm3s6965-ek -DNUTTX_CONFIG=qemu-flat -GNinja > /dev/null;cmake --build build -j16 > /dev/null`
|
| Orignal CMake CMake(Ninja)
| real 0m9.982s 0m4.739s 0m4.475s
| user 1m5.336s 0m41.846s 0m37.434s
| sys 0m16.428s 0m9.239s 0m7.998s
|
|
| Orignal : $ time `./tools/configure.sh sabre-6quad/smp > /dev/null && make -j16 > /dev/null`
| CMake : $ time `cmake -B build -DNUTTX_BOARD=arm/imx6/sabre-6quad -DNUTTX_CONFIG=smp > /dev/null;cmake --build build -j16 > /dev/null`
| CMake(Ninja): $ time `cmake -B build -DNUTTX_BOARD=arm/imx6/sabre-6quad -DNUTTX_CONFIG=smp -GNinja > /dev/null;cmake --build build -j16 > /dev/null`
|
| Orignal CMake CMake(Ninja)
| real 0m10.921s 0m3.936s 0m3.616s
| user 0m51.603s 0m32.621s 0m29.102s
| sys 0m13.720s 0m8.075s 0m6.460s
Signed-off-by: chao.an [email protected]
Impact
Depends on: https://github.com/apache/incubator-nuttx/pull/6718
Testing
cmake -B build -DNUTTX_BOARD=sim/sim/sim -DNUTTX_CONFIG=nsh -GNinja cmake -B build -DNUTTX_BOARD=arm/imx6/sabre-6quad -DNUTTX_CONFIG=smp -GNinja cmake -B build -DNUTTX_BOARD=arm/tiva/lm3s6965-ek -DNUTTX_CONFIG=qemu-flat -GNinja
@anchao Nice! - what are the times for touching one file and rebuilding
@anchao Nice! - what are the times for
touching one file and rebuilding
the rebuilding time depends on whether the file has changed, please pick the changes and try it
Of course it depends on the file, I already know it is way faster, but besides the advantage shoring not only the CI cycle it will shorten the dev cycle and that is were the ROI on this is massive. I was hoping you would showcase that herein to make it very clear to all the project members.