@@ -745,12 +745,10 @@ std::string cmLocalGenerator::GetIncludeFlags(
745
745
OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL;
746
746
std::ostringstream includeFlags;
747
747
748
- std::string flagVar = " CMAKE_INCLUDE_FLAG_" ;
749
- flagVar += lang;
750
- std::string const & includeFlag = this ->Makefile ->GetSafeDefinition (flagVar);
751
- flagVar = " CMAKE_INCLUDE_FLAG_SEP_" ;
752
- flagVar += lang;
753
- const char * sep = this ->Makefile ->GetDefinition (flagVar);
748
+ std::string const & includeFlag =
749
+ this ->Makefile ->GetSafeDefinition (cmStrCat (" CMAKE_INCLUDE_FLAG_" , lang));
750
+ const char * sep =
751
+ this ->Makefile ->GetDefinition (cmStrCat (" CMAKE_INCLUDE_FLAG_SEP_" , lang));
754
752
bool quotePaths = false ;
755
753
if (this ->Makefile ->GetDefinition (" CMAKE_QUOTE_INCLUDE_PATHS" )) {
756
754
quotePaths = true ;
@@ -767,23 +765,16 @@ std::string cmLocalGenerator::GetIncludeFlags(
767
765
768
766
// Support special system include flag if it is available and the
769
767
// normal flag is repeated for each directory.
770
- std::string sysFlagVar = " CMAKE_INCLUDE_SYSTEM_FLAG_" ;
771
- sysFlagVar += lang;
772
768
const char * sysIncludeFlag = nullptr ;
773
769
if (repeatFlag) {
774
- sysIncludeFlag = this ->Makefile ->GetDefinition (sysFlagVar);
770
+ sysIncludeFlag = this ->Makefile ->GetDefinition (
771
+ cmStrCat (" CMAKE_INCLUDE_SYSTEM_FLAG_" , lang));
775
772
}
776
773
777
- std::string fwSearchFlagVar = " CMAKE_" ;
778
- fwSearchFlagVar += lang;
779
- fwSearchFlagVar += " _FRAMEWORK_SEARCH_FLAG" ;
780
- const char * fwSearchFlag = this ->Makefile ->GetDefinition (fwSearchFlagVar);
781
-
782
- std::string sysFwSearchFlagVar = " CMAKE_" ;
783
- sysFwSearchFlagVar += lang;
784
- sysFwSearchFlagVar += " _SYSTEM_FRAMEWORK_SEARCH_FLAG" ;
785
- const char * sysFwSearchFlag =
786
- this ->Makefile ->GetDefinition (sysFwSearchFlagVar);
774
+ const char * fwSearchFlag = this ->Makefile ->GetDefinition (
775
+ cmStrCat (" CMAKE_" , lang, " _FRAMEWORK_SEARCH_FLAG" ));
776
+ const char * sysFwSearchFlag = this ->Makefile ->GetDefinition (
777
+ cmStrCat (" CMAKE_" , lang, " _SYSTEM_FRAMEWORK_SEARCH_FLAG" ));
787
778
788
779
bool flagUsed = false ;
789
780
std::set<std::string> emitted;
@@ -793,9 +784,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
793
784
for (std::string const & i : includes) {
794
785
if (fwSearchFlag && *fwSearchFlag && this ->Makefile ->IsOn (" APPLE" ) &&
795
786
cmSystemTools::IsPathToFramework (i)) {
796
- std::string frameworkDir = i;
797
- frameworkDir += " /../" ;
798
- frameworkDir = cmSystemTools::CollapseFullPath (frameworkDir);
787
+ std::string const frameworkDir =
788
+ cmSystemTools::CollapseFullPath (cmStrCat (i, " /../" ));
799
789
if (emitted.insert (frameworkDir).second ) {
800
790
if (sysFwSearchFlag && target &&
801
791
target->IsSystemIncludeDirectory (i, config, lang)) {
@@ -963,10 +953,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
963
953
// These are intended to simulate additional implicit include directories.
964
954
std::vector<std::string> userStandardDirs;
965
955
{
966
- std::string key = " CMAKE_" ;
967
- key += lang;
968
- key += " _STANDARD_INCLUDE_DIRECTORIES" ;
969
- std::string const value = this ->Makefile ->GetSafeDefinition (key);
956
+ std::string const value = this ->Makefile ->GetSafeDefinition (
957
+ cmStrCat (" CMAKE_" , lang, " _STANDARD_INCLUDE_DIRECTORIES" ));
970
958
cmSystemTools::ExpandListArgument (value, userStandardDirs);
971
959
for (std::string& usd : userStandardDirs) {
972
960
cmSystemTools::ConvertToUnixSlashes (usd);
@@ -989,10 +977,9 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
989
977
// * Compilers like gfortran do not search their own implicit include
990
978
// directories for modules ('.mod' files).
991
979
if (lang != " Fortran" ) {
992
- std::string key = " CMAKE_" ;
993
- key += lang;
994
- key += " _IMPLICIT_INCLUDE_DIRECTORIES" ;
995
- if (const char * value = this ->Makefile ->GetDefinition (key)) {
980
+ const char * value = this ->Makefile ->GetDefinition (
981
+ cmStrCat (" CMAKE_" , lang, " _IMPLICIT_INCLUDE_DIRECTORIES" ));
982
+ if (value != nullptr ) {
996
983
size_t const impDirVecOldSize = impDirVec.size ();
997
984
cmSystemTools::ExpandListArgument (value, impDirVec);
998
985
// FIXME: Use cmRange with 'advance()' when it supports non-const.
@@ -1210,9 +1197,8 @@ void cmLocalGenerator::GetTargetFlags(
1210
1197
linkFlags += " " ;
1211
1198
}
1212
1199
if (!buildType.empty ()) {
1213
- std::string configLinkFlags = " LINK_FLAGS_" ;
1214
- configLinkFlags += buildType;
1215
- targetLinkFlags = target->GetProperty (configLinkFlags);
1200
+ targetLinkFlags =
1201
+ target->GetProperty (cmStrCat (" LINK_FLAGS_" , buildType));
1216
1202
if (targetLinkFlags) {
1217
1203
linkFlags += targetLinkFlags;
1218
1204
linkFlags += " " ;
@@ -1234,9 +1220,8 @@ void cmLocalGenerator::GetTargetFlags(
1234
1220
this ->Makefile ->GetSafeDefinition (" CMAKE_EXE_LINKER_FLAGS" );
1235
1221
linkFlags += " " ;
1236
1222
if (!buildType.empty ()) {
1237
- std::string build = " CMAKE_EXE_LINKER_FLAGS_" ;
1238
- build += buildType;
1239
- linkFlags += this ->Makefile ->GetSafeDefinition (build);
1223
+ linkFlags += this ->Makefile ->GetSafeDefinition (
1224
+ cmStrCat (" CMAKE_EXE_LINKER_FLAGS_" , buildType));
1240
1225
linkFlags += " " ;
1241
1226
}
1242
1227
if (linkLanguage.empty ()) {
@@ -1257,11 +1242,8 @@ void cmLocalGenerator::GetTargetFlags(
1257
1242
}
1258
1243
1259
1244
if (target->IsExecutableWithExports ()) {
1260
- std::string exportFlagVar = " CMAKE_EXE_EXPORTS_" ;
1261
- exportFlagVar += linkLanguage;
1262
- exportFlagVar += " _FLAG" ;
1263
-
1264
- linkFlags += this ->Makefile ->GetSafeDefinition (exportFlagVar);
1245
+ linkFlags += this ->Makefile ->GetSafeDefinition (
1246
+ cmStrCat (" CMAKE_EXE_EXPORTS_" , linkLanguage, " _FLAG" ));
1265
1247
linkFlags += " " ;
1266
1248
}
1267
1249
}
@@ -1293,9 +1275,8 @@ void cmLocalGenerator::GetTargetFlags(
1293
1275
linkFlags += " " ;
1294
1276
}
1295
1277
if (!buildType.empty ()) {
1296
- std::string configLinkFlags = " LINK_FLAGS_" ;
1297
- configLinkFlags += buildType;
1298
- targetLinkFlags = target->GetProperty (configLinkFlags);
1278
+ targetLinkFlags =
1279
+ target->GetProperty (cmStrCat (" LINK_FLAGS_" , buildType));
1299
1280
if (targetLinkFlags) {
1300
1281
linkFlags += targetLinkFlags;
1301
1282
linkFlags += " " ;
@@ -1470,20 +1451,12 @@ void cmLocalGenerator::OutputLinkLibraries(
1470
1451
}
1471
1452
1472
1453
// Add standard libraries for this language.
1473
- std::string standardLibsVar = " CMAKE_" ;
1474
- standardLibsVar += cli.GetLinkLanguage ();
1475
- standardLibsVar += " _STANDARD_LIBRARIES" ;
1476
- std::string stdLibString;
1477
- if (const char * stdLibs = this ->Makefile ->GetDefinition (standardLibsVar)) {
1478
- stdLibString = stdLibs;
1479
- }
1454
+ std::string stdLibString = this ->Makefile ->GetSafeDefinition (
1455
+ cmStrCat (" CMAKE_" , cli.GetLinkLanguage (), " _STANDARD_LIBRARIES" ));
1480
1456
1481
1457
// Append the framework search path flags.
1482
- std::string fwSearchFlagVar = " CMAKE_" ;
1483
- fwSearchFlagVar += linkLanguage;
1484
- fwSearchFlagVar += " _FRAMEWORK_SEARCH_FLAG" ;
1485
- std::string fwSearchFlag =
1486
- this ->Makefile ->GetSafeDefinition (fwSearchFlagVar);
1458
+ std::string fwSearchFlag = this ->Makefile ->GetSafeDefinition (
1459
+ cmStrCat (" CMAKE_" , linkLanguage, " _FRAMEWORK_SEARCH_FLAG" ));
1487
1460
1488
1461
frameworkPath = linkLineComputer->ComputeFrameworkPath (cli, fwSearchFlag);
1489
1462
linkPath =
@@ -1538,10 +1511,8 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065(
1538
1511
}
1539
1512
1540
1513
if (add_shlib_flags) {
1541
- std::string linkFlagsVar = " CMAKE_SHARED_LIBRARY_LINK_" ;
1542
- linkFlagsVar += linkLanguage;
1543
- linkFlagsVar += " _FLAGS" ;
1544
- linkFlags = this ->Makefile ->GetSafeDefinition (linkFlagsVar);
1514
+ linkFlags = this ->Makefile ->GetSafeDefinition (
1515
+ cmStrCat (" CMAKE_SHARED_LIBRARY_LINK_" , linkLanguage, " _FLAGS" ));
1545
1516
}
1546
1517
}
1547
1518
return linkFlags;
@@ -1599,10 +1570,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
1599
1570
const std::string& config)
1600
1571
{
1601
1572
// Add language-specific flags.
1602
- std::string flagsVar = " CMAKE_" ;
1603
- flagsVar += lang;
1604
- flagsVar += " _FLAGS" ;
1605
- this ->AddConfigVariableFlags (flags, flagsVar, config);
1573
+ this ->AddConfigVariableFlags (flags, cmStrCat (" CMAKE_" , lang, " _FLAGS" ),
1574
+ config);
1606
1575
1607
1576
// Add MSVC runtime library flags. This is activated by the presence
1608
1577
// of a default selection whether or not it is overridden by a property.
@@ -1773,10 +1742,9 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
1773
1742
1774
1743
// Add flags for dealing with shared libraries for this language.
1775
1744
if (shared) {
1776
- flagsVar = " CMAKE_SHARED_LIBRARY_" ;
1777
- flagsVar += lang;
1778
- flagsVar += " _FLAGS" ;
1779
- this ->AppendFlags (flags, this ->Makefile ->GetDefinition (flagsVar));
1745
+ this ->AppendFlags (flags,
1746
+ this ->Makefile ->GetDefinition (
1747
+ cmStrCat (" CMAKE_SHARED_LIBRARY_" , lang, " _FLAGS" )));
1780
1748
}
1781
1749
}
1782
1750
@@ -2065,9 +2033,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
2065
2033
std::string originalFlags =
2066
2034
this ->GlobalGenerator ->GetSharedLibFlagsForLanguage (lang);
2067
2035
if (shared) {
2068
- std::string flagsVar = " CMAKE_SHARED_LIBRARY_" ;
2069
- flagsVar += lang;
2070
- flagsVar += " _FLAGS" ;
2036
+ std::string flagsVar = cmStrCat (" CMAKE_SHARED_LIBRARY_" , lang, " _FLAGS" );
2071
2037
std::string const & flags = this ->Makefile ->GetSafeDefinition (flagsVar);
2072
2038
2073
2039
if (flags != originalFlags) {
@@ -2106,16 +2072,12 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
2106
2072
std::string picFlags;
2107
2073
2108
2074
if (targetType == cmStateEnums::EXECUTABLE) {
2109
- std::string flagsVar = " CMAKE_" ;
2110
- flagsVar += lang;
2111
- flagsVar += " _COMPILE_OPTIONS_PIE" ;
2112
- picFlags = this ->Makefile ->GetSafeDefinition (flagsVar);
2075
+ picFlags = this ->Makefile ->GetSafeDefinition (
2076
+ cmStrCat (" CMAKE_" , lang, " _COMPILE_OPTIONS_PIE" ));
2113
2077
}
2114
2078
if (picFlags.empty ()) {
2115
- std::string flagsVar = " CMAKE_" ;
2116
- flagsVar += lang;
2117
- flagsVar += " _COMPILE_OPTIONS_PIC" ;
2118
- picFlags = this ->Makefile ->GetSafeDefinition (flagsVar);
2079
+ picFlags = this ->Makefile ->GetSafeDefinition (
2080
+ cmStrCat (" CMAKE_" , lang, " _COMPILE_OPTIONS_PIC" ));
2119
2081
}
2120
2082
if (!picFlags.empty ()) {
2121
2083
std::vector<std::string> options;
@@ -2356,10 +2318,8 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
2356
2318
// Lookup the define flag for the current language.
2357
2319
std::string dflag = " -D" ;
2358
2320
if (!lang.empty ()) {
2359
- std::string defineFlagVar = " CMAKE_" ;
2360
- defineFlagVar += lang;
2361
- defineFlagVar += " _DEFINE_FLAG" ;
2362
- const char * df = this ->Makefile ->GetDefinition (defineFlagVar);
2321
+ const char * df =
2322
+ this ->Makefile ->GetDefinition (cmStrCat (" CMAKE_" , lang, " _DEFINE_FLAG" ));
2363
2323
if (df && *df) {
2364
2324
dflag = df;
2365
2325
}
@@ -2405,11 +2365,9 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
2405
2365
const std::string& lang,
2406
2366
const char * feature)
2407
2367
{
2408
- std::string optVar = " CMAKE_" ;
2409
- optVar += lang;
2410
- optVar += " _COMPILE_OPTIONS_" ;
2411
- optVar += feature;
2412
- if (const char * optionList = this ->Makefile ->GetDefinition (optVar)) {
2368
+ const char * optionList = this ->Makefile ->GetDefinition (
2369
+ cmStrCat (" CMAKE_" , lang, " _COMPILE_OPTIONS_" , feature));
2370
+ if (optionList != nullptr ) {
2413
2371
std::vector<std::string> options;
2414
2372
cmSystemTools::ExpandListArgument (optionList, options);
2415
2373
for (std::string const & o : options) {
@@ -2762,10 +2720,8 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
2762
2720
if (!replaceExt) {
2763
2721
std::string lang = source.GetLanguage ();
2764
2722
if (!lang.empty ()) {
2765
- std::string repVar = " CMAKE_" ;
2766
- repVar += lang;
2767
- repVar += " _OUTPUT_EXTENSION_REPLACE" ;
2768
- replaceExt = this ->Makefile ->IsOn (repVar);
2723
+ replaceExt = this ->Makefile ->IsOn (
2724
+ cmStrCat (" CMAKE_" , lang, " _OUTPUT_EXTENSION_REPLACE" ));
2769
2725
}
2770
2726
}
2771
2727
0 commit comments