C Development, using cmake

Hi,

I'm going through the Inside Playdate With C, I'd like to compile any of the example files. I've ran setup.sh

Documentation

To build with Cmake manually do the following from the root of the project:

mkdir build
cd build
cmake ..
grep: /home/nate/.Playdate/config: No such file or directory
-- SDK Path: ~/Documents/playdate/PlaydateSDK-1.3.1
-- Configuring done
-- Generating done
-- Build files have been written to: /home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build

So here it's expecting a file called .config in a hidden folder called Playdate? I can't find in the docs anything about setting this up. Now, if I run make I get two errors undocumented in the guide?

$ make
/usr/bin/cmake -S"/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World" -B"/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build" --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build/CMakeFiles" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build//CMakeFiles/progress.marks"
make  -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
make  -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/depend
make[2]: Entering directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
cd "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build" && /usr/bin/cmake -E cmake_depends "Unix Makefiles" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build" "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build/CMakeFiles/hello_world.dir/DependInfo.cmake" --color=
make[2]: Leaving directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
make  -f CMakeFiles/hello_world.dir/build.make CMakeFiles/hello_world.dir/build
make[2]: Entering directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
[ 50%] Building C object CMakeFiles/hello_world.dir/src/main.c.o
/usr/bin/cc -DTARGET_EXTENSION=1 -DTARGET_SIMULATOR=1 -Dhello_world_EXPORTS -I/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API -fPIC -Wall -Wstrict-prototypes -Wno-unknown-pragmas -std=gnu11 -MD -MT CMakeFiles/hello_world.dir/src/main.c.o -MF CMakeFiles/hello_world.dir/src/main.c.o.d -o CMakeFiles/hello_world.dir/src/main.c.o -c "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/src/main.c"
[100%] Linking C shared library libhello_world.so
/usr/bin/cmake -E cmake_link_script CMakeFiles/hello_world.dir/link.txt --verbose=1
/usr/bin/cc -fPIC -shared -Wl,-soname,libhello_world.so -o libhello_world.so CMakeFiles/hello_world.dir/src/main.c.o 
/usr/bin/cmake -E copy /home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello\ World/build/libhello_world.dylib /home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello\ World/Source/pdex.dylib
Error copying file "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build/libhello_world.dylib" to "/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/Source/pdex.dylib".
make[2]: *** [CMakeFiles/hello_world.dir/build.make:101: libhello_world.so] Error 1
make[2]: *** Deleting file 'libhello_world.so'
make[2]: Leaving directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
make[1]: *** [CMakeFiles/Makefile2:86: CMakeFiles/hello_world.dir/all] Error 2
make[1]: Leaving directory '/home/nate/Documents/playdate/PlaydateSDK-1.3.1/C_API/Examples/Hello World/build'
make: *** [Makefile:94: all] Error 2

Any help would be great :slight_smile: I don't use VS Code nor X Code. Ninja is not available for my operating system.

~/.Playdate/config should be written by the installer.

It contains one line setting a variable SDKRoot with the path to your SDK install folder:

SDKRoot	/Applications/PlaydateSDK

I wonder if the installed SDK has to go in Applications?

My setup.sh seems to be doing something different, it doesn't seem to be setting any ENV variables

#!/bin/bash

if [ $(id -u) -ne 0 ]; then
  echo "Please run this script with sudo"
  exit 1
fi

mkdir -p /usr/local/share/applications/

cp Resources/date.play.simulator.svg /usr/share/icons/hicolor/scalable/apps/

cat <<-EOF > /tmp/date.play.simulator.desktop
[Desktop Entry]
Name=Playdate Simulator
Exec=$(pwd)/bin/PlaydateSimulator %f
Icon=$(pwd)/Resources/date.play.simulator.svg
Terminal=false
Type=Application
MimeType=application/playdate-game
StartupWMClass=PlaydateSimulator
Categories=Development;
StartupNotify=true
EOF

desktop-file-install --dir=/usr/local/share/applications/  /tmp/date.play.simulator.desktop
update-desktop-database

cp Resources/50-playdate.rules /etc/udev/rules.d/
udevadm control --reload-rules
udevadm trigger

cp Resources/playdate-types.xml /usr/share/mime/packages/
update-mime-database /usr/share/mime


echo "Done."

Edit

Figured it out, not going to use cmake at all, will just run with make alone.