1313from typing import TYPE_CHECKING , Any
1414
1515from . import __version__
16+ from ._compat .builtins import ExceptionGroup
1617from ._logging import logger
1718from ._shutil import Run
1819from .errors import CMakeConfigError , CMakeNotFoundError , FailedLiveProcessError
20+ from .file_api .query import stateless_query
21+ from .file_api .reply import load_reply_dir
1922from .program_search import Program , best_program , get_cmake_program , get_cmake_programs
2023
2124if TYPE_CHECKING :
2528 from packaging .version import Version
2629
2730 from ._compat .typing import Self
31+ from .file_api .model .index import Index
2832
2933__all__ = ["CMake" , "CMaker" ]
3034
@@ -83,6 +87,8 @@ class CMaker:
8387 init_cache_file : Path = dataclasses .field (init = False , default = Path ())
8488 env : dict [str , str ] = dataclasses .field (init = False , default_factory = os .environ .copy )
8589 single_config : bool = not sysconfig .get_platform ().startswith ("win" )
90+ file_api : Index | None = None
91+ _file_api_query : Path = dataclasses .field (init = False )
8692
8793 def __post_init__ (self ) -> None :
8894 self .init_cache_file = self .build_dir / "CMakeInit.txt"
@@ -97,6 +103,8 @@ def __post_init__(self) -> None:
97103 msg = f"build directory { self .build_dir } must be a (creatable) directory"
98104 raise CMakeConfigError (msg )
99105
106+ # TODO: This could be stateful instead
107+ self ._file_api_query = stateless_query (self .build_dir )
100108 skbuild_info = self .build_dir / ".skbuild-info.json"
101109 stale = False
102110
@@ -253,6 +261,13 @@ def configure(
253261 msg = "CMake configuration failed"
254262 raise FailedLiveProcessError (msg ) from None
255263
264+ try :
265+ if self ._file_api_query .exists ():
266+ self .file_api = load_reply_dir (self ._file_api_query )
267+ except ExceptionGroup as exc :
268+ logger .warning ("Could not parse CMake file-api" )
269+ logger .debug (str (exc ))
270+
256271 def _compute_build_args (
257272 self ,
258273 * ,
0 commit comments