Files
-
MicroController / electrical / sam_d21_dev_board / R2R network.kicad_sch
-
MicroController / electrical / sam_d21_dev_board / sam_d21_dev_board.kicad_pcb
-
MicroController / electrical / sam_d21_dev_board / sam_d21_dev_board.kicad_sch
-
MicroController / electrical / sam_d21_dev_board / VGA ADC.kicad_sch
-
MicroController / electrical / sam_d21_vga / R2R network.kicad_sch
-
MicroController / electrical / sam_d21_vga / sam_d21_vga.kicad_pcb
-
MicroController / electrical / sam_d21_vga / sam_d21_vga.kicad_sch
-
MicroController / electrical / sam_d21_vga / triangle_generator.kicad_sch
-
MicroController / electrical / sam_d21_vga / untitled.kicad_sch
-
MicroController / electrical / sam_d21_vga / VGA ADC.kicad_sch
-
MicroController / electrical / sam_d21_vga / R2R network / R2R network.kicad_pcb
-
MicroController / electrical / sam_d21_vga / R2R network / R2R network.kicad_sch
-
MicroController / electrical / sam_d21_vga / vga_adc / R2R network.kicad_sch
-
MicroController / electrical / sam_d21_vga / vga_adc / vga_adc.kicad_pcb
-
MicroController / electrical / sam_d21_vga / vga_adc / vga_adc.kicad_sch
-
MicroController / electrical / sam_d21_vga / vga_adc / vga_adc_bkp.kicad_pcb
-
MicroController / electrical / samd21_base / samd21_base.kicad_pcb
-
MicroController / electrical / samd21_base / samd21_base.kicad_sch
-
MicroController / electrical / SPI_mem / SPI_mem.kicad_pcb
-
MicroController / electrical / SPI_mem / SPI_mem.kicad_sch
-
MicroController / electrical / vga_adapter / vga_adapter.kicad_pcb
-
MicroController / electrical / vga_adapter / vga_adapter.kicad_sch
-
MicroController / electrical / vga_adc / R2R network.kicad_sch
-
MicroController / electrical / vga_adc / vga_adc.kicad_pcb
-
MicroController / electrical / vga_adc / vga_adc.kicad_sch
-
MicroController / electrical / vga_adc / vga_adc_bkp.kicad_pcb
FilesC++graphicalconway-graphics | |
---|---|
.. | |
.github | |
src | |
.gitignore | |
CMakeLists.txt | |
LICENSE.md | |
README.md |
README.mdCMake SFML Project Template
This repository template should allow for a fast and hassle-free kick start of your next SFML project using CMake. Thanks to GitHub's nature of templates , you can fork this repository without inheriting its Git history.
The template starts out very basic, but might receive additional features over time:
- Basic CMake script to build your project and link SFML on any operating system
- Basic GitHub Actions script for all major platforms
How to Use
- 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
- Enjoy!
Upgrading SFML
SFML is found via CMake's FetchContent module. FetchContent automatically downloads SFML from GitHub and builds it alongside your own code. Beyond the convenience of not having to install SFML yourself, this ensures ABI compatability and simplifies things like specifying static versus shared libraries.
Modifying what version of SFML you want is as easy as changing the GIT_TAG
argument.
Currently it uses the latest in-development version of SFML 2 via the 2.6.x
tag.
If you're feeling adventurous and want to give SFML 3 a try, use the master
tag.
Beware, this requires changing your code to suit the modified API!
The nice folks in the SFML community can help you with that transition and the bugs you may encounter along the way.
But I want to...
Modify CMake options by adding them as configuration parameters (with a -D
flag) or by modifying the contents of CMakeCache.txt and rebuilding.
Use Static Libraries
By default SFML builds shared libraries and this default is inherited by your project.
CMake's BUILD_SHARED_LIBS
option lets you pick static or shared libraries for the entire project.
Change Compilers
See the variety of CMAKE_<LANG>_COMPILER
options.
In particular you'll want to modify CMAKE_CXX_COMPILER
to point to the C++ compiler you wish to use.
Change Compiler Optimizations
CMake abstracts away specific optimizer flags through the CMAKE_BUILD_TYPE
option.
By default this project recommends Release
builds which enable optimizations.
Other build types include Debug
builds which enable debug symbols but disable optimizations.
If you're using a multi-configuration generator (as is often the case on Windows), you can modify the CMAKE_CONFIGURATION_TYPES
option.
Change Generators
While CMake will attempt to pick a suitable default generator, some systems offer a number of generators to choose from.
Ubuntu, for example, offers Makefiles and Ninja as two potential options.
For a list of generators, click here .
To modify the generator you're using you must reconfigure your project providing a -G
flag with a value corresponding to the generator you want.
You can't simply modify an entry in the CMakeCache.txt file unlike the above options.
Then you may rebuild your project with this new generator.
More Reading
Here are some useful resources if you want to learn more about CMake:
- How to Use CMake Without the Agonizing Pain - Part 1
- How to Use CMake Without the Agonizing Pain - Part 2
- Better CMake YouTube series by Jefferon Amstutz
License
The source code is dual licensed under Public Domain and MIT -- choose whichever you prefer.