@@ -744,17 +744,17 @@ export abstract class CMakeDriver implements vscode.Disposable {
744744 preferredGenerators . push ( { name : "Unix Makefiles" } ) ;
745745 }
746746
747- // If a generator is set in the "cmake.generator" setting, push it to the front
748- // of the "best generator" logic
747+ // Use the "best generator" logic only if the user did not define a particular
748+ // generator to be used via the `cmake. generator` setting.
749749 if ( this . config . generator ) {
750- preferredGenerators . unshift ( {
750+ this . _generator = {
751751 name : this . config . generator ,
752752 platform : this . config . platform || undefined ,
753753 toolset : this . config . toolset || undefined
754- } ) ;
754+ } ;
755+ } else {
756+ this . _generator = await this . findBestGenerator ( preferredGenerators ) ;
755757 }
756-
757- this . _generator = await this . findBestGenerator ( preferredGenerators ) ;
758758 }
759759
760760 protected abstract doSetConfigurePreset ( needsClean : boolean , cb : ( ) => Promise < void > ) : Promise < void > ;
@@ -1004,7 +1004,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
10041004 return false ;
10051005 } ) ( ) ;
10061006 if ( ! generator_present ) {
1007- const vsMatch = / ^ ( V i s u a l S t u d i o \d { 2 } \d { 4 } ) ( $ | \s W i n 6 4 $ | \s A R M $ ) / . exec ( gen . name ) ;
1007+ const vsMatch = / ^ ( V i s u a l S t u d i o \d { 2 } \d { 4 } ) ( $ | \s W i n 6 4 $ | \s A R M $ ) / . exec ( gen_name ) ;
10081008 if ( platform === 'win32' && vsMatch ) {
10091009 let possibleArchitecture = vsMatch [ 2 ] . trim ( ) ;
10101010 if ( possibleArchitecture && possibleArchitecture === "Win64" ) {
@@ -1016,11 +1016,15 @@ export abstract class CMakeDriver implements vscode.Disposable {
10161016 toolset : gen . toolset
10171017 } ;
10181018 }
1019- if ( gen . name . toLowerCase ( ) . startsWith ( 'xcode' ) && platform === 'darwin' ) {
1019+ if ( gen_name . toLowerCase ( ) . startsWith ( 'xcode' ) && platform === 'darwin' ) {
10201020 return gen ;
10211021 }
10221022
1023- // If the generator isn't found, move on to the next one
1023+ // If it is not a common generator that we can find, but it is a known cmake generator (cmakeGenerators), return it.
1024+ // The only caveat is that we should not return a Visual Studio generator on non-Windows platforms.
1025+ if ( this . cmakeGenerators . indexOf ( gen_name ) >= 0 && ! this . isCommonGenerator ( gen_name ) && ! ( gen_name . startsWith ( "Visual Studio" ) && platform !== "win32" ) ) {
1026+ return gen ;
1027+ }
10241028 continue ;
10251029 } else {
10261030 return gen ;
0 commit comments