@@ -156,62 +156,57 @@ std::string cmQtAutoGenInitializer::InfoWriter::ListJoin(IT it_begin,
156
156
return res;
157
157
}
158
158
159
- std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey (
160
- const char * key, std::string const & config)
159
+ inline std::string cmQtAutoGenInitializer::InfoWriter::ConfigKey (
160
+ cm::string_view key, std::string const & config)
161
161
{
162
- std::string ckey = key;
163
- ckey += ' _' ;
164
- ckey += config;
165
- return ckey;
162
+ return cmStrCat (key, " _" , config);
166
163
}
167
164
168
- void cmQtAutoGenInitializer::InfoWriter::Write (const char * key,
165
+ void cmQtAutoGenInitializer::InfoWriter::Write (cm::string_view key,
169
166
std::string const & value)
170
167
{
171
168
Ofs_ << " set(" << key << " " << cmOutputConverter::EscapeForCMake (value)
172
169
<< " )\n " ;
173
170
};
174
171
175
- void cmQtAutoGenInitializer::InfoWriter::WriteUInt (const char * key,
172
+ void cmQtAutoGenInitializer::InfoWriter::WriteUInt (cm::string_view key,
176
173
unsigned int value)
177
174
{
178
175
Ofs_ << " set(" << key << " " << value << " )\n " ;
179
176
};
180
177
181
178
template <class C >
182
- void cmQtAutoGenInitializer::InfoWriter::WriteStrings (const char * key,
179
+ void cmQtAutoGenInitializer::InfoWriter::WriteStrings (cm::string_view key,
183
180
C const & container)
184
181
{
185
182
Ofs_ << " set(" << key << " \" "
186
183
<< ListJoin (container.begin (), container.end ()) << " \" )\n " ;
187
184
}
188
185
189
186
void cmQtAutoGenInitializer::InfoWriter::WriteConfig (
190
- const char * key, std::map<std::string, std::string> const & map)
187
+ cm::string_view key, std::map<std::string, std::string> const & map)
191
188
{
192
189
for (auto const & item : map) {
193
- Write (ConfigKey (key, item.first ). c_str () , item.second );
190
+ Write (ConfigKey (key, item.first ), item.second );
194
191
}
195
192
};
196
193
197
194
template <class C >
198
195
void cmQtAutoGenInitializer::InfoWriter::WriteConfigStrings (
199
- const char * key, std::map<std::string, C> const & map)
196
+ cm::string_view key, std::map<std::string, C> const & map)
200
197
{
201
198
for (auto const & item : map) {
202
- WriteStrings (ConfigKey (key, item.first ). c_str () , item.second );
199
+ WriteStrings (ConfigKey (key, item.first ), item.second );
203
200
}
204
201
}
205
202
206
203
void cmQtAutoGenInitializer::InfoWriter::WriteNestedLists (
207
- const char * key, std::vector<std::vector<std::string>> const & lists)
204
+ cm::string_view key, std::vector<std::vector<std::string>> const & lists)
208
205
{
209
206
std::vector<std::string> seplist;
210
- for (const std::vector<std::string>& list : lists) {
211
- std::string blist = " {" ;
212
- blist += ListJoin (list.begin (), list.end ());
213
- blist += " }" ;
214
- seplist.push_back (std::move (blist));
207
+ seplist.reserve (lists.size ());
208
+ for (std::vector<std::string> const & list : lists) {
209
+ seplist.push_back (cmStrCat (" {" , ListJoin (list.begin (), list.end ()), " }" ));
215
210
}
216
211
Write (key, cmJoin (seplist, cmQtAutoGen::ListSep));
217
212
};
@@ -721,14 +716,13 @@ bool cmQtAutoGenInitializer::InitScanFiles()
721
716
if (muf.MocIt || muf.UicIt ) {
722
717
// Search for the default header file and a private header
723
718
std::string const & srcPath = muf.SF ->GetFullPath ();
724
- std::string basePath = cmQtAutoGen::SubDirPrefix (srcPath);
725
- basePath += cmSystemTools::GetFilenameWithoutLastExtension (srcPath);
719
+ std::string basePath =
720
+ cmStrCat (cmQtAutoGen::SubDirPrefix (srcPath),
721
+ cmSystemTools::GetFilenameWithoutLastExtension (srcPath));
726
722
for (auto const & suffix : suffixes) {
727
723
std::string const suffixedPath = basePath + suffix;
728
724
for (auto const & ext : exts) {
729
- std::string fullPath = suffixedPath;
730
- fullPath += ' .' ;
731
- fullPath += ext;
725
+ std::string fullPath = cmStrCat (suffixedPath, ' .' , ext);
732
726
733
727
auto constexpr locationKind = cmSourceFileLocationKind::Known;
734
728
cmSourceFile* sf = makefile->GetSource (fullPath, locationKind);
@@ -833,9 +827,8 @@ bool cmQtAutoGenInitializer::InitScanFiles()
833
827
this ->AutogenTarget .DependFiles .insert (muf->RealPath );
834
828
}
835
829
} else if (this ->CMP0071Warn ) {
836
- std::string msg;
837
- msg += cmPolicies::GetPolicyWarning (cmPolicies::CMP0071);
838
- msg += ' \n ' ;
830
+ std::string msg =
831
+ cmStrCat (cmPolicies::GetPolicyWarning (cmPolicies::CMP0071), ' \n ' );
839
832
std::string property;
840
833
if (this ->Moc .Enabled && this ->Uic .Enabled ) {
841
834
property = kw.SKIP_AUTOGEN ;
@@ -888,18 +881,10 @@ bool cmQtAutoGenInitializer::InitScanFiles()
888
881
for (Qrc& qrc : this ->Rcc .Qrcs ) {
889
882
qrc.PathChecksum = fpathCheckSum.getPart (qrc.QrcFile );
890
883
// RCC output file name
884
+ qrc.RccFile = cmStrCat (this ->Dir .Build + " /" , qrc.PathChecksum ,
885
+ " /qrc_" , qrc.QrcName , " .cpp" );
891
886
{
892
- std::string rccFile = this ->Dir .Build + " /" ;
893
- rccFile += qrc.PathChecksum ;
894
- rccFile += " /qrc_" ;
895
- rccFile += qrc.QrcName ;
896
- rccFile += " .cpp" ;
897
- qrc.RccFile = std::move (rccFile);
898
- }
899
- {
900
- std::string base = this ->Dir .Info ;
901
- base += " /RCC" ;
902
- base += qrc.QrcName ;
887
+ std::string base = cmStrCat (this ->Dir .Info , " /RCC" , qrc.QrcName );
903
888
if (!qrc.Unique ) {
904
889
base += qrc.PathChecksum ;
905
890
}
@@ -932,8 +917,7 @@ bool cmQtAutoGenInitializer::InitScanFiles()
932
917
// Replace '-' with '_'. The former is not valid for symbol names.
933
918
std::replace (name.begin (), name.end (), ' -' , ' _' );
934
919
if (!qrc.Unique ) {
935
- name += " _" ;
936
- name += qrc.PathChecksum ;
920
+ name += cmStrCat (" _" , qrc.PathChecksum );
937
921
}
938
922
std::vector<std::string> nameOpts;
939
923
nameOpts.emplace_back (" -name" );
@@ -1157,8 +1141,8 @@ bool cmQtAutoGenInitializer::InitRccTargets()
1157
1141
currentLine.push_back (" $<CONFIG>" );
1158
1142
commandLines.push_back (std::move (currentLine));
1159
1143
}
1160
- std::string ccComment = " Automatic RCC for " ;
1161
- ccComment += FileProjectRelativePath (makefile, qrc.QrcFile );
1144
+ std::string ccComment = cmStrCat (
1145
+ " Automatic RCC for " , FileProjectRelativePath (makefile, qrc.QrcFile ) );
1162
1146
1163
1147
if (qrc.Generated || this ->Rcc .GlobalTarget ) {
1164
1148
// Create custom rcc target
@@ -1226,9 +1210,8 @@ bool cmQtAutoGenInitializer::SetupCustomTargets()
1226
1210
{
1227
1211
// Create info directory on demand
1228
1212
if (!cmSystemTools::MakeDirectory (this ->Dir .Info )) {
1229
- std::string emsg = (" AutoGen: Could not create directory: " );
1230
- emsg += Quoted (this ->Dir .Info );
1231
- cmSystemTools::Error (emsg);
1213
+ cmSystemTools::Error (cmStrCat (" AutoGen: Could not create directory: " ,
1214
+ Quoted (this ->Dir .Info )));
1232
1215
return false ;
1233
1216
}
1234
1217
@@ -1311,10 +1294,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
1311
1294
}
1312
1295
if (muf->MocIt || muf->UicIt ) {
1313
1296
headers.emplace_back (muf->RealPath );
1314
- std::string flags;
1315
- flags += muf->MocIt ? ' M' : ' m' ;
1316
- flags += muf->UicIt ? ' U' : ' u' ;
1317
- headersFlags.emplace_back (std::move (flags));
1297
+ headersFlags.emplace_back (
1298
+ cmStrCat (muf->MocIt ? " M" : " m" , muf->UicIt ? " U" : " u" ));
1318
1299
}
1319
1300
}
1320
1301
}
@@ -1323,14 +1304,13 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
1323
1304
cmFilePathChecksum const fpathCheckSum (makefile);
1324
1305
std::unordered_set<std::string> emitted;
1325
1306
for (std::string const & hdr : headers) {
1326
- std::string basePath = fpathCheckSum. getPart (hdr);
1327
- basePath += " /moc_" ;
1328
- basePath += cmSystemTools::GetFilenameWithoutLastExtension (hdr);
1329
- for (unsigned int ii = 1 ; ii != 1024 ; ++ii) {
1307
+ std::string basePath =
1308
+ cmStrCat (fpathCheckSum. getPart (hdr), " /moc_" ,
1309
+ cmSystemTools::GetFilenameWithoutLastExtension (hdr) );
1310
+ for (int ii = 1 ; ii != 1024 ; ++ii) {
1330
1311
std::string path = basePath;
1331
1312
if (ii > 1 ) {
1332
- path += ' _' ;
1333
- path += std::to_string (ii);
1313
+ path += cmStrCat (" _" , ii);
1334
1314
}
1335
1315
path += " .cpp" ;
1336
1316
if (emitted.emplace (path).second ) {
@@ -1369,10 +1349,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
1369
1349
}
1370
1350
if (muf->MocIt || muf->UicIt ) {
1371
1351
sources.emplace_back (muf->RealPath );
1372
- std::string flags;
1373
- flags += muf->MocIt ? ' M' : ' m' ;
1374
- flags += muf->UicIt ? ' U' : ' u' ;
1375
- sourcesFlags.emplace_back (std::move (flags));
1352
+ sourcesFlags.emplace_back (
1353
+ cmStrCat (muf->MocIt ? " M" : " m" , muf->UicIt ? " U" : " u" ));
1376
1354
}
1377
1355
}
1378
1356
}
@@ -1426,9 +1404,8 @@ bool cmQtAutoGenInitializer::SetupWriteAutogenInfo()
1426
1404
ofs.WriteStrings (" AM_UIC_SEARCH_PATHS" , this ->Uic .SearchPaths );
1427
1405
}
1428
1406
} else {
1429
- std::string err = " AutoGen: Could not write file " ;
1430
- err += this ->AutogenTarget .InfoFile ;
1431
- cmSystemTools::Error (err);
1407
+ cmSystemTools::Error (cmStrCat (" AutoGen: Could not write file " ,
1408
+ this ->AutogenTarget .InfoFile ));
1432
1409
return false ;
1433
1410
}
1434
1411
@@ -1467,9 +1444,8 @@ bool cmQtAutoGenInitializer::SetupWriteRccInfo()
1467
1444
ofs.WriteStrings (" ARCC_OPTIONS" , qrc.Options );
1468
1445
ofs.WriteStrings (" ARCC_INPUTS" , qrc.Resources );
1469
1446
} else {
1470
- std::string err = " AutoRcc: Could not write file " ;
1471
- err += qrc.InfoFile ;
1472
- cmSystemTools::Error (err);
1447
+ cmSystemTools::Error (
1448
+ cmStrCat (" AutoRcc: Could not write file " , qrc.InfoFile ));
1473
1449
return false ;
1474
1450
}
1475
1451
}
@@ -1524,13 +1500,10 @@ bool cmQtAutoGenInitializer::AddToSourceGroup(std::string const& fileName,
1524
1500
if (!groupName.empty ()) {
1525
1501
sourceGroup = makefile->GetOrCreateSourceGroup (groupName);
1526
1502
if (sourceGroup == nullptr ) {
1527
- std::string err;
1528
- err += genNameUpper;
1529
- err += " error in " ;
1530
- err += property;
1531
- err += " : Could not find or create the source group " ;
1532
- err += cmQtAutoGen::Quoted (groupName);
1533
- cmSystemTools::Error (err);
1503
+ cmSystemTools::Error (
1504
+ cmStrCat (genNameUpper, " error in " , property,
1505
+ " : Could not find or create the source group " ,
1506
+ cmQtAutoGen::Quoted (groupName)));
1534
1507
return false ;
1535
1508
}
1536
1509
}
@@ -1622,12 +1595,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
1622
1595
bool ignoreMissingTarget) const
1623
1596
{
1624
1597
auto print_err = [this , &genVars](std::string const & err) {
1625
- std::string msg = genVars.GenNameUpper ;
1626
- msg += " for target " ;
1627
- msg += this ->Target ->GetName ();
1628
- msg += " : " ;
1629
- msg += err;
1630
- cmSystemTools::Error (msg);
1598
+ cmSystemTools::Error (cmStrCat (genVars.GenNameUpper , " for target " ,
1599
+ this ->Target ->GetName (), " : " , err));
1631
1600
};
1632
1601
1633
1602
// Custom executable
@@ -1687,11 +1656,8 @@ bool cmQtAutoGenInitializer::GetQtExecutable(GenVarsT& genVars,
1687
1656
std::make_shared<cmQtAutoGen::CompilerFeatures>();
1688
1657
return true ;
1689
1658
}
1690
- std::string err = " Could not find " ;
1691
- err += executable;
1692
- err += " executable target " ;
1693
- err += targetName;
1694
- print_err (err);
1659
+ print_err (cmStrCat (" Could not find " , executable, " executable target " ,
1660
+ targetName));
1695
1661
return false ;
1696
1662
}
1697
1663
}
0 commit comments