Skip to main content

crt-cpp-app

crt-cpp-app 是一个跨平台的命令行工具,用于快速创建可由 CMake 构建的 C++ 项目。

工具会生成可执行程序、静态库、动态库以及常用的 inc/、res/、3rd/、patch/ 和 cmake/ 目录,并支持 C++17 和 C++20。安装完成后,各种发行包都使用相同的命令和参数。

crt-cpp-app is a cross-platform command-line scaffolding tool for C++ CMake projects. It interactively creates a ready-to-build project layout with executable, static-library, shared-library, and reusable CMake components, supporting C++17 and C++20. All distribution packages provide the same command and options after installation.

项目主页:https://github.com/PrettyCADStudio/crt-cpp-app

问题反馈:https://github.com/PrettyCADStudio/crt-cpp-app/issues

安装 Python CLI

需要 Python 3.9 或更高版本。使用 pip 安装:

pip install crt-cpp-app

建议在虚拟环境中安装。PyPI wheel 已包含自包含应用,不需要安装 .NET runtime 或 SDK;Linux 需要 glibc 2.17 或更高版本。

验证安装:

crt-cpp-app --version
python -m crt_cpp_app --version

卸载 Python CLI

在安装该工具的同一个 Python 环境中运行:

pip uninstall crt-cpp-app

使用方法

命令格式

crt-cpp-app [选项]

命令选项

选项 说明
-f、--force 同名项目目录存在时删除并重新创建,不再询问。
--where 输出当前正在运行的可执行程序路径。
--version 显示工具版本。
-h、-?、--help 显示帮助信息。

创建项目

在目标父目录中运行:

crt-cpp-app

工具会依次询问项目名称、C++ 标准(17 或 20)以及是否生成 Python 开发辅助脚本。完成后会在当前目录创建项目目录。

项目名称必须以英文字母或下划线开头,后续只能包含英文字母、数字、下划线或连字符。

覆盖已有项目

使用 --force 跳过确认并覆盖同名目录:

crt-cpp-app --force

该选项会递归删除已有目录,请确认其中内容可以删除。

生成的项目

默认结构如下:

my-app/
├── CMakeLists.txt
├── cmake/my-app.cmake
├── inc/my-app.h
├── res/
├── 3rd/
├── patch/
└── src/
    ├── App/
    ├── Static/
    └── Dynamic/

进入项目后使用 CMake 构建:

cd my-app
cmake -S . -B build
cmake --build build --config Release

输出位置取决于生成器。Visual Studio 通常为 bin/Release/App.exe,Ninja 或 Unix Makefiles 通常为 bin/App。

使用 Python 开发脚本

创建项目时选择 Python 开发辅助脚本后,会生成以下脚本:

  • mksln.py:配置 CMake 并生成构建文件。
  • build.py:配置并编译项目。
  • install.py:执行 CMake 安装,可通过 --prefix 指定安装目录。
  • build-install.py:依次执行构建和安装。
  • archive.py:构建项目并将 bin/ 打包到 dist/。

直接使用 Python

直接 Python 模式将脚本放在项目根目录,进入项目目录后运行:

python mksln.py
python build.py --config Release
python install.py --config Release --prefix install
python build-install.py --config Release
python archive.py --config Release

通过 Pipenv 使用 Python

Pipenv 模式将脚本放在 scripts/,并在项目根目录生成 Pipfile。首次使用时安装 Pipenv 并创建环境:

python -m pip install pipenv
pipenv install

随后使用 Pipfile 中的快捷命令:

pipenv run mksln
pipenv run build --config Release
pipenv run install --config Release --prefix install
pipenv run build-install --config Release
pipenv run archive --config Release

常用查询

crt-cpp-app --version
crt-cpp-app --where
crt-cpp-app --help

许可信息

本项目采用 MIT License 发布。

Copyright (c) PrettyCAD Studio

Metadata

Release files for crt-cpp-app 0.1.14

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for crt-cpp-app 0.1.14
File Interpreter ABI Platform
crt_cpp_app-0.1.14-py3-none-win_amd64.whl Python 3 none Windows x86-64 Details
crt_cpp_app-0.1.14-py3-none-manylinux_2_17_x86_64.whl Python 3 none Linux glibc 2.17+ x86-64 Details
crt_cpp_app-0.1.14-py3-none-macosx_12_0_universal2.whl Python 3 none macOS 12.0+ universal2 (ARM64, x86-64) Details

Total release size: 105.0 MB

Release files / crt_cpp_app-0.1.14-py3-none-win_amd64.whl

Download URL crt_cpp_app-0.1.14-py3-none-win_amd64.whl
Size 36.0 MB
Tags Python 3 Windows x86-64
SHA-256 checksum
How to use checksums
0467bd8905827113417c106ffb57675db4aa3dc343963c5117110edef0c92c6a
BLAKE2b-256 checksum
How to use checksums
1e421c31fc06cdff3b9f89b65e66f05ac60d217db436410fee17832c6e72c263
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / crt_cpp_app-0.1.14-py3-none-manylinux_2_17_x86_64.whl

Download URL crt_cpp_app-0.1.14-py3-none-manylinux_2_17_x86_64.whl
Size 36.1 MB
Tags Linux glibc 2.17+ x86-64 Python 3
SHA-256 checksum
How to use checksums
b5c9d29d7ecc844de9c6dae42ed14fbc9c63779bd6f805c787acc98d7d1aabdb
BLAKE2b-256 checksum
How to use checksums
aabecb99d209a449066d3b43ac64e8cc446d88e1730f991e9030d1dcd8fe6bfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release files / crt_cpp_app-0.1.14-py3-none-macosx_12_0_universal2.whl

Download URL crt_cpp_app-0.1.14-py3-none-macosx_12_0_universal2.whl
Size 32.9 MB
Tags Python 3 macOS 12.0+ universal2 (ARM64, x86-64)
SHA-256 checksum
How to use checksums
f2d2e641999b5b0036ea2470ee03e170c5ceb643e5c676aa9d3692a566735bb1
BLAKE2b-256 checksum
How to use checksums
2dfcb3eb1da1ec00eec8b65ba3fbe9ed7b1b2b3c42149281b4cfa659fd0d5101
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.14

Release history Release notifications | RSS feed

This release

0.1.14 This release

3 release files

0.1.9

3 release files

0.1.8

3 release files

0.1.7

3 release files

0.1.6

3 release files

0.1.5

3 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page