Skip to content

Commit 17b6616

Browse files
KyleFromKitwarekwrobot
authored andcommitted
Merge topic 'strcat-localgenerator'
6265910 cmLocalGenerator: Use cmStrCat Acked-by: Kitware Robot <[email protected]> Acked-by: Sebastian Holtermann <[email protected]> Merge-request: !3671
2 parents 9ab15fa + 6265910 commit 17b6616

File tree

1 file changed

+48
-92
lines changed

1 file changed

+48
-92
lines changed

Source/cmLocalGenerator.cxx

Lines changed: 48 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -745,12 +745,10 @@ std::string cmLocalGenerator::GetIncludeFlags(
745745
OutputFormat shellFormat = forResponseFile ? RESPONSE : SHELL;
746746
std::ostringstream includeFlags;
747747

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));
754752
bool quotePaths = false;
755753
if (this->Makefile->GetDefinition("CMAKE_QUOTE_INCLUDE_PATHS")) {
756754
quotePaths = true;
@@ -767,23 +765,16 @@ std::string cmLocalGenerator::GetIncludeFlags(
767765

768766
// Support special system include flag if it is available and the
769767
// normal flag is repeated for each directory.
770-
std::string sysFlagVar = "CMAKE_INCLUDE_SYSTEM_FLAG_";
771-
sysFlagVar += lang;
772768
const char* sysIncludeFlag = nullptr;
773769
if (repeatFlag) {
774-
sysIncludeFlag = this->Makefile->GetDefinition(sysFlagVar);
770+
sysIncludeFlag = this->Makefile->GetDefinition(
771+
cmStrCat("CMAKE_INCLUDE_SYSTEM_FLAG_", lang));
775772
}
776773

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"));
787778

788779
bool flagUsed = false;
789780
std::set<std::string> emitted;
@@ -793,9 +784,8 @@ std::string cmLocalGenerator::GetIncludeFlags(
793784
for (std::string const& i : includes) {
794785
if (fwSearchFlag && *fwSearchFlag && this->Makefile->IsOn("APPLE") &&
795786
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, "/../"));
799789
if (emitted.insert(frameworkDir).second) {
800790
if (sysFwSearchFlag && target &&
801791
target->IsSystemIncludeDirectory(i, config, lang)) {
@@ -963,10 +953,8 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
963953
// These are intended to simulate additional implicit include directories.
964954
std::vector<std::string> userStandardDirs;
965955
{
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"));
970958
cmSystemTools::ExpandListArgument(value, userStandardDirs);
971959
for (std::string& usd : userStandardDirs) {
972960
cmSystemTools::ConvertToUnixSlashes(usd);
@@ -989,10 +977,9 @@ std::vector<BT<std::string>> cmLocalGenerator::GetIncludeDirectoriesImplicit(
989977
// * Compilers like gfortran do not search their own implicit include
990978
// directories for modules ('.mod' files).
991979
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) {
996983
size_t const impDirVecOldSize = impDirVec.size();
997984
cmSystemTools::ExpandListArgument(value, impDirVec);
998985
// FIXME: Use cmRange with 'advance()' when it supports non-const.
@@ -1210,9 +1197,8 @@ void cmLocalGenerator::GetTargetFlags(
12101197
linkFlags += " ";
12111198
}
12121199
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));
12161202
if (targetLinkFlags) {
12171203
linkFlags += targetLinkFlags;
12181204
linkFlags += " ";
@@ -1234,9 +1220,8 @@ void cmLocalGenerator::GetTargetFlags(
12341220
this->Makefile->GetSafeDefinition("CMAKE_EXE_LINKER_FLAGS");
12351221
linkFlags += " ";
12361222
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));
12401225
linkFlags += " ";
12411226
}
12421227
if (linkLanguage.empty()) {
@@ -1257,11 +1242,8 @@ void cmLocalGenerator::GetTargetFlags(
12571242
}
12581243

12591244
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"));
12651247
linkFlags += " ";
12661248
}
12671249
}
@@ -1293,9 +1275,8 @@ void cmLocalGenerator::GetTargetFlags(
12931275
linkFlags += " ";
12941276
}
12951277
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));
12991280
if (targetLinkFlags) {
13001281
linkFlags += targetLinkFlags;
13011282
linkFlags += " ";
@@ -1470,20 +1451,12 @@ void cmLocalGenerator::OutputLinkLibraries(
14701451
}
14711452

14721453
// 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"));
14801456

14811457
// 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"));
14871460

14881461
frameworkPath = linkLineComputer->ComputeFrameworkPath(cli, fwSearchFlag);
14891462
linkPath =
@@ -1538,10 +1511,8 @@ std::string cmLocalGenerator::GetLinkLibsCMP0065(
15381511
}
15391512

15401513
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"));
15451516
}
15461517
}
15471518
return linkFlags;
@@ -1599,10 +1570,8 @@ void cmLocalGenerator::AddLanguageFlags(std::string& flags,
15991570
const std::string& config)
16001571
{
16011572
// 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);
16061575

16071576
// Add MSVC runtime library flags. This is activated by the presence
16081577
// of a default selection whether or not it is overridden by a property.
@@ -1773,10 +1742,9 @@ void cmLocalGenerator::AddSharedFlags(std::string& flags,
17731742

17741743
// Add flags for dealing with shared libraries for this language.
17751744
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")));
17801748
}
17811749
}
17821750

@@ -2065,9 +2033,7 @@ bool cmLocalGenerator::GetShouldUseOldFlags(bool shared,
20652033
std::string originalFlags =
20662034
this->GlobalGenerator->GetSharedLibFlagsForLanguage(lang);
20672035
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");
20712037
std::string const& flags = this->Makefile->GetSafeDefinition(flagsVar);
20722038

20732039
if (flags != originalFlags) {
@@ -2106,16 +2072,12 @@ void cmLocalGenerator::AddPositionIndependentFlags(std::string& flags,
21062072
std::string picFlags;
21072073

21082074
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"));
21132077
}
21142078
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"));
21192081
}
21202082
if (!picFlags.empty()) {
21212083
std::vector<std::string> options;
@@ -2356,10 +2318,8 @@ void cmLocalGenerator::JoinDefines(const std::set<std::string>& defines,
23562318
// Lookup the define flag for the current language.
23572319
std::string dflag = "-D";
23582320
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"));
23632323
if (df && *df) {
23642324
dflag = df;
23652325
}
@@ -2405,11 +2365,9 @@ void cmLocalGenerator::AppendFeatureOptions(std::string& flags,
24052365
const std::string& lang,
24062366
const char* feature)
24072367
{
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) {
24132371
std::vector<std::string> options;
24142372
cmSystemTools::ExpandListArgument(optionList, options);
24152373
for (std::string const& o : options) {
@@ -2762,10 +2720,8 @@ std::string cmLocalGenerator::GetObjectFileNameWithoutTarget(
27622720
if (!replaceExt) {
27632721
std::string lang = source.GetLanguage();
27642722
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"));
27692725
}
27702726
}
27712727

0 commit comments

Comments
 (0)