@@ -58,8 +58,9 @@ def get_source_dir_from_pyproject_toml() -> str | None:
5858
5959
6060class BuildCMake (setuptools .Command ):
61- source_dir : str | None = None
61+ cmake_source_dir : str | None = None
6262 cmake_args : list [str ] | str | None = None
63+ cmake_install_target : str | None = None
6364
6465 build_lib : str | None
6566 build_temp : str | None
@@ -74,8 +75,9 @@ class BuildCMake(setuptools.Command):
7475 ("plat-name=" , "p" , "platform name to cross-compile for, if supported " ),
7576 ("debug" , "g" , "compile/link with debugging information" ),
7677 ("parallel=" , "j" , "number of parallel build jobs" ),
77- ("source-dir=" , "j " , "directory with CMakeLists.txt" ),
78+ ("cmake- source-dir=" , "" , "directory with CMakeLists.txt" ),
7879 ("cmake-args=" , "a" , "extra arguments for CMake" ),
80+ ("cmake-install-target=" , "" , "CMake target to install" ),
7981 ]
8082
8183 def initialize_options (self ) -> None :
@@ -85,8 +87,9 @@ def initialize_options(self) -> None:
8587 self .editable_mode = False
8688 self .parallel = None
8789 self .plat_name = None
88- self .source_dir = get_source_dir_from_pyproject_toml ()
90+ self .cmake_source_dir = get_source_dir_from_pyproject_toml ()
8991 self .cmake_args = None
92+ self .cmake_install_target = None
9093
9194 def finalize_options (self ) -> None :
9295 self .set_undefined_options (
@@ -116,7 +119,9 @@ def run(self) -> None:
116119
117120 dist = self .distribution
118121 dist_source_dir = getattr (self .distribution , "cmake_source_dir" , None )
119- source_dir = self .source_dir if dist_source_dir is None else dist_source_dir
122+ source_dir = (
123+ self .cmake_source_dir if dist_source_dir is None else dist_source_dir
124+ )
120125 assert source_dir is not None , "This should not be reachable"
121126
122127 configure_args = self .cmake_args or []
@@ -180,7 +185,7 @@ def run(self) -> None:
180185 builder .build (build_args = build_args )
181186 builder .install (install_dir = install_dir )
182187
183- # def "get_source_file+ys "(self) -> list[str]:
188+ # def "get_source_file"(self) -> list[str]:
184189 # return ["CMakeLists.txt"]
185190
186191 # def get_outputs(self) -> list[str]:
@@ -194,7 +199,7 @@ def _has_cmake(dist: Distribution) -> bool:
194199 build_cmake = dist .get_command_obj ("build_cmake" )
195200 assert isinstance (build_cmake , BuildCMake )
196201 return (
197- build_cmake .source_dir is not None
202+ build_cmake .cmake_source_dir is not None
198203 or getattr (dist , "cmake_source_dir" , None ) is not None
199204 )
200205
@@ -260,3 +265,13 @@ def cmake_source_dir(
260265 if not Path (value ).is_dir ():
261266 msg = "cmake_source_dir must be an existing directory"
262267 raise setuptools .errors .SetupError (msg )
268+
269+
270+ def cmake_install_target (
271+ dist : Distribution , attr : Literal ["cmake_install_target" ], value : str
272+ ) -> None :
273+ assert attr == "cmake_install_target"
274+ assert value is not None
275+ _cmake_extension (dist )
276+ msg = "cmake_install_target is not supported - please use components and build targets instead"
277+ raise setuptools .errors .SetupError (msg )
0 commit comments