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

Function AddDefinitions

Source/cmPackageInfoReader.cxx:371–408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369using DefinitionsMap = std::map<std::string, DefinitionLanguageMap>;
370
371void AddDefinitions(cmMakefile* makefile, cmTarget* target,
372 cm::string_view configuration,
373 DefinitionsMap const& definitions)
374{
375 for (auto const& di : definitions) {
376 auto const& g = di.second.find("*"_s);
377 if (g != di.second.end()) {
378 std::string const& def = BuildDefinition(di.first, g->second);
379 if (di.second.size() == 1) {
380 // Only the non-language-specific definition exists.
381 AddDefinition(makefile, target, configuration, def);
382 continue;
383 }
384
385 // Create a genex to apply this definition to all languages except
386 // those that override it.
387 std::vector<cm::string_view> excludedLanguages;
388 for (auto const& li : di.second) {
389 if (li.first != "*"_s) {
390 excludedLanguages.emplace_back(li.first);
391 }
392 }
393 AddDefinition(makefile, target, configuration,
394 cmStrCat("$<$<NOT:$<COMPILE_LANGUAGE:"_s,
395 cmJoin(excludedLanguages, ","_s), ">>:"_s, def,
396 '>'));
397 }
398
399 // Add language-specific definitions.
400 for (auto const& li : di.second) {
401 if (li.first != "*"_s) {
402 AddDefinition(makefile, target, configuration,
403 cmStrCat("$<$<COMPILE_LANGUAGE:"_s, li.first, ">:"_s,
404 BuildDefinition(di.first, li.second), '>'));
405 }
406 }
407 }
408}
409
410cm::optional<cmPackageInfoReader::Pep440Version> ParseSimpleVersion(
411 std::string const& version)

Callers 1

SetTargetPropertiesMethod · 0.85

Calls 8

BuildDefinitionFunction · 0.85
AddDefinitionFunction · 0.85
emplace_backMethod · 0.80
cmStrCatFunction · 0.70
cmJoinFunction · 0.70
findMethod · 0.45
endMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…