@@ -189,8 +189,9 @@ bool ProjectGenerator::outputProject()
189189 StaticList includeDirs;
190190 StaticList lib32Dirs;
191191 StaticList lib64Dirs;
192- StaticList defines;
193- buildDependencyValues (includeDirs, lib32Dirs, lib64Dirs, defines);
192+ StaticList definesShared;
193+ StaticList definesStatic;
194+ buildDependencyValues (includeDirs, lib32Dirs, lib64Dirs, definesShared, definesStatic);
194195
195196 // Create missing definitions of functions removed by DCE
196197 if (!outputProjectDCE (includeDirs)) {
@@ -251,7 +252,7 @@ bool ProjectGenerator::outputProject()
251252 outputLibDirs (lib32Dirs, lib64Dirs, projectFile);
252253
253254 // Add additional defines
254- outputDefines (defines , projectFile);
255+ outputDefines (definesShared, definesStatic , projectFile);
255256
256257 // Replace all template tag arguments
257258 outputTemplateTags (projectFile, filtersFile);
@@ -283,8 +284,9 @@ bool ProjectGenerator::outputProgramProject(const string& destinationFile, const
283284 StaticList includeDirs;
284285 StaticList lib32Dirs;
285286 StaticList lib64Dirs;
286- StaticList defines;
287- buildDependencyValues (includeDirs, lib32Dirs, lib64Dirs, defines);
287+ StaticList definesShared;
288+ StaticList definesStatic;
289+ buildDependencyValues (includeDirs, lib32Dirs, lib64Dirs, definesShared, definesStatic);
288290
289291 // Create missing definitions of functions removed by DCE
290292 if (!outputProjectDCE (includeDirs)) {
@@ -335,7 +337,7 @@ bool ProjectGenerator::outputProgramProject(const string& destinationFile, const
335337 outputLibDirs (lib32Dirs, lib64Dirs, programFile);
336338
337339 // Add additional defines
338- outputDefines (defines, programFile);
340+ outputDefines (definesShared, definesStatic, programFile, true );
339341
340342 // Replace all template tag arguments
341343 outputTemplateTags (programFile, programFiltersFile);
@@ -1470,22 +1472,42 @@ void ProjectGenerator::outputLibDirs(const StaticList& lib32Dirs, const StaticLi
14701472 }
14711473}
14721474
1473- void ProjectGenerator::outputDefines (const StaticList& defines, string& projectTemplate)
1475+ void ProjectGenerator::outputDefines (
1476+ const StaticList& definesShared, const StaticList& definesStatic, string& projectTemplate, const bool program)
14741477{
1475- if (!defines .empty ()) {
1476- string defines2 ;
1477- for (const auto & i : defines ) {
1478- defines2 += i + " ;" ;
1478+ if (!definesShared. empty () || !definesStatic .empty ()) {
1479+ string defines2Shared, defines2Static ;
1480+ for (const auto & i : definesShared ) {
1481+ defines2Shared += i + " ;" ;
14791482 }
1483+ for (const auto & i : definesStatic) {
1484+ defines2Static += i + " ;" ;
1485+ }
1486+ // libraries:
1487+ // Debug, DebugWinRT x2 (0-7), DebugDLL,DebugDLLWinRT x2 (8-15), Release, ReleaseWinRT x2, ReleaseDLL,
1488+ // ReleaseDLLWinRT x2, ReleaseDLLStaticDeps, ReleaseDLLWinRTStaticDeps x2
1489+ // Libraries have 2 PreprocessorDefinitions for each configuration due to NASM section
1490+ // programs:
1491+ // Debug x2, DebugDLL x2, Release x2, ReleaseDLL x2
14801492 const string addDefines = " <PreprocessorDefinitions>" ;
14811493 uint findPos = projectTemplate.find (addDefines);
1494+ uint count = 0 ;
1495+ const bool addWinrt =
1496+ m_configHelper.isConfigOptionEnabled (" winrt" ) || m_configHelper.isConfigOptionEnabled (" uwp" );
1497+ const uint check = (!program) ? (addWinrt ? 8 : 4 ) : 2 ;
14821498 while (findPos != string::npos) {
14831499 // Add to output
14841500 findPos += addDefines.length ();
1485- projectTemplate.insert (findPos, defines2);
1486- findPos += defines2.length ();
1501+ if ((count / check) % 2 == 0 ) {
1502+ projectTemplate.insert (findPos, defines2Static);
1503+ findPos += defines2Static.length ();
1504+ } else {
1505+ projectTemplate.insert (findPos, defines2Shared);
1506+ findPos += defines2Shared.length ();
1507+ }
14871508 // Get next
14881509 findPos = projectTemplate.find (addDefines, findPos + 1 );
1510+ ++count;
14891511 }
14901512 }
14911513}
0 commit comments