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

Method Evaluate

Source/cmGeneratorExpressionNode.cxx:867–1273  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

865 bool AcceptsArbitraryContentParameter() const override { return true; }
866
867 std::string Evaluate(
868 std::vector<std::string> const& parameters, cm::GenEx::Evaluation* eval,
869 GeneratorExpressionContent const* content,
870 cmGeneratorExpressionDAGChecker* /*dagChecker*/) const override
871 {
872 static auto processList =
873 [](std::string const& arg,
874 std::function<void(std::string&)> transform) -> std::string {
875 cmList list{ arg };
876 std::for_each(list.begin(), list.end(), std::move(transform));
877 return list.to_string();
878 };
879
880 static std::unordered_map<
881 cm::string_view,
882 std::function<std::string(cm::GenEx::Evaluation*,
883 GeneratorExpressionContent const*,
884 Arguments&)>>
885 pathCommands{
886 { "GET_ROOT_NAME"_s,
887 [](cm::GenEx::Evaluation* ev, GeneratorExpressionContent const* cnt,
888 Arguments& args) -> std::string {
889 if (CheckPathParameters(ev, cnt, "GET_ROOT_NAME"_s, args) &&
890 !args.front().empty()) {
891 return processList(args.front(), [](std::string& value) {
892 value = cmCMakePath{ value }.GetRootName().String();
893 });
894 }
895 return std::string{};
896 } },
897 { "GET_ROOT_DIRECTORY"_s,
898 [](cm::GenEx::Evaluation* ev, GeneratorExpressionContent const* cnt,
899 Arguments& args) -> std::string {
900 if (CheckPathParameters(ev, cnt, "GET_ROOT_DIRECTORY"_s, args) &&
901 !args.front().empty()) {
902 return processList(args.front(), [](std::string& value) {
903 value = cmCMakePath{ value }.GetRootDirectory().String();
904 });
905 }
906 return std::string{};
907 } },
908 { "GET_ROOT_PATH"_s,
909 [](cm::GenEx::Evaluation* ev, GeneratorExpressionContent const* cnt,
910 Arguments& args) -> std::string {
911 if (CheckPathParameters(ev, cnt, "GET_ROOT_PATH"_s, args) &&
912 !args.front().empty()) {
913 return processList(args.front(), [](std::string& value) {
914 value = cmCMakePath{ value }.GetRootPath().String();
915 });
916 }
917 return std::string{};
918 } },
919 { "GET_FILENAME"_s,
920 [](cm::GenEx::Evaluation* ev, GeneratorExpressionContent const* cnt,
921 Arguments& args) -> std::string {
922 if (CheckPathParameters(ev, cnt, "GET_FILENAME"_s, args) &&
923 !args.front().empty()) {
924 return processList(args.front(), [](std::string& value) {

Callers

nothing calls this directly

Calls 15

moveFunction · 0.85
CheckPathParametersFunction · 0.85
CheckPathParametersExFunction · 0.85
reportErrorFunction · 0.85
to_stringMethod · 0.80
GetRootNameMethod · 0.80
GetRootDirectoryMethod · 0.80
GetRootPathMethod · 0.80
GetExtensionMethod · 0.80
GetWideExtensionMethod · 0.80
GetStemMethod · 0.80
GetNarrowStemMethod · 0.80

Tested by

no test coverage detected