2525#include < sstream>
2626#include < utility>
2727
28- #define TEMPLATE_SLN_ID 101
28+ #define TEMPLATE_SLN_WINRT_ID 101
2929#define TEMPLATE_VCXPROJ_ID 102
3030#define TEMPLATE_FILTERS_ID 103
3131#define TEMPLATE_PROG_VCXPROJ_ID 104
3535#define TEMPLATE_PROPS_ID 108
3636#define TEMPLATE_PROPS_WINRT_ID 109
3737#define TEMPLATE_FILE_PROPS_ID 110
38+ #define TEMPLATE_SLN_NOWINRT_ID 111
3839
3940bool ProjectGenerator::passAllMake ()
4041{
@@ -247,9 +248,12 @@ bool ProjectGenerator::outputProject()
247248 if (!writeToFile (outFiltersFile, filtersFile, true )) {
248249 return false ;
249250 }
250- outFiltersFile = m_configHelper.m_solutionDirectory + m_projectName + " _winrt.vcxproj.filters" ;
251- if (!writeToFile (outFiltersFile, filtersFile, true )) {
252- return false ;
251+ const bool winrtEnabled = m_configHelper.isConfigOptionEnabled (" winrt" ) || m_configHelper.isConfigOptionEnabled (" uwp" );
252+ if (winrtEnabled) {
253+ outFiltersFile = m_configHelper.m_solutionDirectory + m_projectName + " _winrt.vcxproj.filters" ;
254+ if (!writeToFile (outFiltersFile, filtersFile, true )) {
255+ return false ;
256+ }
253257 }
254258
255259 // Open the input temp project file
@@ -311,8 +315,11 @@ bool ProjectGenerator::outputProject()
311315 if (!writeToFile (outProjectFile, projectFile, true )) {
312316 return false ;
313317 }
314- outProjectFile = m_configHelper.m_solutionDirectory + m_projectName + " _winrt.vcxproj" ;
315- return writeToFile (outProjectFile, projectFileWinRT, true );
318+ if (winrtEnabled) {
319+ outProjectFile = m_configHelper.m_solutionDirectory + m_projectName + " _winrt.vcxproj" ;
320+ return writeToFile (outProjectFile, projectFileWinRT, true );
321+ }
322+ return true ;
316323}
317324
318325bool ProjectGenerator::outputProgramProject (const string& destinationFile, const string& destinationFilterFile)
@@ -457,10 +464,18 @@ bool ProjectGenerator::outputSolution()
457464 }
458465
459466 outputLine (" Generating solution file..." );
467+ const bool winrtEnabled =
468+ m_configHelper.isConfigOptionEnabled (" winrt" ) || m_configHelper.isConfigOptionEnabled (" uwp" );
460469 // Open the input temp project file
461470 string solutionFile;
462- if (!loadFromResourceFile (TEMPLATE_SLN_ID, solutionFile)) {
463- return false ;
471+ if (winrtEnabled) {
472+ if (!loadFromResourceFile (TEMPLATE_SLN_WINRT_ID, solutionFile)) {
473+ return false ;
474+ }
475+ } else {
476+ if (!loadFromResourceFile (TEMPLATE_SLN_NOWINRT_ID, solutionFile)) {
477+ return false ;
478+ }
464479 }
465480
466481 map<string, string> keys;
@@ -488,9 +503,9 @@ bool ProjectGenerator::outputSolution()
488503 for (const auto & i : m_projectLibs) {
489504 // Check if this is a library or a program
490505 if (programList.find (i.first ) == programList.end ()) {
491- for (uint winrt = 0 ; winrt < 2 ; ++winrt) {
506+ for (uint winrt = 0 ; winrt < (winrtEnabled ? 2 : 1 ) ; ++winrt) {
492507 string name = i.first ;
493- if (winrt) {
508+ if (winrt > 0 ) {
494509 name += " _winrt" ;
495510 }
496511 // Check if this library has a known key (to lazy to auto generate at this time)
@@ -510,14 +525,14 @@ bool ProjectGenerator::outputSolution()
510525 projectAdd += projectEnd;
511526
512527 // Add the key to the used key list
513- addedKeys.emplace_back (keys[name], winrt);
528+ addedKeys.emplace_back (keys[name], winrt > 0 );
514529
515530 // Add the dependencies
516531 if (i.second .size () > 0 ) {
517532 projectAdd += depend;
518533 for (auto & j : i.second ) {
519534 string name2 = j;
520- if (winrt) {
535+ if (winrt > 0 ) {
521536 name2 += " _winrt" ;
522537 }
523538 // Check if this library has a known key
@@ -601,20 +616,26 @@ bool ProjectGenerator::outputSolution()
601616 string configPlatform = " \r\n {" ;
602617 string configPlatform2 = " }." ;
603618 string configPlatform3 = " |" ;
604- string buildConfigs[ 10 ] = {" Debug" , " DebugDLL" , " DebugDLLWinRT" , " DebugWinRT" , " Release" , " ReleaseDLL" ,
619+ vector< string> buildConfigs = {" Debug" , " DebugDLL" , " DebugDLLWinRT" , " DebugWinRT" , " Release" , " ReleaseDLL" ,
605620 " ReleaseDLLStaticDeps" , " ReleaseDLLWinRT" , " ReleaseDLLWinRTStaticDeps" , " ReleaseWinRT" };
606- string buildConfigsNoWinRT[ 10 ] = {" Debug" , " DebugDLL" , " DebugDLL" , " Debug" , " Release" , " ReleaseDLL" ,
621+ vector< string> buildConfigsNoWinRT = {" Debug" , " DebugDLL" , " DebugDLL" , " Debug" , " Release" , " ReleaseDLL" ,
607622 " ReleaseDLLStaticDeps" , " ReleaseDLL" , " ReleaseDLLStaticDeps" , " Release" };
608- string buildConfigsWinRT[10 ] = {" DebugWinRT" , " DebugDLLWinRT" , " DebugDLLWinRT" , " DebugWinRT" , " ReleaseWinRT" ,
623+ vector<string> buildConfigsWinRT = {" DebugWinRT" , " DebugDLLWinRT" , " DebugDLLWinRT" , " DebugWinRT" ,
624+ " ReleaseWinRT" ,
609625 " ReleaseDLLWinRT" , " ReleaseDLLWinRTStaticDeps" , " ReleaseDLLWinRT" , " ReleaseDLLWinRTStaticDeps" , " ReleaseWinRT" };
626+ if (!winrtEnabled) {
627+ buildConfigs = {" Debug" , " DebugDLL" , " Release" , " ReleaseDLL" , " ReleaseDLLStaticDeps" };
628+ buildConfigsNoWinRT = buildConfigs;
629+ buildConfigsWinRT = buildConfigs;
630+ }
610631 string buildArchsSol[2 ] = {" x86" , " x64" };
611632 string buildArchs[2 ] = {" Win32" , " x64" };
612633 string buildTypes[2 ] = {" .ActiveCfg = " , " .Build.0 = " };
613634 string addPlatform;
614635 // Add the lib keys
615636 for (const auto & i : addedKeys) {
616637 // loop over build configs
617- for (uint j = 0 ; j < sizeof ( buildConfigs) / sizeof (buildConfigs[ 0 ] ); j++) {
638+ for (uint j = 0 ; j < buildConfigs. size ( ); j++) {
618639 // loop over build archs
619640 for (uint k = 0 ; k < sizeof (buildArchsSol) / sizeof (buildArchsSol[0 ]); k++) {
620641 // loop over build types
@@ -641,7 +662,7 @@ bool ProjectGenerator::outputSolution()
641662 // Add the program keys
642663 for (const auto & i : addedPrograms) {
643664 // Loop over build configs
644- for (uint j = 0 ; j < sizeof ( buildConfigs) / sizeof (buildConfigs[ 0 ] ); j++) {
665+ for (uint j = 0 ; j < buildConfigs. size ( ); j++) {
645666 // Loop over build archs
646667 for (uint k = 0 ; k < sizeof (buildArchsSol) / sizeof (buildArchsSol[0 ]); k++) {
647668 // Loop over build types
0 commit comments