{"id":22288894,"url":"https://github.com/michael-valdron/cpp-app-template","last_synced_at":"2025-03-25T21:20:48.908Z","repository":{"id":91210198,"uuid":"284225259","full_name":"michael-valdron/cpp-app-template","owner":"michael-valdron","description":"Personal template for starting a C++ project.","archived":false,"fork":false,"pushed_at":"2022-07-20T03:31:50.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-01-30T18:39:30.266Z","etag":null,"topics":["c-plus-plus","c-plus-plus-11","c-plusplus","cmake","cpp","cpp-template","cpp-templates","cpp11","makefile"],"latest_commit_sha":null,"homepage":"","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/michael-valdron.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2020-08-01T09:03:49.000Z","updated_at":"2022-07-20T03:31:52.000Z","dependencies_parsed_at":"2023-07-04T14:15:36.812Z","dependency_job_id":null,"html_url":"https://github.com/michael-valdron/cpp-app-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/michael-valdron%2Fcpp-app-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-valdron%2Fcpp-app-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-valdron%2Fcpp-app-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/michael-valdron%2Fcpp-app-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/michael-valdron","download_url":"https://codeload.github.com/michael-valdron/cpp-app-template/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245543428,"owners_count":20632648,"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":["c-plus-plus","c-plus-plus-11","c-plusplus","cmake","cpp","cpp-template","cpp-templates","cpp11","makefile"],"created_at":"2024-12-03T17:07:24.379Z","updated_at":"2025-03-25T21:20:48.893Z","avatar_url":"https://github.com/michael-valdron.png","language":"CMake","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cpp-app-template\nPersonal template for starting a C++ project.\n\n## Requirements\n\nThis template works under GNU+Linux distributions, however, this template should\nwork under Windows and other UNIX based operating systems (e.g. macOS, FreeBSD,\netc.) with the following utilities:\n\n1. [`gcc`](https://gcc.gnu.org/) and\n   [`g++`](https://gcc.gnu.org/projects/cxx-status.html)\n2. [`git`](https://git-scm.com/)\n3. [`make`](https://www.gnu.org/software/make/)\n4. [`cmake`](https://cmake.org/)\n\n## Directory Structure\n\n- `extern/`: Contains imported submodules\n- `include/`: Contains header files\n- `src/`: Contains cpp source files\n- `.gitmodules`: Stores submodules repository information\n- `CMakeLists.txt`: CMake config\n- `Makefile`: Makefile which contains tasks for CMake\n\n```\n.\n+--extern\n|   +--...\n+--include\n|   +--...\n+--src\n|   +--main.cc\n|   +--...\n+--.gitignore\n+--.gitmodules\n+--CMakeLists.txt\n+--Makefile\n+--README.md\n```\n\n## Compile Project\n\nYou can use `make` to run the compile process which is a `make` task called\n`build`, this is the default task:\n\n```sh\nmake build\n```\nor\n```sh\nmake\n```\n\nHowever, the task `build` will not run unless the output of CMake does not\nexist. To recompile changes one must use the `rebuild` task:\n\n```sh\nmake rebuild\n```\n\n## Run Project\n\nLike with `make build`, you can use `make` to run the compiled executable by\nusing the task called `run`:\n\n```sh\nmake run\n```\n\n## Clean Binaries\n\nWe can clean the generated files and directories from our compiling by using the\n`clean` task:\n\n```sh\nmake clean\n```\n\n## Importing Libraries\n\nThis template uses the common methods of bring in libraries. In the\n`CMakeLists.txt` file:\n\n1. We must include the libraries using [add_subdirectory](###add-submodules)\n   statements for each library.\n2. We must link the includes and binaries of the libraries by defining:\n    1. A [target_include_directories](###link-submodules) block that contains\n       paths to libraries include directories for each library.\n    2. [target_link_libraries](###link-submodules) statements for each library.\n\n\n## CMakeLists.txt Structure\n\n### CMAKE Version Requirement\n```cmake\ncmake_minimum_required(VERSION \u003ccmake-version-req\u003e)\n```\n\n### Project definitions\n\n```cmake\nproject(\n    \u003cproject-name\u003e\n    VERSION \u003cversion\u003e\n    LANGUAGES \u003cc-or-cxx\u003e)\n```\n\n### Variables\n\n```cmake\nset(\u003cvar-name\u003e \u003cval\u003e)\n```\n\n#### Examples\n```cmake\nset(CMAKE_CXX_STANDARD 11)\nset(CMAKE_CXX_STANDARD_REQUIRED True)\nset(SOURCE_DIR \"${PROJECT_SOURCE_DIR}/src/\")\nset(INCLUDE_DIR \"${PROJECT_SOURCE_DIR}/include/\")\n```\n\n### Add submodules\n\n```cmake\nadd_subdirectory(extern/\u003csubmodule\u003e)\n...\n```\n\n### Link project includes\n\n```cmake\ninclude_directories(\u003cdir-with-includes\u003e)\n```\n\n### Get source files\n\n```cmake\nfile(GLOB_RECURSE SOURCES \u003csrc-patterns\u003e)\n```\n\n### Compile executable for project\n\n```cmake\nadd_executable(${PROJECT_NAME} ${SOURCES})\n```\n\n### Link submodules\n\n```cmake\ntarget_include_directories(${PROJECT_NAME}\n    PUBLIC extern/\u003csubmodule\u003e/include\n    ...\n)\ntarget_link_libraries(${PROJECT_NAME} \u003csubmodule_binary_name\u003e)\n...\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-valdron%2Fcpp-app-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmichael-valdron%2Fcpp-app-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmichael-valdron%2Fcpp-app-template/lists"}