💾 Archived View for akselmo.dev › posts › 2021-05-29-Quick-CMake-Setup.gmi captured on 2023-06-16 at 16:25:36. Gemini links have been rewritten to link to archived content
⬅️ Previous capture (2023-06-14)
-=-=-=-=-=-=-
When setting up my ScifiFPS[1] C/Raylib[2] project, I was having lots of problems with Makefiles. Apparently this is not uncommon, however I'm pretty new in C and makefiles in the first place, *and* setting it all up with VSCode was also a bit of a hassle.
1: https://github.com/Akselmo/Artificial-Rage
I however managed to get my CMake files work nicely with VSCode. Keep in mind this **has only been tested on Windows**, because as much as I'd love to run Linux as my daily driver, I haven't had the chance to do the switch yet. Also this was made for **Raylib** project, so you probaby will have to modify your build command etc. to suit your needs.
1. First, download CMake Tools -extension[3] for your VSCode. You'll also have to install CMake[4]
3: https://marketplace.visualstudio.com/items?itemName=ms-vscode.cmake-tools
2. In the root of your C project folder, add `CMakeLists.txt` and copy the following to the file
3. Put this in your `src` directory inside `CMakeLists.txt` file
5: https://github.com/GoldenThumbs/raylibGame/blob/main/src/CMakeLists.txt
4. To get VSCode build your project when you press F5, add the following to your project root inside `.vscode` folder.
`launch.json`
Again, remember that the first `CMakeLists.txt` file I mentioned, the one that goes to the root of your project, you may have to tailor for your own needs. The one I copied there works for me when I build Raylib projects.
Also, **I'm new in all of things related to C!** If you have better ideas how to make CMake files, don't hesitate to contact me on my twitter[6] or if you spot me in Discord. I'd like to know and learn.
6: https://www.twitter.com/akselmo
However I hope this is useful someone! Happy coding, and happy less-make-file..ing. *That sounded better in my head..*
I you have any comments, you can mail me in here: