In this project, I’ll be using CMake as I’m told that makes it easier to port to other platforms later on.
In case it’s not clear yet, I do all my development on Pop OS so this is a must to get software running on Windows later on, say before a game gets sent to Steam (obviously not an emulator but you get the idea)
So to make things ready for using CMake, I have moved the main.cpp file around so that the follow structure now exists:
SameBoy/
├── build
│ └── deleteme.txt
├── CMakeLists.txt
└── source
└── main.cpp
So I have created a build folder, placed the source code into a folder called source and created an empty file called CmakeLists.txt in the root folder
The deleteme.txt file is there so that github, or zipping the code folder doesn’t remove the empty folder. I’m not 100% sure that this actually happens anymore but it is a artifact left in my mind from my RISC OS days!
Within the CMakeLists.txt file, I put the following:
cmake_minimum_required(VERSION 3.22)
project(SameBoy)
set(CMAKE_CXX_STANDARD 17)
include_directories(source)
add_executable(${PROJECT_NAME} source/main.cpp)
target_link_libraries(${PROJECT_NAME} SDL3)
From here, I’ll just let CLion take over, open the project and tick the first option regarding reloading the project(Not sure exactly what this does but it looks important)

Cool so my build folder is completely ignored and the new cmake-build-debug older is used instead, I’ll just need to make sure those are added to .gitignore later on
From this point I can now click run/debug in CLion and run the test app.
Alternatively, I can call CMake .. in the build folder and things work fine as well!
Leave a Reply