@@ -744,17 +744,17 @@ export abstract class CMakeDriver implements vscode.Disposable {
744
744
preferredGenerators . push ( { name : "Unix Makefiles" } ) ;
745
745
}
746
746
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.
749
749
if ( this . config . generator ) {
750
- preferredGenerators . unshift ( {
750
+ this . _generator = {
751
751
name : this . config . generator ,
752
752
platform : this . config . platform || undefined ,
753
753
toolset : this . config . toolset || undefined
754
- } ) ;
754
+ } ;
755
+ } else {
756
+ this . _generator = await this . findBestGenerator ( preferredGenerators ) ;
755
757
}
756
-
757
- this . _generator = await this . findBestGenerator ( preferredGenerators ) ;
758
758
}
759
759
760
760
protected abstract doSetConfigurePreset ( needsClean : boolean , cb : ( ) => Promise < void > ) : Promise < void > ;
@@ -1004,7 +1004,7 @@ export abstract class CMakeDriver implements vscode.Disposable {
1004
1004
return false ;
1005
1005
} ) ( ) ;
1006
1006
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 ) ;
1008
1008
if ( platform === 'win32' && vsMatch ) {
1009
1009
let possibleArchitecture = vsMatch [ 2 ] . trim ( ) ;
1010
1010
if ( possibleArchitecture && possibleArchitecture === "Win64" ) {
@@ -1016,11 +1016,15 @@ export abstract class CMakeDriver implements vscode.Disposable {
1016
1016
toolset : gen . toolset
1017
1017
} ;
1018
1018
}
1019
- if ( gen . name . toLowerCase ( ) . startsWith ( 'xcode' ) && platform === 'darwin' ) {
1019
+ if ( gen_name . toLowerCase ( ) . startsWith ( 'xcode' ) && platform === 'darwin' ) {
1020
1020
return gen ;
1021
1021
}
1022
1022
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
+ }
1024
1028
continue ;
1025
1029
} else {
1026
1030
return gen ;
0 commit comments