Allow specifying where a pdx will be built with CMake

I'm using the C API with CMake, built from the command line. One relatively minor issue I'm hitting is that the Playdate SDK's CMake files have it build a project's pdx in the root of its source directory.

On top of it being a bit odd to have a build artifact be created in the source directory rather than the build directory, this means that I can't easily have builds for both the simulator and device at the same time, since building for one always overwrites a previous build for the other. Of course I could just copy the pdx file around between builds, but I'd rather they just be created in a build directory specific for either the emulator or physical Playdate so I always know which one I'm dealing with.

I just edited playdate_game.cmake to allow this, but it means that if I update the SDK I'll have to make the change again. It'd be nice to have a CMake variable that just specifies where the pdx is going to end up, and seems like it'd be a pretty straight forward change to make.

(In fact if I have working changes to playdate_game.cmake that allow this, would you like me to just send you my changes somehow?)

1 Like

Sounds good, you could just post your updated files here and we'll take a look. :slight_smile: Thanks!

I've attached my updated version of playdate_game.cmake. The change is pretty straight forward, and defines a new variable PLAYDATE_PDX_DIR that defaults to the current default pdx build location, but can be overridden by the user in their own CMakeLists.txt to specify a different directory. I set it to CMAKE_BINARY_DIR in my project.

playdate_game.cmake.zip (1.1 KB)