{"id":13830862,"url":"https://github.com/qqiangwu/cppship","last_synced_at":"2025-10-23T11:32:00.188Z","repository":{"id":152870478,"uuid":"625312213","full_name":"qqiangwu/cppship","owner":"qqiangwu","description":"Cargo-like build tool for modern cpp","archived":false,"fork":false,"pushed_at":"2024-02-08T10:26:11.000Z","size":178,"stargazers_count":64,"open_issues_count":2,"forks_count":6,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-01-30T18:38:09.608Z","etag":null,"topics":["cargo","cmake","conan","cpp","modern-cpp"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsl-1.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/qqiangwu.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":"2023-04-08T18:10:52.000Z","updated_at":"2024-12-20T20:20:08.000Z","dependencies_parsed_at":"2024-02-08T05:27:24.037Z","dependency_job_id":"cdacb34b-7f86-4c45-b3c4-330208303efb","html_url":"https://github.com/qqiangwu/cppship","commit_stats":null,"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qqiangwu%2Fcppship","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qqiangwu%2Fcppship/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qqiangwu%2Fcppship/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/qqiangwu%2Fcppship/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/qqiangwu","download_url":"https://codeload.github.com/qqiangwu/cppship/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":237821683,"owners_count":19371806,"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":["cargo","cmake","conan","cpp","modern-cpp"],"created_at":"2024-08-04T10:01:10.778Z","updated_at":"2025-10-23T11:31:59.880Z","avatar_url":"https://github.com/qqiangwu.png","language":"C++","readme":"[![Linux](https://github.com/qqiangwu/cppship/actions/workflows/ci-linux.yml/badge.svg?branch=main)](https://github.com/qqiangwu/cppship/actions/workflows/ci-linux.yml)\n[![macOS](https://github.com/qqiangwu/cppship/actions/workflows/ci-macos.yml/badge.svg?branch=main)](https://github.com/qqiangwu/cppship/actions/workflows/ci-macos.yml)\n[![Windows](https://github.com/qqiangwu/cppship/actions/workflows/ci-windows.yml/badge.svg?branch=main)](https://github.com/qqiangwu/cppship/actions/workflows/ci-windows.yml)\n\n# Intro\nA cargo-like modern cpp build tools, aimed to combine all existing best practices, rather than re-inventing them from scratch.\n\n+ dependency management: [conan2](https://conan.io/)\n  + you can also directly declare a header-only lib on git as a dependency since we already have tons of such libs\n  + you can also directly declare a cppship lib on git as a dependency\n  + we will not support import arbitrary libs on git since it will make our package less composable\n+ build: [cmake](https://cmake.org/)\n  + Cppship use cmake as the underlying build tool\n  + You can also run `cppship cmake` to convert a cppship project to CMake project\n+ tests: google test\n+ benches: google bench\n+ format: clang-format\n+ lint: clang-tidy\n\nFurther details can be found in [wiki](https://github.com/qqiangwu/cppship/wiki)\n\n# Goals\n+ Super easy to start a new project without any googling and boilerplate code\n+ Super easy to use a thirdparty package\n+ Packages can be composed arbitrarily\n+ Newbees can create a standard project easily, including tests, benchmarks, examples, documents, format, lint\n+ Do simple things simple, but reserve mechanism for hard things\n\nThe above goals are achieved by the following features:\n\n+ Use `cppship init \u003cname\u003e` or `cppship init --lib \u003cname\u003e` to start a new project\n+ Use `conan2` to import dependencies\n  + You can also import a header-only package on git or a cppship package on git\n  + Git-based dependencies are not stable, and is subject to change\n+ Cppship packages can import other cppship packages as dependencies (not stable now)\n+ Creating a test, benchmark, example only involves a single file creation\n+ Project structure are standardized, by default you only need to create cpp files and `cppship run` or `cppship test` or `cppship bench` without any configuration or boilerplate code\n\n# Demo\n![demo](https://user-images.githubusercontent.com/2892107/232242145-bcc4bb3f-21c0-41a6-919a-9b5f5b196246.gif)\n\n# Install\n## Predefined packages\n### MacOS\n```bash\n$ brew install qqiangwu/tap/cppship\n```\n\n### Linux\nTry [homebrew](https://brew.sh/), or build it yourself, see below.\n\n\n## CMake\nWe can use cmake to build `cppship`\n\n```bash\nmkdir build\ncmake -B build -S . -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON\n\ncmake --build build -j8\ncmake --build build -j8 --target install\n```\n\n## Cppship\nWe can also use cppship to build `cppship`\n\n```bash\n# install\ncppship install\n```\n\n# Tutorial\nCppship will generate cmake projects based on your directory structure and cppship.toml.\n\nSee [examples](https://github.com/qqiangwu/cppship-examples)\n\n## cppship.toml\n```toml\n[package]\n# (required) your lib or binary name\nname = \"cppship\"\n# (required)\nversion = \"0.0.1\"\nauthors = []\n# (optional) specifiy you cppstd\nstd = 20\n\n[dependencies]\n# conan dependencies\nboost = { version = \"1.81.0\", components = [\"headers\"], options = { header_only = true } }\ntoml11 = \"3.7.1\"\nfmt = \"9.1.0\"\nrange-v3 = \"0.12.0\"\nbshoshany-thread-pool = \"3.3.0\"\nms-gsl = \"4.0.0\"\nargparse = \"2.9\"\nspdlog = \"1.11.0\"\n# git header-only libs\nscope_guard = { git = \"https://github.com/Neargye/scope_guard.git\", commit = \"fa60305b5805dcd872b3c60d0bc517c505f99502\" }\n\n# git cppship header only lib\nheader_only = { git = \"https://github.com/cppship/demo_header_only.git\", commit = \"93f6793\" }\n\n# git cppship lib\nsimple_lib = { git = \"https://github.com/cppship/demo_lib.git\", commit = \"25dbedf\" }\n\n[dev-dependencies]\nscnlib = \"1.1.2\"\n\n[profile]\ndefinitions = [\"BOOST_PROCESS_USE_STD_FS\"]\nubsan = true\nasan = true\ntsan = false\nleak = false\n\n[target.'cfg(not(compiler = \"msvc\"))'.profile]\ncxxflags = [\"-Wall\", \"-Wextra\", \"-Werror\", \"-Wno-unused-parameter\", \"-Wno-missing-field-initializers\"]\n\n[target.'cfg(compiler = \"msvc\")'.profile]\ncxxflags = [\"/Zc:__cplusplus\", \"/Zc:preprocessor\", \"/MP\"]\n\n[profile.debug]\n# appends to cxxflags in [profile]\ncxxflags = [\"-g\"]\n\n# merged with definitions in [profile]\ndefinitions = [\"C\"]\n\n[profile.release]\n# appends to cxxflags in [profile]\ncxxflags = [\"-O3\", \"-DNDEBUG\"]\n```\n\n## header-only lib\nmake sure your project have the following structure:\n\n+ include: lib include dir\n+ tests: test cpp files go here, optional, `lib` will be its dependency\n\n## lib\nmake sure your project have the following structure:\n\n+ include: lib include dir\n+ lib: lib cpp files go here\n+ tests: test cpp files go here, optional, `lib` will be its dependency\n\n## binary\nmake sure your project have the following structure:\n\n+ src: binary cpp files go here, currently only one binary is supported\n\n## lib + binary\n+ include: lib include dir\n+ lib: lib cpp files go here\n+ src: bin cpp files go here, `lib` will be its dependency\n+ tests: test cpp files go here, optional, `lib` and `gtest` will be its dependency\n\n## multiple binaries\n+ src/main.cpp: primary binary named with your project name\n+ src/bin/xxx.cpp: binary xxx\n+ src/bin/yyy.cpp: binary yyy\n\n## inner tests\n+ lib/a_test.cpp: will be viewed as a test\n+ lib/sub/b_test.cpp: will be viewed as a test\n\n## examples\n+ include\n+ lib\n+ src\n+ tests\n+ examples\n  + ex1.cpp: depends on lib\n  + ex2.cpp: depends on lib\n\n## benchmarks\n+ benches\n  + b1.cpp: depends on lib, google benchmark\n  + b2.cpp: depends on lib, google benchmark\n\n# Convert to cmake project\nYou can easily convert a cppship project into a cmake project:\n\n```bash\n# CMakeFiles.txt and conanfiles.txt will be generated under the project root dir\ncppship cmake\n\n# Build with cmake\ncmake -S . -B build -DCMAKE_BUILD_TYPE=Debug\ncmake --build build\n```\n\n# Usage\n## Init\n```bash\n# init a binary\ncppship init demo\ncd demo\ncppship run\ncppship test\n\n# init a library\ncppship init demolib --lib\ncd demolib\ncppship build\n```\n\n## build\n```bash\n# debug build\ncppship build\n\n# release build\ncppship build -r\n\n# dry-run, config cmake and generate compile_commands.json under build\ncppship build -d\n\n# build tests only\ncppship build --tests\n\n# build examples only\ncppship build --examples\n\n# build benches only\ncppship build --benches\n\n# build binaries only\ncppship build --bins\n```\n\n## run\n```bash\ncppship run\ncppship run -- a b c extra_args\n\n# run a binary\ncppship run --bin \u003cname\u003e\n\n# run an example\ncppship run --example \u003cname\u003e\n```\n\n## test\n```bash\ncppship test\ncppship test --rerun-failed\ncppship test \u003ctestname\u003e\ncppship test -R \u003ctestname-regex\u003e\n```\n\n## bench\n```bash\ncppship bench\n\ncppship bench \u003cbench-name\u003e\n```\n\n## install\n```bash\ncppship install\n```\n\n## clean\n```bash\ncppship clean\n```\n\n## format\nWe will use `clang-format` to format our code\n\n```bash\n# by default, only format files changed since last commit\n# dry-run and warn\ncppship fmt\n# only fmt git cached files\ncppship fmt --cached\n# fix it\ncppship fmt -f\n\n# reun against commit\ncppship fmt -c \u003ccommit\u003e\n\n# format all files\ncppship fmt -a\ncppship fmt -a -f\n```\n\n## lint\nWe will use `clang-tidy` to lint your code\n\n```bash\n# by default, only lint files changed since last commit\ncppship lint\n# lint git cached files\ncppship lint --cached\n# lint all\ncppship lint -a\n# lint against commit\ncppship lint -c \u003ccommit\u003e\n```\n\n# Integration with VSCode\nNow cppship has no extensions for VSCode, but use `clangd` is enough. Just write your project and run `cppship build -d`, which will create  `build/compile_commands.json`. Clangd will find it and do its work.\n","funding_links":[],"categories":["C++"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqqiangwu%2Fcppship","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fqqiangwu%2Fcppship","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fqqiangwu%2Fcppship/lists"}