Instructions for Hello World cmake build do not work

The instructions for using cmake to build a project do not seem to work with the Hello World example:

$ cd /tmp
$ cp -r $PLAYDATE_SDK_PATH/C_API/Examples/Hello\ World .
$ cd Hello\ World
$ mkdir build
$ cd build
$ cmake ..

Produces the error

-- The C compiler identification is GNU 11.3.0
-- The ASM compiler identification is GNU
-- Found assembler: /usr/bin/cc
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- SDK Path: /store/sheldon/opt/PlaydateSDK
-- Configuring done
CMake Error at CMakeLists.txt:36 (add_library):
  Cannot find source file:

    src/main.c

  Tried extensions .c .C .c++ .cc .cpp .cxx .cu .mpp .m .M .mm .ixx .cppm .h
  .hh .h++ .hm .hpp .hxx .in .txx .f .F .for .f77 .f90 .f95 .f03 .hip .ispc


CMake Error at CMakeLists.txt:36 (add_library):
  No SOURCES given to target: hello_world


CMake Generate step failed.  Build files cannot be regenerated correctly.

Works here on Fedora/Ubuntu. What OS are you on? What version of CMake are you using? It failed on this line:

add_library(${PLAYDATE_GAME_NAME} SHARED src/main.c )

Also, might be worth verifying that file exists inside the Hello World example folder.

Mint, which is essentially Ubuntu.

sheldon@blackbird:~$ cmake --version
cmake version 3.22.1

CMake suite maintained and supported by Kitware (kitware.com/cmake).

.... huh, src/main.c doesn't exist. Interesting!

I reinstalled the SDK and the file now exists and the build works fine. I have no idea where the file went but it's probably safe to assume is was my error.

Thanks for the assistance.

Glad you got it sorted out! Sometimes the simplest solution is the right one. :slight_smile:

You'd think decades of development experience would have help catch that one, but nope! :slight_smile: