-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Cristian Le <[email protected]>
- Loading branch information
Showing
3 changed files
with
260 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,6 +32,7 @@ getting_started | |
configuration | ||
overrides | ||
cmakelists | ||
search_paths | ||
crosscompile | ||
migration_guide | ||
build | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,252 @@ | ||
# Search paths | ||
|
||
Scikit-build-core populates CMake search paths to take into account any other | ||
CMake project installed in the same environment. | ||
|
||
## `<PackageName>_ROOT` | ||
|
||
This is the most recommended interface to be used for importing dependent | ||
packages using `find_package`. This variable is populated by the dependent | ||
project's entry-point `cmake.root` or by the current project's `search.roots` | ||
option, the latter having a higher priority. | ||
|
||
To configure the `cmake.root` entry-point to export to other projects, you | ||
can use the CMake standard install paths in you `CMakeLists.txt` if you use | ||
`wheel.install-dir` option, e.g. | ||
|
||
```{code-block} cmake | ||
:caption: CMakeLists.txt | ||
:emphasize-lines: 14-16 | ||
include(CMakePackageConfigHelpers) | ||
include(GNUInstallDirs) | ||
write_basic_package_version_file( | ||
MyProjectConfigVersion.cmake | ||
VERSION ${PROJECT_VERSION} | ||
COMPATIBILITY SameMajorVersion | ||
) | ||
configure_package_config_file( | ||
cmake/MyProjectConfig.cmake.in | ||
MyProjectConfig.cmake | ||
INSTALL_DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MyProject | ||
) | ||
install(FILES | ||
${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfigVersion.cmake | ||
${CMAKE_CURRENT_BINARY_DIR}/MyProjectConfig.cmake | ||
DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/MyProject | ||
) | ||
``` | ||
```{code-block} toml | ||
:caption: pyproject.toml | ||
:emphasize-lines: 2,5 | ||
[tool.scikit-build] | ||
wheel.install-dir = "myproject" | ||
[project.entry-points."cmake.root"] | ||
MyProject = "myproject" | ||
``` | ||
|
||
:::{note} | ||
|
||
Scikit-build-core does not currently support dynamic entry-points population. | ||
|
||
::: | ||
|
||
With this any consuming project that depends on this would automatically work | ||
with `find_package(MyProject)` as long as it is in the `build-system.requires` | ||
list. | ||
|
||
You can use `search.roots` to override or extend these variables, e.g. you can | ||
delete the `MyProject_ROOT` variable by setting | ||
|
||
````{tab} pyproject.toml | ||
|
||
```toml | ||
[tool.scikit-build.search.roots] | ||
MyProject = "" | ||
``` | ||
|
||
```` | ||
|
||
`````{tab} config-settings | ||
````{tab} pip | ||
```console | ||
$ pip install . -v --config-settings=search.roots.MyProject="" | ||
``` | ||
```` | ||
````{tab} build | ||
```console | ||
$ pipx run build --wheel -Csearch.roots.MyProject="" | ||
``` | ||
```` | ||
````{tab} cibuildwheel | ||
```toml | ||
[tool.cibuildwheel.config-settings] | ||
"search.roots.MyProject" = "" | ||
``` | ||
```` | ||
````` | ||
|
||
````{tab} Environment | ||
```yaml | ||
SKBUILD_SEARCH_ROOTS_MyProject: "" | ||
``` | ||
```` | ||
|
||
Or you could point to another preferred path: | ||
|
||
|
||
````{tab} pyproject.toml | ||
|
||
```toml | ||
[tool.scikit-build.search.roots] | ||
MyProject = "other_project" | ||
``` | ||
|
||
```` | ||
|
||
`````{tab} config-settings | ||
````{tab} pip | ||
```console | ||
$ pip install . -v --config-settings=search.roots.MyProject="other_project" | ||
``` | ||
```` | ||
````{tab} build | ||
```console | ||
$ pipx run build --wheel -Csearch.roots.MyProject="other_project" | ||
``` | ||
```` | ||
````{tab} cibuildwheel | ||
```toml | ||
[tool.cibuildwheel.config-settings] | ||
"search.roots.MyProject" = "other_project" | ||
``` | ||
```` | ||
````` | ||
|
||
````{tab} Environment | ||
```yaml | ||
SKBUILD_SEARCH_ROOTS_MyProject: "other_project" | ||
``` | ||
```` | ||
|
||
## `CMAKE_PREFIX_PATH` | ||
|
||
Another common search path that scikit-build-core populates is the | ||
`CMAKE_PREFIX_PATH` which is a common catch-all for all CMake search paths, | ||
e.g. `find_package`, `find_program`, `find_path`. This is populated by default | ||
with the install and build path's `site-packages` folder, but this can be | ||
disabled by setting | ||
|
||
```toml | ||
[tool.scikit-build.search] | ||
search.use-install-prefix = false | ||
search.use-build-prefix = false | ||
``` | ||
|
||
Additionally, scikit-build-core reads the entry-point `cmake.prefix` and the | ||
option `search.prefixes` to prepend to this path list. You can similarly export | ||
this as | ||
|
||
``` toml | ||
[project.entry-points."cmake.prefix"] | ||
MyProject = "myproject" | ||
``` | ||
|
||
and you can similarly delete this entry-point variable | ||
|
||
````{tab} pyproject.toml | ||
|
||
```toml | ||
[tool.scikit-build.search.prefixes] | ||
MyProject = "" | ||
``` | ||
|
||
```` | ||
|
||
`````{tab} config-settings | ||
````{tab} pip | ||
```console | ||
$ pip install . -v --config-settings=search.prefixes.MyProject="" | ||
``` | ||
```` | ||
````{tab} build | ||
```console | ||
$ pipx run build --wheel -Csearch.prefixes.MyProject="" | ||
``` | ||
```` | ||
````{tab} cibuildwheel | ||
```toml | ||
[tool.cibuildwheel.config-settings] | ||
"search.prefixes.MyProject" = "" | ||
``` | ||
```` | ||
````` | ||
|
||
````{tab} Environment | ||
```yaml | ||
SKBUILD_SEARCH_PREFIXES_MyProject: "" | ||
``` | ||
```` | ||
|
||
If you only wish to expand the prefix path, you can also define | ||
`search.prefixes` as a list | ||
|
||
```toml | ||
[tool.scikit-build.search] | ||
prefixes = ["/path/to/prefixA", "/path/to/prefixB"] | ||
``` | ||
|
||
## `CMAKE_MODULE_PATH` | ||
|
||
Scikit-build-core also populates `CMAKE_MODULE_PATH` variable used to search | ||
for CMake modules using the `include()` command (if the `.cmake` suffix is | ||
omitted). | ||
|
||
This variable is populated from the entry-point `cmake.module` and the option | ||
`search.modules` similar to [`CMAKE_PREFIX_PATH`] section. | ||
|
||
[`CMAKE_PREFIX_PATH`]: #cmake-prefix-path |