-
Follow the above instructions about how to use GitHub's project template feature to create your own project.
-
Open CMakeLists.txt. Rename the project and the executable to whatever name you want. The project and executable names don't have to match.
-
If you want to add or remove any .cpp files, change the source files listed in the
add_executable
call in CMakeLists.txt to match the source files your project requires. If you plan on keeping the default main.cpp file then no changes are required. -
If you use Linux, install SFML's dependencies using your system package manager. On Ubuntu and other Debian-based distributions you can use the following commands:
sudo apt update sudo apt install \ libxrandr-dev \ libxcursor-dev \ libudev-dev \ libfreetype-dev \ libopenal-dev \ libflac-dev \ libvorbis-dev \ libgl1-mesa-dev \ libegl1-mesa-dev
-
Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part.
Using CMake from the command line is straightforward as well.
For a single-configuration generator (typically the case on Linux and macOS):
cmake -S . -B build -DCMAKE_BUILD_TYPE=Release cmake --build build
For a multi-configuration generator (typically the case on Windows):
cmake -S . -B build cmake --build build --config Release
Note from author of CMakes, Alan Zhang:
- Delete C:...\Desktop\DSAProject3\cmake-build-debug_deps\sfml-build
- Delete C:...\Desktop\DSAProject3\cmake-build-debug_deps\sfml-build
- do NOT delete sfml-src. VERY IMPORTANT
- Reload CMake Project
- Make sure target is set to DSAProject3 (should already be that way in CMakeLists.txt)
- Make sure working directory in CLion is set to C:..\Desktop\DSAProject3\src
- Enjoy!