{"id":19091855,"url":"https://github.com/sfml/cmake-sfml-project","last_synced_at":"2025-05-15T11:09:10.303Z","repository":{"id":37269522,"uuid":"469114768","full_name":"SFML/cmake-sfml-project","owner":"SFML","description":"Repository template for SFML projects using CMake","archived":false,"fork":false,"pushed_at":"2025-04-22T14:30:55.000Z","size":24,"stargazers_count":451,"open_issues_count":0,"forks_count":285,"subscribers_count":14,"default_branch":"master","last_synced_at":"2025-05-09T00:14:42.223Z","etag":null,"topics":["cmake","sfml","template"],"latest_commit_sha":null,"homepage":"","language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/SFML.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-03-12T15:01:38.000Z","updated_at":"2025-05-08T14:31:01.000Z","dependencies_parsed_at":"2023-09-22T03:25:45.806Z","dependency_job_id":"4fc38253-d6ff-4081-94ad-b49a51eaffad","html_url":"https://github.com/SFML/cmake-sfml-project","commit_stats":null,"previous_names":[],"tags_count":0,"template":true,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SFML%2Fcmake-sfml-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SFML%2Fcmake-sfml-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SFML%2Fcmake-sfml-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/SFML%2Fcmake-sfml-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/SFML","download_url":"https://codeload.github.com/SFML/cmake-sfml-project/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254328386,"owners_count":22052632,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cmake","sfml","template"],"created_at":"2024-11-09T03:17:14.869Z","updated_at":"2025-05-15T11:09:10.283Z","avatar_url":"https://github.com/SFML.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# CMake SFML Project Template\n\nThis repository template should allow for a fast and hassle-free kick start of your next SFML project using CMake.\nThanks to [GitHub's nature of templates](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template), you can fork this repository without inheriting its Git history.\n\nThe template starts out very basic, but might receive additional features over time:\n\n- Basic CMake script to build your project and link SFML on any operating system\n- Basic [GitHub Actions](https://github.com/features/actions) script for all major platforms\n\n## How to Use\n\n1. Install [Git](https://git-scm.com/downloads) and [CMake](https://cmake.org/download/). Use your system's package manager if available.\n2. Follow [GitHub's instructions](https://docs.github.com/en/repositories/creating-and-managing-repositories/creating-a-repository-from-a-template) for how to use their project template feature to create your own project. If you don't want to use GitHub, see the section below.\n3. Clone your new GitHub repo and open the repo in your text editor of choice.\n4. Open [CMakeLists.txt](CMakeLists.txt). Rename the project and the target name of the executable to whatever name you want. Make sure to change all occurrences.\n5. 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.\n6. If your code uses the Audio or Network modules then add `SFML::Audio` or `SFML::Network` to the `target_link_libraries` call alongside the existing `SFML::Graphics` library that is being linked.\n7. 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:\n   ```\n   sudo apt update\n   sudo apt install \\\n       libxrandr-dev \\\n       libxcursor-dev \\\n       libxi-dev \\\n       libudev-dev \\\n       libfreetype-dev \\\n       libflac-dev \\\n       libvorbis-dev \\\n       libgl1-mesa-dev \\\n       libegl1-mesa-dev \\\n       libfreetype-dev\n   ```\n8. Configure and build your project. Most popular IDEs support CMake projects with very little effort on your part.\n\n   - [VS Code](https://code.visualstudio.com) via the [CMake extension](https://code.visualstudio.com/docs/cpp/cmake-linux)\n   - [Visual Studio](https://docs.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio?view=msvc-170)\n   - [CLion](https://www.jetbrains.com/clion/features/cmake-support.html)\n   - [Qt Creator](https://doc.qt.io/qtcreator/creator-project-cmake.html)\n\n   Using CMake from the command line is straightforward as well.\n   Be sure to run these commands in the root directory of the project you just created.\n\n   ```\n   cmake -B build\n   cmake --build build\n   ```\n\n9. Enjoy!\n\n## Upgrading SFML\n\nSFML is found via CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) module.\nFetchContent automatically downloads SFML from GitHub and builds it alongside your own code.\nBeyond the convenience of not having to install SFML yourself, this ensures ABI compatibility and simplifies things like specifying static versus shared libraries.\n\nModifying what version of SFML you want is as easy as changing the `GIT_TAG` argument.\nCurrently it uses SFML 3 via the `3.0.0` tag.\n\n## But I want to...\n\nModify CMake options by adding them as configuration parameters (with a `-D` flag) or by modifying the contents of CMakeCache.txt and rebuilding.\n\n### Not use GitHub\n\nYou can use this project without a GitHub account by [downloading the contents](https://github.com/SFML/cmake-sfml-project/archive/refs/heads/master.zip) of the repository as a ZIP archive and unpacking it locally.\nThis approach also avoids using Git entirely if you would prefer to not do that.\n\n### Change Compilers\n\nSee the variety of [`CMAKE_\u003cLANG\u003e_COMPILER`](https://cmake.org/cmake/help/latest/variable/CMAKE_LANG_COMPILER.html) options.\nIn particular you'll want to modify `CMAKE_CXX_COMPILER` to point to the C++ compiler you wish to use.\n\n### Change Compiler Optimizations\n\nCMake abstracts away specific optimizer flags through the [`CMAKE_BUILD_TYPE`](https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html) option.\nBy default this project recommends `Release` builds which enable optimizations.\nOther build types include `Debug` builds which enable debug symbols but disable optimizations.\nIf you're using a multi-configuration generator (as is often the case on Windows), you can modify the [`CMAKE_CONFIGURATION_TYPES`](https://cmake.org/cmake/help/latest/variable/CMAKE_CONFIGURATION_TYPES.html#variable:CMAKE_CONFIGURATION_TYPES) option.\n\n### Change Generators\n\nWhile CMake will attempt to pick a suitable default generator, some systems offer a number of generators to choose from.\nUbuntu, for example, offers Makefiles and Ninja as two potential options.\nFor a list of generators, click [here](https://cmake.org/cmake/help/latest/manual/cmake-generators.7.html).\nTo modify the generator you're using you must reconfigure your project providing a `-G` flag with a value corresponding to the generator you want.\nYou can't simply modify an entry in the CMakeCache.txt file unlike the above options.\nThen you may rebuild your project with this new generator.\n\n## More Reading\n\nHere are some useful resources if you want to learn more about CMake:\n\n- [Official CMake Tutorial](https://cmake.org/cmake/help/latest/guide/tutorial/)\n- [How to Use CMake Without the Agonizing Pain - Part 1](https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-1.html)\n- [How to Use CMake Without the Agonizing Pain - Part 2](https://alexreinking.com/blog/how-to-use-cmake-without-the-agonizing-pain-part-2.html)\n- [Better CMake YouTube series by Jefferon Amstutz](https://www.youtube.com/playlist?list=PL8i3OhJb4FNV10aIZ8oF0AA46HgA2ed8g)\n\n## License\n\nThe source code is dual licensed under Public Domain and MIT -- choose whichever you prefer.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfml%2Fcmake-sfml-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsfml%2Fcmake-sfml-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsfml%2Fcmake-sfml-project/lists"}