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

Method AddLibraryFeature

Source/cmComputeLinkInformation.cxx:793–931  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

791}
792
793bool cmComputeLinkInformation::AddLibraryFeature(std::string const& feature)
794{
795 auto it = this->LibraryFeatureDescriptors.find(feature);
796 if (it != this->LibraryFeatureDescriptors.end()) {
797 return it->second.Supported;
798 }
799
800 auto featureName =
801 cmStrCat("CMAKE_", this->LinkLanguage, "_LINK_LIBRARY_USING_", feature);
802 cmValue featureSupported =
803 this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
804 if (!featureSupported) {
805 // language specific variable is not defined, fallback to the more generic
806 // one
807 featureName = cmStrCat("CMAKE_LINK_LIBRARY_USING_", feature);
808 featureSupported =
809 this->Makefile->GetDefinition(cmStrCat(featureName, "_SUPPORTED"));
810 }
811 if (!featureSupported.IsOn()) {
812 this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
813
814 this->CMakeInstance->IssueMessage(
815 MessageType::FATAL_ERROR,
816 cmStrCat(
817 "Feature '", feature,
818 "', specified through generator-expression '$<LINK_LIBRARY>' to "
819 "link target '",
820 this->Target->GetName(), "', is not supported for the '",
821 this->LinkLanguage, "' link language."),
822 this->Target->GetBacktrace());
823
824 return false;
825 }
826
827 cmValue langFeature = this->Makefile->GetDefinition(featureName);
828 if (!langFeature) {
829 this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
830
831 this->CMakeInstance->IssueMessage(
832 MessageType::FATAL_ERROR,
833 cmStrCat(
834 "Feature '", feature,
835 "', specified through generator-expression '$<LINK_LIBRARY>' to "
836 "link target '",
837 this->Target->GetName(), "', is not defined for the '",
838 this->LinkLanguage, "' link language."),
839 this->Target->GetBacktrace());
840
841 return false;
842 }
843
844 auto items = cmExpandListWithBacktrace(
845 *langFeature, this->Target->GetBacktrace(), cmList::EmptyElements::Yes);
846
847 if ((items.size() == 1 && !IsValidFeatureFormat(items.front().Value)) ||
848 (items.size() == 3 && !IsValidFeatureFormat(items[1].Value))) {
849 this->LibraryFeatureDescriptors.emplace(feature, FeatureDescriptor{});
850 this->CMakeInstance->IssueMessage(

Callers 3

ComputeMethod · 0.95
AddTargetItemMethod · 0.95
AddFrameworkItemMethod · 0.95

Calls 15

IsValidFeatureFormatFunction · 0.85
FinalizeFeatureFormatFunction · 0.85
emplaceMethod · 0.80
push_backMethod · 0.80
cmStrCatFunction · 0.70
findMethod · 0.45
endMethod · 0.45
GetDefinitionMethod · 0.45
IsOnMethod · 0.45
IssueMessageMethod · 0.45
GetNameMethod · 0.45

Tested by

no test coverage detected