MCPcopy Create free account
hub / github.com/Kitware/CMake / AppendTarget

Method AppendTarget

Source/cmExtraSublimeTextGenerator.cxx:238–309  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

236}
237
238void cmExtraSublimeTextGenerator::AppendTarget(
239 cmGeneratedFileStream& fout, std::string const& targetName,
240 cmLocalGenerator* lg, cmGeneratorTarget* target, char const* make,
241 cmMakefile const* makefile, char const* /*compiler*/,
242 MapSourceFileFlags& sourceFileFlags, bool firstTarget)
243{
244
245 if (target) {
246 std::vector<cmSourceFile*> sourceFiles;
247 target->GetSourceFiles(sourceFiles,
248 makefile->GetSafeDefinition("CMAKE_BUILD_TYPE"));
249 for (cmSourceFile* sourceFile : sourceFiles) {
250 auto sourceFileFlagsIter =
251 sourceFileFlags.find(sourceFile->ResolveFullPath());
252 if (sourceFileFlagsIter == sourceFileFlags.end()) {
253 sourceFileFlagsIter =
254 sourceFileFlags
255 .insert(MapSourceFileFlags::value_type(
256 sourceFile->ResolveFullPath(), std::vector<std::string>()))
257 .first;
258 }
259 std::vector<std::string>& flags = sourceFileFlagsIter->second;
260 std::string flagsString =
261 this->ComputeFlagsForObject(sourceFile, lg, target);
262 std::string definesString = this->ComputeDefines(sourceFile, lg, target);
263 std::string includesString =
264 this->ComputeIncludes(sourceFile, lg, target);
265 flags.clear();
266 cmsys::RegularExpression flagRegex;
267 // Regular expression to extract compiler flags from a string
268 // https://gist.github.com/3944250
269 char const* regexString =
270 R"((^|[ ])-[DIOUWfgs][^= ]+(=\"[^"]+\"|=[^"][^ ]+)?)";
271 flagRegex.compile(regexString);
272 std::string workString =
273 cmStrCat(flagsString, ' ', definesString, ' ', includesString);
274 while (flagRegex.find(workString)) {
275 std::string::size_type start = flagRegex.start();
276 if (workString[start] == ' ') {
277 start++;
278 }
279 flags.push_back(workString.substr(start, flagRegex.end() - start));
280 if (flagRegex.end() < workString.size()) {
281 workString = workString.substr(flagRegex.end());
282 } else {
283 workString.clear();
284 }
285 }
286 }
287 }
288
289 // Ninja uses ninja.build files (look for a way to get the output file name
290 // from cmMakefile or something)
291 std::string makefileName;
292 if (this->GlobalGenerator->GetName() == "Ninja") {
293 makefileName = "build.ninja";
294 } else {
295 makefileName = "Makefile";

Callers 1

AppendAllTargetsMethod · 0.95

Calls 15

ComputeFlagsForObjectMethod · 0.95
ComputeDefinesMethod · 0.95
ComputeIncludesMethod · 0.95
BuildMakeCommandMethod · 0.95
GetSourceFilesMethod · 0.80
compileMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
findMethod · 0.45
endMethod · 0.45
insertMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected