批量构建CMake工程的Python工具,支持build.json配置和命令行批量编译
Project description
pycmakebuild
Python CMake 批量构建与自动化工具,支持通过 build.json 配置文件和命令行批量编译多个 CMake 项目,适用于跨平台 C++/第三方库工程的自动化批量编译。
功能特性
- 支持 build.json 配置批量管理和编译多个 CMake 项目
- 支持 Debug/Release 等多种构建类型,支持自定义 CMakeLists.txt 子目录
- 支持命令行一键初始化环境、生成模板、批量构建
- 自动推断 CMake 构建参数,兼容 Windows/Linux/Mac
- 支持通过
python -m pycmakebuild或pycmakebuild命令行调用
快速开始
1. 安装
pip install pycmakebuild
2. 初始化环境和模板
python -m pycmakebuild --init
将在当前目录生成 .env 和 build.json 模板。
3. 编辑 build.json
示例:
{
"sources": [
{
"path": "../Log4Qt",
"name": "log4qt",
"cmakelists_subpath": ".",
"other_build_params": ["-DCUSTOM_OPTION=ON"]
}
]
}
path: CMake 项目源码路径name: 目标名称(安装目录名)cmakelists_subpath: CMakeLists.txt 所在子目录(可选,默认".")other_build_params: 传递给 cmake 的额外参数列表(如 ["-DCUSTOM_OPTION=ON"],可选)
4. 批量构建
编译Release版本
python -m pycmakebuild
或编译Debug版本
python -m pycmakebuild --build=Debug
或指定配置文件
python -m pycmakebuild --build=Release --json mybuild.json
会自动检测指定json并批量构建所有配置项目,支持自定义 cmake 参数。
5. 批量更新源码(git工程)
python -m pycmakebuild --clean
更新所有 build.json 中配置的项目源码,不会删除安装目录。
命令行参数
--init初始化环境和 build.json 模板--build [Debug|Release]指定构建类型,支持 --build=Debug 或 --build=Release,默认Release--json <file>指定配置json文件,默认为build.json--clean清理所有 build.json 配置的项目源码(git clean/pull)--version显示版本号
依赖
- python-dotenv:环境变量管理
- cmake:Python CMake 封装
典型应用场景
- 本地一键环境初始化默认构建环境与批量编译CMake三方库
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
pycmakebuild-0.2.12.tar.gz
(8.4 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pycmakebuild-0.2.12.tar.gz.
File metadata
- Download URL: pycmakebuild-0.2.12.tar.gz
- Upload date:
- Size: 8.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
2197cd1fa95f90e861426cf459938fdbad9f66d34bb7a0a43a09c2ca120ec6bb
|
|
| MD5 |
cea81cca6da8d8dff3e0371ec6657dc1
|
|
| BLAKE2b-256 |
0fe41726898235b03825537575541835e788f066e3cbd0801446bf886e65b496
|
File details
Details for the file pycmakebuild-0.2.12-py3-none-any.whl.
File metadata
- Download URL: pycmakebuild-0.2.12-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1b64ce1e633dbea96beb2a1b5810f0208021284aeb3963b4e6c7582bb710c5b2
|
|
| MD5 |
60159e78af80c62c77d515629501f9a5
|
|
| BLAKE2b-256 |
add05fe2af05bceaa72e1db9c7c553a05af9f676331c4d45a5725cce79b8ffbb
|