@@ -352,6 +352,7 @@ function cmake.build(opt, callback)
352352 end
353353
354354 local presets_exists = config .base_settings .use_preset and Presets .exists (config .cwd )
355+ local use_build_preset = false
355356 if presets_exists then
356357 local presets = Presets :parse (config .cwd )
357358 if not config .build_preset then
@@ -371,9 +372,10 @@ function cmake.build(opt, callback)
371372 end
372373 if config .build_preset then
373374 local build_preset = presets :get_build_preset (config .build_preset )
374- if build_preset then
375+ if build_preset and build_preset : is_valid () then
375376 config :update_build_target ()
376377 config :update_build_type ()
378+ use_build_preset = true
377379 end
378380 end
379381 end
@@ -391,7 +393,7 @@ function cmake.build(opt, callback)
391393
392394 local args
393395
394- if presets_exists and config . build_preset then
396+ if use_build_preset then
395397 args = { " --build" , " --preset" , config .build_preset } -- preset don't need define build dir.
396398 else
397399 args = {
@@ -895,32 +897,29 @@ function cmake.select_build_preset(callback)
895897 callback (Result :new_error (Types .NOT_SELECT_PRESET , " No build preset selected" ))
896898 return
897899 end
900+
898901 if config .build_preset ~= choice then
902+ config .build_preset = choice
903+
899904 local build_preset = presets :get_build_preset (choice )
900- if build_preset :is_valid () then
901- config .build_preset = choice
902905
903- if build_preset then
904- config :update_build_target ()
906+ if build_preset and build_preset :is_valid () then
907+ config :update_build_target ()
908+
909+ local associated_configure_preset =
910+ presets :get_configure_preset (build_preset .configurePreset , { include_hidden = true })
911+ local associated_configure_preset_name = associated_configure_preset
912+ and associated_configure_preset .name
913+ or nil
914+
915+ if
916+ associated_configure_preset_name
917+ and config .configure_preset ~= associated_configure_preset_name
918+ then
919+ config .configure_preset = associated_configure_preset_name
905920 end
906921 end
907922 end
908- local associated_configure_preset = presets :get_configure_preset (
909- presets :get_build_preset (choice ).configurePreset ,
910- { include_hidden = true }
911- )
912- local associated_configure_preset_name = associated_configure_preset
913- and associated_configure_preset .name
914- or nil
915- local configure_preset_updated = false
916-
917- if
918- associated_configure_preset_name
919- and config .configure_preset ~= associated_configure_preset_name
920- then
921- config .configure_preset = associated_configure_preset_name
922- configure_preset_updated = true
923- end
924923
925924 callback (Result :new (Types .SUCCESS , nil , nil ))
926925 end )
@@ -1211,7 +1210,7 @@ function cmake.run_test(opt, callback)
12111210 return
12121211 end
12131212 if idx == 1 then
1214- ctest .run (const .ctest_command , " '.*' " , config :build_directory_path (), env , config , opt )
1213+ ctest .run (const .ctest_command , nil , config :build_directory_path (), env , config , opt )
12151214 else
12161215 ctest .run (
12171216 const .ctest_command ,
0 commit comments