Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,9 @@ cmake.build-type = "Release"
# The source directory to use when building the project.
cmake.source-dir = "."

# CMake cache file to be loaded.
cmake.cache-file = ""

# The versions of Ninja to allow.
ninja.version = ">=1.5"

Expand Down
7 changes: 7 additions & 0 deletions docs/reference/configs.md
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,13 @@ print(mk_skbuild_docs())
Custom values can also be used.
```

```{eval-rst}
.. confval:: cmake.cache-file
:type: ``Path``

CMake cache file to be loaded.
```

```{eval-rst}
.. confval:: cmake.define
:type: ``EnvVar``
Expand Down
9 changes: 8 additions & 1 deletion src/scikit_build_core/builder/builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,6 +281,9 @@ def configure(
cache_config.update(cache_entries)

self.config.init_cache(cache_config)
cache_file_args = []
if self.settings.cmake.cache_file:
cache_file_args.append(f"-C{self.settings.cmake.cache_file}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be good to test this, especially on Windows, to make sure that there isn't anything weird with path separators or escape characters. My Windows test machines are down right now, but I can probably help next week, if needed.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point I will try to add it. It shouldn't be any issue because we use Path in other parts as well without special handling (build-dir or source-dir), so that part should be fine (or we need to fix it in various places).

What I want to be covered though is the order of these flags and that those are predictable.


if sys.platform.startswith("darwin"):
# Cross-compile support for macOS - respect ARCHFLAGS if set
Expand All @@ -293,7 +296,11 @@ def configure(

self.config.configure(
defines=cmake_defines,
cmake_args=[*self.get_cmake_args(), *configure_args],
cmake_args=[
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we have a note for the record somewhere? The initial cache file generated by scikit-build-core will be added to the end of the argument list, or the beginning? Do we expect the cache files to be processed sequentially? The AIs I ask disagree on how CMake handles multiple -C arguments.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be after the first -C that we add, but otherwise the order is a bit ill defined, I'll try to do some troubleshooting to see how -D flags impact it and if we need to reorder it.

But on that note, should this be a single option or a list of cache files?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof. Well, I guess it wouldn't be too hard to accept a sequence, but I don't personally need it. I guess the processing would be similar to cmake.define, so it wouldn't be unusual or surprising for users or developers.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am open to either approach. It's just that this decision needs to be definite so that we don't change the schema afterwards. We ave cmake.args for more free-style args if needed

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since cmake accepts multiple -C arguments, it would seem more correct to accept a list. I can't think of a good reason not to accept a list other than the effort and extra burden of support (documentation, test coverage, ...)

*cache_file_args,
*self.get_cmake_args(),
*configure_args,
],
)

def build(self, build_args: Sequence[str]) -> None:
Expand Down
4 changes: 4 additions & 0 deletions src/scikit_build_core/resources/scikit-build.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,10 @@
},
"description": "DEPRECATED in 0.10; use build.targets instead.",
"deprecated": true
},
"cache-file": {
"type": "string",
"description": "CMake cache file to be loaded."
}
}
},
Expand Down
5 changes: 5 additions & 0 deletions src/scikit_build_core/settings/skbuild_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,11 @@ class CMakeSettings:
DEPRECATED in 0.10; use build.targets instead.
"""

cache_file: Optional[Path] = None
"""
CMake cache file to be loaded.
"""


@dataclasses.dataclass
class SearchSettings:
Expand Down
Loading