| 21 | } |
| 22 | |
| 23 | bool cmGetSourceFilePropertyCommand(std::vector<std::string> const& args, |
| 24 | cmExecutionStatus& status) |
| 25 | { |
| 26 | std::vector<std::string>::size_type args_size = args.size(); |
| 27 | if (args_size != 3 && args_size != 5) { |
| 28 | status.SetError("called with incorrect number of arguments"); |
| 29 | return false; |
| 30 | } |
| 31 | |
| 32 | std::vector<std::string> source_file_directories; |
| 33 | std::vector<std::string> source_file_target_directories; |
| 34 | bool source_file_directory_option_enabled = false; |
| 35 | bool source_file_target_option_enabled = false; |
| 36 | |
| 37 | int property_arg_index = 2; |
| 38 | if (args[2] == "DIRECTORY"_s && args_size == 5) { |
| 39 | property_arg_index = 4; |
| 40 | source_file_directory_option_enabled = true; |
| 41 | source_file_directories.push_back(args[3]); |
| 42 | } else if (args[2] == "TARGET_DIRECTORY"_s && args_size == 5) { |
| 43 | property_arg_index = 4; |
| 44 | source_file_target_option_enabled = true; |
| 45 | source_file_target_directories.push_back(args[3]); |
| 46 | } |
| 47 | |
| 48 | std::vector<cmMakefile*> source_file_directory_makefiles; |
| 49 | bool file_scopes_handled = |
| 50 | SetPropertyCommand::HandleAndValidateSourceFileDirectoryScopes( |
| 51 | status, source_file_directory_option_enabled, |
| 52 | source_file_target_option_enabled, source_file_directories, |
| 53 | source_file_target_directories, source_file_directory_makefiles); |
| 54 | if (!file_scopes_handled) { |
| 55 | return false; |
| 56 | } |
| 57 | |
| 58 | std::string const& var = args[0]; |
| 59 | std::string const& propName = args[property_arg_index]; |
| 60 | bool source_file_paths_should_be_absolute = |
| 61 | source_file_directory_option_enabled || source_file_target_option_enabled; |
| 62 | cmMakefile& directory_makefile = *source_file_directory_makefiles[0]; |
| 63 | |
| 64 | // Special handling for GENERATED property. |
| 65 | // Note: Only, if CMP0163 is set to NEW! |
| 66 | if (propName == "GENERATED"_s) { |
| 67 | auto& mf = status.GetMakefile(); |
| 68 | auto cmp0163 = directory_makefile.GetPolicyStatus(cmPolicies::CMP0163); |
| 69 | bool const cmp0163new = |
| 70 | cmp0163 != cmPolicies::OLD && cmp0163 != cmPolicies::WARN; |
| 71 | if (cmp0163new) { |
| 72 | return GetPropertyCommand::GetSourceFilePropertyGENERATED( |
| 73 | args[1], mf, [&var, &mf](bool isGenerated) -> bool { |
| 74 | // Set the value on the original Makefile scope, not the scope of the |
| 75 | // requested directory. |
| 76 | mf.AddDefinition(var, (isGenerated) ? cmValue("1") : cmValue("0")); |
| 77 | return true; |
| 78 | }); |
| 79 | } |
| 80 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…