{"id":21005290,"url":"https://github.com/jdumas/cpp-project-template","last_synced_at":"2025-05-15T01:33:33.859Z","repository":{"id":98238205,"uuid":"223657518","full_name":"jdumas/cpp-project-template","owner":"jdumas","description":"Template repository for C++ projects using CMake, libigl, etc.","archived":false,"fork":false,"pushed_at":"2019-11-24T21:24:38.000Z","size":58,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T02:02:26.733Z","etag":null,"topics":["cmake","cpp","graphics"],"latest_commit_sha":null,"homepage":null,"language":"CMake","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jdumas.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","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}},"created_at":"2019-11-23T21:48:53.000Z","updated_at":"2024-04-22T16:46:08.000Z","dependencies_parsed_at":"2023-05-18T20:15:12.834Z","dependency_job_id":null,"html_url":"https://github.com/jdumas/cpp-project-template","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/jdumas%2Fcpp-project-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdumas%2Fcpp-project-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdumas%2Fcpp-project-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jdumas%2Fcpp-project-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jdumas","download_url":"https://codeload.github.com/jdumas/cpp-project-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254256664,"owners_count":22040329,"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","cpp","graphics"],"created_at":"2024-11-19T08:43:12.791Z","updated_at":"2025-05-15T01:33:33.853Z","avatar_url":"https://github.com/jdumas.png","language":"CMake","readme":"# C++ Project Template\n\n[![Build Status](https://travis-ci.com/jdumas/cpp-project-template.svg?branch=master)](https://travis-ci.com/jdumas/cpp-project-template)\n[![Build Status](https://dev.azure.com/jdumas-github/cpp-project-template/_apis/build/status/jdumas.cpp-project-template?branchName=master)](https://dev.azure.com/jdumas-github/cpp-project-template/_build/latest?definitionId=1\u0026branchName=master)\n\nTemplate repository for C++ projects using CMake, libigl, etc.\n\n### Getting Started\n\nCreate a new github repository using this project [as template](https://help.github.com/en/github/creating-cloning-and-archiving-repositories/creating-a-repository-from-a-template):\n\n![](https://help.github.com/assets/images/help/repository/use-this-template-button.png)\n\nThen replace all placeholders with your new project name using this simple python script:\n\n```\n./misc/bootstrap.py \u003cnew_project_name\u003e\n```\n\n### Project Structure\n\nThe main file you want to be looking at to add/update dependencies is `cmake/@Project_Name@External.cmake`. Do not look at `@Project_Name@Boilerplate.cmake`, this is the file doing the dirty laundry so that `@Project_Name@External.cmake` looks pretty. Everything else should speak for itself, mostly.\n\nWe use CMake's [FetchContent](https://cmake.org/cmake/help/latest/module/FetchContent.html) mechanism to download external dependencies at CMake time so that they can be built alongside your main project. External dependencies are compiled statically so the produced executable is as self-contained as possible.\nThe goal of this project is to provide a modern template for C++ project using CMake. Thus, you will need at least:\n\n- CMake 3.11\n- C++17\n\nThe core mechanism used to import an external dependencies (download + create a CMake target) is the `@project_name@_import()` function. For example, to create a new executable that depends on libigl, CLI11 and tinyfiledialogs, you can use the following:\n\n```cmake\nadd_executable(MyViewer\n    main.cpp\n    filedialogs.cpp\n    filedialogs.h\n    viewer.cpp\n    viewer.h\n)\n\n@project_name@_import(libigl cli11 tinyfiledialogs)\n\ntarget_link_libraries(MyViewer\n    PRIVATE\n        igl::opengl_glfw_imgui\n        CLI11::CLI11\n        tinyfiledialogs::tinyfiledialogs\n)\n\n# Use C++17\ntarget_compile_features(MyViewer PUBLIC cxx_std_17)\n```\n\nwhere `@project_name@` should be replaced by your project name when you run the `./misc/bootstrap.py` script. Note that the name given to the `@project_name@_import()` function is different from the target name (`Foo::Bar`) available once the library is imported. The table below lists all libraries which are available for import in this current template. One important detail to note is that *nothing is downloaded* if you do not import a library. Thus, adding libraries to this template will not \"bloat\" your starting project unless you decide to actually use it. The reasoning is that it should be easier to remove imported libraries from this template than to add a new one should you need it.\n\n### Available Libraries\n\n| FetchContent name | Target name | Url |\n| --- | --- | --- |\n| `catch2`           | `Catch2::Catch2`                   | [Catch2](https://github.com/catchorg/Catch2.git)                         |\n| `cli11`            | `CLI11::CLI11`                     | [CLI11](https://github.com/CLIUtils/CLI11.git)                           |\n| `cppoptlib`        | `cppoptlib::cppoptlib`             | [CppNumericalSolvers](https://github.com/PatWie/CppNumericalSolvers.git) |\n| `eigen`            | `Eigen3::Eigen`                    | [Eigen](https://github.com/eigenteam/eigen-git-mirror)                   |\n| `ghc_filesystem`   | `ghc::filesystem`                  | [Filesystem](https://github.com/gulrak/filesystem.git)                   |\n| `fmt`              | `fmt::fmt`                         | [{fmt}](https://github.com/fmtlib/fmt)                                   |\n| `json`             | `nlohmann_json::nlohmann_json`     | [JSON](https://github.com/nlohmann/json)                                 |\n| `libigl`           | `igl::core`, ...                   | [libigl](https://github.com/libigl/libigl.git)                           |\n| `nanoflann`        | `nanoflann::nanoflann`             | [nanoflann](https://github.com/jlblancoc/nanoflann)                      |\n| `pcg`              | `pcg::pcg`                         | [PCG](https://github.com/imneme/pcg-cpp.git)                             |\n| `simple_svg`       | `simple_svg::simple_svg`           | [simple-svg](https://github.com/adishavit/simple-svg.git)                |\n| `spdlog`           | `spdlog::spdlog`                   | [spdlog](https://github.com/gabime/spdlog)                               |\n| `tbb`              | `tbb::tbb`                         | [Threading Building Blocks](https://github.com/wjakob/tbb.git)           |\n| `tinyfiledialogs`  | `tinyfiledialogs::tinyfiledialogs` | [tiny file dialogs](https://sourceforge.net/projects/tinyfiledialogs/)   |\n| `windingnumber`    | `windingnumber::windingnumber`     | [WindingNumber](https://github.com/sideeffects/WindingNumber)            |\n\n### Continuous Integration\n\nIt is a good idea to ensure that your code always builds, and does so on all platforms (Windows, Linux, macOS). You do not want to push code that might leave your coworkers unhappy because they cannot build the project anymore. To that end, we use continuous integration via the following services:\n\n- [Travis CI](https://docs.travis-ci.com/user/tutorial/)\n- [Azure Pipeline](https://docs.microsoft.com/en-us/azure/devops/pipelines/repos/github)\n\nBoth support Windows, Linux and macOS. Feel free to adapt existing scripts to your needs. Travis can be used for private projects if you have an education account.\n\n\u003c!-- TODO: Add continuous integration with Github Actions --\u003e\n\n### Notes\n\n##### Libigl\n\nBy default, we use libigl in header-only mode, single building in static mode takes a long time. However, as your project grows, you might want to switch the CMake option `LIBIGL_USE_STATIC_LIBRARY` to `ON` to accelerate incremental builds (this is especially useful in combination with a caching compiler such as `ccache`).\n\n##### Filesystem\n\nWith C++17, in theory the `\u003cfilesystem\u003e` header from the Standard Template Library provides a cross-platform filesystem library. Unfortunately, compiler support is still lacking, in particular on macOS -- you need at least Xcode 11 and macOS 10.15, which may not be supported by our CI platforms yet. To that end, we define an alias target `std::filesystem`. This target will add the necessary linking flags if `\u003cfilesystem\u003e` or `\u003cexperimental/filesystem\u003e` are supported on your system. If not, it will download [ghc::filesystem](https://github.com/gulrak/filesystem) and use that as an alias. Automatic namespace forwarding is implemented in [filesystem.h](https://github.com/jdumas/cpp-project-template/blob/master/src/@project_name@/filesystem.h) so you can use it directly.\n\n##### Logger\n\n*TODO*\n\n##### Clang-format\n\n*TODO*\n\n##### Sanitizers\n\n*TODO*\n\n### Useful links\n\n- [An Introduction to Modern CMake](https://cliutils.gitlab.io/modern-cmake/)\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdumas%2Fcpp-project-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdumas%2Fcpp-project-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdumas%2Fcpp-project-template/lists"}