{"id":17127604,"url":"https://github.com/cmazakas/cppinit","last_synced_at":"2026-01-27T18:44:18.357Z","repository":{"id":80344135,"uuid":"129563152","full_name":"cmazakas/cppinit","owner":"cmazakas","description":"A CLI tool written in Go used to generate C++ projects","archived":false,"fork":false,"pushed_at":"2018-04-15T16:58:42.000Z","size":13,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-06-02T04:16:24.936Z","etag":null,"topics":["boost","catch2","cli","cmake","cpp","golang"],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cmazakas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2018-04-14T23:56:09.000Z","updated_at":"2018-07-08T15:40:59.000Z","dependencies_parsed_at":"2023-06-06T00:00:43.144Z","dependency_job_id":null,"html_url":"https://github.com/cmazakas/cppinit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/cmazakas/cppinit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmazakas%2Fcppinit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmazakas%2Fcppinit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmazakas%2Fcppinit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmazakas%2Fcppinit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cmazakas","download_url":"https://codeload.github.com/cmazakas/cppinit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cmazakas%2Fcppinit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28818902,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-27T18:01:38.485Z","status":"ssl_error","status_checked_at":"2026-01-27T18:01:27.499Z","response_time":168,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["boost","catch2","cli","cmake","cpp","golang"],"created_at":"2024-10-14T19:04:58.257Z","updated_at":"2026-01-27T18:44:18.339Z","avatar_url":"https://github.com/cmazakas.png","language":"Go","readme":"# cppinit\n\n`cppinit` is a CLI utility written in Go that generates empty C++ projects for\nmy particular configuration and tastes.\n\nIt requires the following:\n* [VSCode](https://code.visualstudio.com/) (and the plugin CMake Tools by vector-of-bool)\n* [CMake](https://cmake.org/) (v3.11+)\n* [Boost](https://www.boost.org/) (v1.67)\n* [Catch](https://github.com/catchorg/Catch2) (v2)\n* [Ninja](https://ninja-build.org/)\n\nDownload Boost via `brew`, `pacman` or `vcpkg`. Because Ubuntu is usually so behind, simply download and build the source.\n\nFor `cppinit` itself:\n\n1. Download and install the Go toolkit (1.10 was used at time of writing)\n2. `go get github.com/LeonineKing1199/cppinit`\n3. `cd $GOPATH/src/github.com/LeonineKing1199/cppinit`\n3. `go build`\n4. Take the compiled binary and add it to a dedicated folder on your system's PATH\n\nTo use:\n\nBuild an empty project with:\n```\nmkdir my-new-project\ncd my-new-project\n./cppinit -name=my-new-project\n\n=\u003e creates\nC:.\n│   .gitignore\n│   CMakeLists.txt\n│   my-new-project.cmake\n├───.vscode\n│       settings.json\n│\n├───cmake.modules\n│       ParseAndAddCatchTests.cmake\n│\n├───include\n│   └───my-new-project\n└───test\n    │   main.cpp\n    │\n    └───include\n        └───my-new-project\n            └───test\n```\n\nTo purge the current directory,\n```\n./cppinit -clean\n```\n\n**Note**: Inovking `cppinit -clean` will delete anything in the `include/` and `test/` directories which means one can lose quite a bit of work. Always make sure `cppinit -clean` is invoked with caution. And always have backups of anything you care about.\n\n## For C++ Beginners\n\nIt's a goal of this project to make using C++ for newcomers simple and\nstraight-forward. `cppinit`'s main strength is that it gives users a project\nwith some useful include paths already configured so they can begin coding\nwithout mucking about.\n\n### Boost\n\nBoost installation steps vary wildly from system to system but in most cases,\none can simply download the compressed source, decompress it and then use the\ndocumentation to build Boost with `b2`, making sure that one uses the `prefix`\noption to create an easy-to-use Boost root folder. Otherwise, the include and\nlibrary directories will both need to be specified.\n\n### Creating Your CMake Toolchain File\n\nOne may notice in the above example that a `my-new-project.cmake` file is generated\nby `cppinit`. This is intended to be an empty CMake toolchain file. Toolchain files\nare easy ways to feed system-specific variables into CMake without polluting the root\n`CMakeLists.txt` file which should only be used for system-agnostic requirements of\nthe project.\n\nSample toolchain file:\n```\n# Sample file for Windows users\n\nset(BOOST_ROOT \"/Users/cmaza/source/boosts/boost_1_67_0_b1\")\nset(Boost_USE_STATIC_LIBS ON)\n\n# directory that contains our catch.hpp file\ninclude_directories(\n  \"/vcpkg/installed/x64-windows/include/catch\"\n)\n```\n\nHere one can see that we define the `BOOST_ROOT` to be the directory where we told\n`b2` to install Boost. We also wish to use only the static libraries and then\nwe help CMake find our installation of Catch which was done via `vcpkg`.\n\nBuilding and testing your project:\n```\ncd my-new-project\nmkdir build_Debug\ncd build_Debug\ncmake \\\n-DCMAKE_TOOLCHAIN_FILE=../my-new-project.cmake \\\n-DCMAKE_BUILD_TYPE=Debug \\\n-G Ninja ..\ncmake --build .\n./my-new-project_tests\n```\n\n`cppinit` ultimately gives the programmer a CMakeLists.txt file that they can\nnow edit and maintain themselves.\n\nThe core project is pulled into a \"core\" lib that is then linked to by the testing binary.\nIt defaults to an INTERFACE library. This needs to be changed if the\ncore library itself becomes non-header-only.\n\n### Using the empty project by writing your first test\n\nAs a good example of what to do with `cppinit`, considering building the sample\ndemo files:\n```\n-------------------------------------------------\ntest/include/my-new-project/test/integral_add.hpp\n-------------------------------------------------\n\n#include \u003cnumeric\u003e\n#include \u003ctype_traits\u003e\n\n// we choose to write a constrained templated function\n// that will only add integral types\n//\ntemplate \u003c\n  typename T,\n  typename = std::enable_if_t\u003cstd::is_integral\u003cT\u003e::value\u003e\n\u003e\nauto integral_add(T const\u0026 a, T const\u0026 b) -\u003e T\n{\n  return a + b;\n}\n\n-------------------------------------------------\ntest/lifting_add_test.cpp\n-------------------------------------------------\n\n#include \u003cvector\u003e\n#include \u003cnumeric\u003e\n#include \u003cboost/hof/lift.hpp\u003e\n#include \"my-new-project/test/integral_add.hpp\"\n\n#include \u003ccatch.hpp\u003e\n\n// we want to use our constrained adding function\n// but we want to make sure we can also use it in\n// higher-order functions\n//\nTEST_CASE(\"do u even lift?\")\n{\n  // 0 + 1 + 2 + 3 + 4 + 5 =\u003e 3 + 3 + 4 + 5 =\u003e 6 + 9 =\u003e 15\n  //\n  auto const input = std::vector\u003cint\u003e{0, 1, 2, 3, 4, 5};\n  auto const sum   = std::accumulate(\n    input.begin(), input.end(),\n    0,\n    BOOST_HOF_LIFT(integral_add));\n\n  REQUIRE(sum == 15);\n}\n```\n\nThen in the CMakeLists.txt file, simply do:\n```\nadd_executable(\n  my-new-project_tests\n\n  ${CMAKE_CURRENT_SOURCE_DIR}/test/main.cpp\n\n  # all we're doing is simply adding this line to the existing file\n  ${CMAKE_CURRENT_SOURCE_DIR}/test/lifting_add_test.cpp\n)\n```\n\nNow, assuming we've run CMake once before with the proper toolchain file,\nall we should need to do now is invoke:\n```\ncmake --build .\nctest .\n```\nfrom the command line and this will both build all the tests and then run\nthem.\n\nExpected output:\n```\nTest project .../build_debug\n    Start 1: my-new-project_tests:do u even lift?\n1/1 Test #1: my-new-project_tests:do u even lift? .....   Passed    0.03 sec\n\n100% tests passed, 0 tests failed out of 1\n\nLabel Time Summary:\nmy-new-project_tests    =   0.03 sec*proc (1 test)\n\nTotal Test time (real) =   0.07 sec\n\n```\n\nFor Windows/msvc users, you'll have to do all this from a Developer Command Prompt.\nUse `vcvarsall` to configure your specific environment.\n\nIn the above example we chose to put the file under our testing directory. This isn't\nstrictly necessary. `cppinit` sets default include paths that let you include anything\nfrom Boost, `./include/` and `./test/include/`. We also add a default directory\n`test/include/my-new-project/test/` so that one can also write a coupled set of tests with\ntheir library itself. This more done out of convenience than anything else.","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmazakas%2Fcppinit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcmazakas%2Fcppinit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcmazakas%2Fcppinit/lists"}