@@ -236,6 +236,7 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG
236
236
{
237
237
var forcedIncludes = new Strings ( ) ;
238
238
239
+ bool useClang = context . Configuration . Platform . IsUsingClang ( ) ;
239
240
bool useClangCl = Options . GetObject < Options . Vc . General . PlatformToolset > ( context . Configuration ) . IsLLVMToolchain ( ) &&
240
241
Options . GetObject < Options . Vc . LLVM . UseClangCl > ( context . Configuration ) == Options . Vc . LLVM . UseClangCl . Enable ;
241
242
@@ -367,46 +368,6 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG
367
368
) ;
368
369
}
369
370
370
- // MSVC NMake IntelliSence options
371
-
372
- context . Options [ "AdditionalOptions" ] = ( context . Configuration . CustomBuildSettings is null ) ? FileGeneratorUtilities . RemoveLineTag : context . Configuration . CustomBuildSettings . AdditionalOptions ;
373
-
374
- string cppLanguageStd = null ;
375
- if ( context . Configuration . CustomBuildSettings is null || context . Configuration . CustomBuildSettings . AutoConfigure )
376
- {
377
- context . SelectOption
378
- (
379
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . CPP98 , ( ) => { } ) ,
380
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . CPP11 , ( ) => { } ) ,
381
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . CPP14 , ( ) => { cppLanguageStd = "/std:c++14" ; } ) ,
382
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . CPP17 , ( ) => { cppLanguageStd = "/std:c++17" ; } ) ,
383
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . CPP20 , ( ) => { cppLanguageStd = "/std:c++20" ; } ) ,
384
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . GNU98 , ( ) => { } ) ,
385
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . GNU11 , ( ) => { } ) ,
386
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . GNU14 , ( ) => { cppLanguageStd = "/std:c++14" ; } ) ,
387
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . GNU17 , ( ) => { cppLanguageStd = "/std:c++17" ; } ) ,
388
- Options . Option ( Options . Vc . Compiler . CppLanguageStandard . Latest , ( ) => { cppLanguageStd = "/std:c++latest" ; } )
389
- ) ;
390
- }
391
-
392
- if ( ! string . IsNullOrEmpty ( cppLanguageStd ) )
393
- {
394
- if ( string . IsNullOrEmpty ( context . Options [ "AdditionalOptions" ] ) || context . Options [ "AdditionalOptions" ] == FileGeneratorUtilities . RemoveLineTag )
395
- context . Options [ "AdditionalOptions" ] = cppLanguageStd ;
396
- else
397
- context . Options [ "AdditionalOptions" ] += $ " { cppLanguageStd } ";
398
- }
399
- else if ( string . IsNullOrEmpty ( context . Options [ "AdditionalOptions" ] ) )
400
- {
401
- context . Options [ "AdditionalOptions" ] = FileGeneratorUtilities . RemoveLineTag ;
402
- }
403
-
404
- if ( useClangCl && context . Options [ "AdditionalOptions" ] != FileGeneratorUtilities . RemoveLineTag )
405
- {
406
- // need to use a special syntax when compiler is clang or Visual Studio will generate intellisense errors
407
- context . Options [ "AdditionalOptions" ] = context . Options [ "AdditionalOptions" ] . Replace ( "/std:c++" , "/Clangstdc++" ) ;
408
- }
409
-
410
371
// Compiler section
411
372
412
373
context . SelectOption
@@ -1208,6 +1169,43 @@ private void GenerateCompilerOptions(IGenerationContext context, ProjectOptionsG
1208
1169
}
1209
1170
1210
1171
optionsContext . HasClrSupport = clrSupport ;
1172
+
1173
+ //--------------------------------
1174
+ // MSVC NMake IntelliSence options
1175
+ //--------------------------------
1176
+
1177
+ // Handle C++ language version option
1178
+ string intellisenseCppLanguageStandard ;
1179
+ if ( ! context . CommandLineOptions . TryGetValue ( "LanguageStandard" , out intellisenseCppLanguageStandard ) || intellisenseCppLanguageStandard == FileGeneratorUtilities . RemoveLineTag )
1180
+ {
1181
+ if ( ! context . CommandLineOptions . TryGetValue ( "CppLanguageStd" , out intellisenseCppLanguageStandard ) )
1182
+ intellisenseCppLanguageStandard = FileGeneratorUtilities . RemoveLineTag ;
1183
+ }
1184
+
1185
+ if ( intellisenseCppLanguageStandard != FileGeneratorUtilities . RemoveLineTag )
1186
+ {
1187
+ if ( useClangCl || useClang )
1188
+ {
1189
+ // need to use a special syntax when compiler is clang/clangcl or Visual Studio will generate intellisense errors
1190
+ intellisenseCppLanguageStandard = intellisenseCppLanguageStandard . Replace ( "/std:c++" , "/Clangstdc++" ) ;
1191
+ intellisenseCppLanguageStandard = intellisenseCppLanguageStandard . Replace ( "-std=c++" , "/Clangstdc++" ) ;
1192
+ }
1193
+ }
1194
+
1195
+ // Merge the intellisense language option with additional intellisense command line options
1196
+ string intellisenseCommandLineOptions = intellisenseCppLanguageStandard ;
1197
+ Strings intellisenseAdditionalCommandlineOptions = context . Configuration . IntellisenseAdditionalCommandLineOptions ;
1198
+ if ( intellisenseAdditionalCommandlineOptions != null )
1199
+ {
1200
+ if ( intellisenseCommandLineOptions != FileGeneratorUtilities . RemoveLineTag )
1201
+ intellisenseCommandLineOptions += " " ;
1202
+ intellisenseCommandLineOptions += string . Join ( ' ' , intellisenseAdditionalCommandlineOptions ) ;
1203
+ }
1204
+ context . Options [ "IntellisenseCommandLineOptions" ] = intellisenseCommandLineOptions ;
1205
+
1206
+ // Add additional defines for intellisense to the default ones set for that target.
1207
+ Strings intellisenseDefines = context . Configuration . IntellisenseAdditionalDefines ;
1208
+ context . Options [ "IntellisenseAdditionalDefines" ] = intellisenseDefines != null ? ";" + String . Join ( ';' , intellisenseDefines ) : "" ;
1211
1209
}
1212
1210
1213
1211
public static List < KeyValuePair < string , string > > ConvertPostBuildCopiesToRelative ( Project . Configuration conf , string relativeTo )
0 commit comments