2525__all__ = [
2626 "BuildCMake" ,
2727 "cmake_args" ,
28+ "cmake_install_target" ,
2829 "cmake_source_dir" ,
2930 "finalize_distribution_options" ,
3031]
@@ -60,6 +61,7 @@ def get_source_dir_from_pyproject_toml() -> str | None:
6061class BuildCMake (setuptools .Command ):
6162 source_dir : str | None = None
6263 cmake_args : list [str ] | str | None = None
64+ cmake_install_target : str | None = None
6365
6466 build_lib : str | None
6567 build_temp : str | None
@@ -74,8 +76,9 @@ class BuildCMake(setuptools.Command):
7476 ("plat-name=" , "p" , "platform name to cross-compile for, if supported " ),
7577 ("debug" , "g" , "compile/link with debugging information" ),
7678 ("parallel=" , "j" , "number of parallel build jobs" ),
77- ("source-dir=" , "j " , "directory with CMakeLists.txt" ),
79+ ("source-dir=" , "s " , "directory with CMakeLists.txt" ),
7880 ("cmake-args=" , "a" , "extra arguments for CMake" ),
81+ ("cmake-install-target=" , "" , "CMake target to install" ),
7982 ]
8083
8184 def initialize_options (self ) -> None :
@@ -87,6 +90,7 @@ def initialize_options(self) -> None:
8790 self .plat_name = None
8891 self .source_dir = get_source_dir_from_pyproject_toml ()
8992 self .cmake_args = None
93+ self .cmake_install_target = None
9094
9195 def finalize_options (self ) -> None :
9296 self .set_undefined_options (
@@ -180,7 +184,7 @@ def run(self) -> None:
180184 builder .build (build_args = build_args )
181185 builder .install (install_dir = install_dir )
182186
183- # def "get_source_file+ys "(self) -> list[str]:
187+ # def "get_source_file"(self) -> list[str]:
184188 # return ["CMakeLists.txt"]
185189
186190 # def get_outputs(self) -> list[str]:
@@ -260,3 +264,13 @@ def cmake_source_dir(
260264 if not Path (value ).is_dir ():
261265 msg = "cmake_source_dir must be an existing directory"
262266 raise setuptools .errors .SetupError (msg )
267+
268+
269+ def cmake_install_target (
270+ dist : Distribution , attr : Literal ["cmake_install_target" ], value : str
271+ ) -> None :
272+ assert attr == "cmake_install_target"
273+ assert value is not None
274+ _cmake_extension (dist )
275+ msg = "cmake_install_target is not supported - please use components and build targets instead"
276+ raise setuptools .errors .SetupError (msg )
0 commit comments