@@ -23,15 +23,77 @@ For more complete systems, see:
2323- [ scikit-build-core] ( https://github.com/scikit-build/scikit-build-core )
2424- [ setuptools] ( https://setuptools.pypa.io/en/latest/userguide/ext_modules.html )
2525
26- ## Environment Variables
27-
28- | Name | Default | Description |
29- | :------------------------- | :------ | :---------- |
30- | ` CC ` | | |
31- | ` CXX ` | | |
32- | ` LD ` | | |
33- | ` HATCH_CPP_PLATFORM ` | | |
34- | ` HATCH_CPP_DISABLE_CCACHE ` | | |
26+ ## Configuration
27+
28+ Configuration is driven from the ` [tool.hatch.build.hooks.hatch-cpp] ` hatch hook configuration field in a ` pyproject.toml ` .
29+ It is designed to closely match existing Python/C/C++ packaging tools.
30+
31+ ``` toml
32+ verbose = true
33+ libraries = { Library Args }
34+ cmake = { CMake Args }
35+ platform = { Platform, either "linux", "darwin", or "win32" }
36+ ```
37+
38+ See the [ test cases] ( ./hatch_cpp/tests/ ) for more concrete examples.
39+
40+ ` hatch-cpp ` is driven by [ pydantic] ( https://docs.pydantic.dev/latest/ ) models for configuration and execution of the build.
41+ These models can themselves be overridden by setting ` build-config-class ` / ` build-plan-class ` .
42+
43+ ### Library Arguments
44+
45+ ``` toml
46+ name = " mylib"
47+ sources = [
48+ " path/to/file.cpp" ,
49+ ]
50+ language = " c++"
51+
52+ binding = " cpython" # or "pybind11", "nanobind", "generic"
53+ std = " " # Passed to -std= or /std:
54+
55+ include_dirs = [" paths/to/add/to/-I" ]
56+ library_dirs = [" paths/to/add/to/-L" ]
57+ libraries = [" -llibraries_to_link" ]
58+
59+ extra_compile_args = [" --extra-compile-args" ]
60+ extra_link_args = [" --extra-link-args" ]
61+ extra_objects = [" extra_objects" ]
62+
63+ define_macros = [" -Ddefines_to_use" ]
64+ undef_macros = [" -Uundefines_to_use" ]
65+
66+ py_limited_api = " cp39" # limited API to use
67+ ```
68+
69+ ### CMake Arguments
70+
71+ ` hatch-cpp ` has some convenience integration with CMake.
72+ Though this is not designed to be as full-featured as e.g. ` scikit-build ` , it should be satisfactory for many small projects.
73+
74+ ``` toml
75+ root = " path/to/cmake/root"
76+ build = " path/to/cmake/build/folder"
77+ install = " path/to/cmake/install/folder"
78+
79+ cmake_arg_prefix = " MYPROJECT_"
80+ cmake_args = {} # any other cmake args to pass
81+ cmake_env_args = {} # env-specific cmake args to pass
82+
83+ include_flags = {} # include flags to pass -D
84+ ```
85+
86+ ### Environment Variables
87+
88+ ` hatch-cpp ` will respect standard environment variables for compiler control.
89+
90+ | Name | Default | Description |
91+ | :------------------------- | :------ | :-------------------- |
92+ | ` CC ` | | C Compiler override |
93+ | ` CXX ` | | C++ Compiler override |
94+ | ` LD ` | | Linker override |
95+ | ` HATCH_CPP_PLATFORM ` | | Platform to build |
96+ | ` HATCH_CPP_DISABLE_CCACHE ` | | Disable CCache usage |
3597
3698> [ !NOTE]
3799> This library was generated using [ copier] ( https://copier.readthedocs.io/en/stable/ ) from the [ Base Python Project Template repository] ( https://github.com/python-project-templates/base ) .
0 commit comments