Skip to content

games: add CMake build support for snake, brickmatch, and match4 - #3861

Merged
linguini1 merged 3 commits into
apache:masterfrom
Swatantra-66:cmake/games-snake-brickmatch-match4
Oct 18, 2026
Merged

linguini1 merged 3 commits into
apache:masterfrom
Swatantra-66:cmake/games-snake-brickmatch-match4

Conversation

@Swatantra-66

@Swatantra-66 Swatantra-66 commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Addresses the CMake vs. Make build-system gap for apps/games identified in issue apache/nuttx#19549 ("[Analysis] CMake vs. Make Build-System Gap Analysis"):

Add CMake build support (CMakeLists.txt) for the remaining simple games in apps/games:

  • snake: Added apps/games/snake/CMakeLists.txt matching Makefile options (CONFIG_GAMES_SNAKE_*).
  • brickmatch: Added apps/games/brickmatch/CMakeLists.txt matching Makefile options (CONFIG_GAMES_BRICKMATCH_*).
  • match4: Added apps/games/match4/CMakeLists.txt matching Makefile options (CONFIG_GAMES_MATCH4_*).

Addresses apache/nuttx#19549

All CMake files have been formatted with cmake-format and verified with checkpatch.sh.

Impact

  • New Feature: Enables CMake build configuration and compilation for snake, brickmatch, and match4.
  • Existing Feature: No change to existing Make build or runtime logic.
  • Compatibility: Fully backwards compatible.

Testing

  • Host: Linux x86_64 (Ubuntu / WSL2)
  • Toolchain: GCC 15.2.0, CMake 4.2.3, Ninja 1.13.2
  • Target: sim:nsh (with CONFIG_GAMES_BRICKMATCH=y, CONFIG_GAMES_SNAKE=y, CONFIG_GAMES_MATCH4=y)

Build Log:

$ cmake -B build -DBOARD_CONFIG=sim:nsh -GNinja
-- Initializing NuttX
--   CMake:  4.2.3
--   Ninja:  1.13.2
--   Board:  sim
--   Config: nsh
--   Appdir: /path/to/nuttx-apps
-- Configuring done (97.6s)
-- Generating done (11.6s)
-- Build files have been written to: build

$ cmake --build build --target apps_brick apps_snake apps_match
[1/5] Building C object apps/games/snake/CMakeFiles/apps_snake.dir/snake_main.c.o
[2/5] Building C object apps/games/match4/CMakeFiles/apps_match.dir/match4_main.c.o
[3/5] Linking C static library apps/games/snake/libapps_snake.a
[4/5] Linking C static library apps/games/match4/libapps_match.a
[5/5] Linking C static library apps/games/brickmatch/libapps_brick.a

$ cmake --build build --target nuttx
[1217/1248] Linking C static library apps/games/brickmatch/libapps_brick.a
[1237/1248] Generating nuttx.rel
[1247/1248] Linking C executable nuttx
[1248/1248] Built target nuttx

Runtime Log:

$ ./build/nuttx

NuttShell (NSH) NuttX-12.x
nsh> help
help usage:  help [-v] [<cmd>]

    .           dirname     free        mount       set         umount      
    [           date        help        mv          kill        unset       
    ?           df          hexdump     pidof       pkill       uptime      
    alias       dmesg       losetup     poweroff    sleep       watch       
    unalias     echo        ln          quit        usleep      xd          
    basename    env         ls          printf      source      wait        
    break       exec        du          ps          test        
    cat         exit        mkdir       pwd         time        
    cd          expr        mkfatfs     readlink    true        
    cp          false       mkfifo      rm          truncate    
    cmp         fdinfo      mkrd        rmdir       uname       

Builtin Apps:
    brick        dumpstack    nsh          init         gpio         
    dd           gcov         sh           ostest       hello        

nsh> brick
ERROR: Failed to open /dev/fb0: 2
nsh> exit

(Note: brick exits with Failed to open /dev/fb0: 2 (ENOENT) as expected on headless sim:nsh since no framebuffer display driver is attached, confirming that the builtin application registers and executes successfully).

Add CMakeLists.txt to enable CMake build support for the snake game.

Signed-off-by: Swatantra Yadav <[email protected]>
Add CMakeLists.txt to enable CMake build support for the brickmatch game.

Signed-off-by: Swatantra Yadav <[email protected]>
Add CMakeLists.txt to enable CMake build support for the match4 game.

Signed-off-by: Swatantra Yadav <[email protected]>
@Swatantra-66
Swatantra-66 force-pushed the cmake/games-snake-brickmatch-match4 branch from 55a2909 to 74dead3 Compare October 17, 2026 17:44
@linguini1

Copy link
Copy Markdown
Contributor

FYI, you can try rendering with an actual framebuffer on the simulator by using the X11 graphics support. You can take a look at the sim:nxdoom configuration for how that's done and just include brick in the build if you want.

@linguini1
linguini1 merged commit edda86f into apache:master Oct 18, 2026
41 checks passed
@Swatantra-66

Copy link
Copy Markdown
Contributor Author

Thank you so much for the review and merge, @linguini1!

And thanks for the tip on the X11 graphics support—I'll definitely try running brick and snake with the sim:nxdoom X11 framebuffer setup!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants