@@ -298,40 +298,8 @@ def resolve_build_directory(self, build_dir_list=None, *, automatic_discovery=Tr
298298 self .build_dir ,
299299 )
300300
301- def setup_cmake_args (self , cmake_args ): # noqa: C901
302- """
303- Setup CMake arguments.
304-
305- Args:
306- cmake_args: Dictionary-like data structure with following keys:
307- - 'defines': list[str]
308- - 'undefined': list[str]
309- - 'errors': list[str]
310- - 'no_errors': list[str]
311- - 'generator': str
312- - 'toolset': str
313- - 'platform': str
314- - 'preset': str
315- - 'cmake': str
316- - 'dev_warnings': bool
317- - 'no_dev_warnings': bool
318- - 'linux': list[str]
319- - 'mac': list[str]
320- - 'win': list[str]
321- """
322- self .source_dir = Path (cmake_args .source_dir ).resolve ()
323- if cmake_args .cmake :
324- self .command = [Path (cmake_args .cmake ).resolve ()]
325- self .no_cmake_configure = cmake_args .no_cmake_configure
326-
327- self .resolve_build_directory (
328- build_dir_list = cmake_args .build_dir ,
329- automatic_discovery = cmake_args .automatic_discovery ,
330- )
331-
332- if cmake_args .detect_configured_files and self .build_dir :
333- self .cmake_trace_log = self .build_dir / self .DEFAULT_TRACE_LOG
334-
301+ def _process_keyword_cmake_args (self , cmake_args ):
302+ """Process keyword-style CMake arguments."""
335303 keyword_args = {
336304 'defines' : ([], '-D{}' ),
337305 'undefines' : ([], '-U{}' ),
@@ -352,6 +320,8 @@ def setup_cmake_args(self, cmake_args): # noqa: C901
352320 for element in value :
353321 self .cmake_args .append (format_str .format (element ))
354322
323+ def _process_flag_cmake_args (self , cmake_args ):
324+ """Process flag-style CMake arguments."""
355325 flag_args = {
356326 'dev_warnings' : (False , '-Wdev' ),
357327 'no_dev_warnings' : (False , '-Wno_dev' ),
@@ -360,18 +330,58 @@ def setup_cmake_args(self, cmake_args): # noqa: C901
360330 if getattr (cmake_args , key , default ):
361331 self .cmake_args .append (flag_str )
362332
363- platform_args = {
333+ def _process_platform_cmake_args (self , cmake_args ):
334+ """Process platform-specific CMake arguments."""
335+ platform_args_config = {
364336 'linux' : ([], 'Linux' ),
365337 'mac' : ([], 'Darwin' ),
366338 'win' : ([], 'Windows' ),
367339 }
368340
369- for key , (default , platform_name ) in platform_args .items ():
370- platform_args = getattr (cmake_args , key , default )
371- if platform .system () == platform_name and platform_args :
372- for arg in platform_args :
341+ for key , (default , platform_name ) in platform_args_config .items ():
342+ platform_arg_values = getattr (cmake_args , key , default )
343+ if platform .system () == platform_name and platform_arg_values :
344+ for arg in platform_arg_values :
373345 self .cmake_args .append (arg .strip ('"\' ' ))
374346
347+ def setup_cmake_args (self , cmake_args ):
348+ """
349+ Setup CMake arguments.
350+
351+ Args:
352+ cmake_args: Dictionary-like data structure with following keys:
353+ - 'defines': list[str]
354+ - 'undefined': list[str]
355+ - 'errors': list[str]
356+ - 'no_errors': list[str]
357+ - 'generator': str
358+ - 'toolset': str
359+ - 'platform': str
360+ - 'preset': str
361+ - 'cmake': str
362+ - 'dev_warnings': bool
363+ - 'no_dev_warnings': bool
364+ - 'linux': list[str]
365+ - 'mac': list[str]
366+ - 'win': list[str]
367+ """
368+ self .source_dir = Path (cmake_args .source_dir ).resolve ()
369+ if cmake_args .cmake :
370+ self .command = [Path (cmake_args .cmake ).resolve ()]
371+ self .no_cmake_configure = cmake_args .no_cmake_configure
372+
373+ self .resolve_build_directory (
374+ build_dir_list = cmake_args .build_dir ,
375+ automatic_discovery = cmake_args .automatic_discovery ,
376+ )
377+
378+ if cmake_args .detect_configured_files and self .build_dir :
379+ self .cmake_trace_log = self .build_dir / self .DEFAULT_TRACE_LOG
380+
381+ self ._process_keyword_cmake_args (cmake_args )
382+ self ._process_flag_cmake_args (cmake_args )
383+ self ._process_platform_cmake_args (cmake_args )
384+
375385 def configure (self , command , * , clean_build = False ):
376386 """
377387 Run a CMake configure step (multi-process safe).
0 commit comments