| 11 | #include "cmTarget.h" |
| 12 | |
| 13 | bool cmAddExecutableCommand(std::vector<std::string> const& args, |
| 14 | cmExecutionStatus& status) |
| 15 | { |
| 16 | if (args.empty()) { |
| 17 | status.SetError("called with incorrect number of arguments"); |
| 18 | return false; |
| 19 | } |
| 20 | |
| 21 | cmMakefile& mf = status.GetMakefile(); |
| 22 | auto s = args.begin(); |
| 23 | |
| 24 | std::string const& exename = *s; |
| 25 | |
| 26 | ++s; |
| 27 | bool use_win32 = false; |
| 28 | bool use_macbundle = false; |
| 29 | bool excludeFromAll = false; |
| 30 | bool importTarget = false; |
| 31 | bool importGlobal = false; |
| 32 | bool isAlias = false; |
| 33 | while (s != args.end()) { |
| 34 | if (*s == "WIN32") { |
| 35 | ++s; |
| 36 | use_win32 = true; |
| 37 | } else if (*s == "MACOSX_BUNDLE") { |
| 38 | ++s; |
| 39 | use_macbundle = true; |
| 40 | } else if (*s == "EXCLUDE_FROM_ALL") { |
| 41 | ++s; |
| 42 | excludeFromAll = true; |
| 43 | } else if (*s == "IMPORTED") { |
| 44 | ++s; |
| 45 | importTarget = true; |
| 46 | } else if (importTarget && *s == "GLOBAL") { |
| 47 | ++s; |
| 48 | importGlobal = true; |
| 49 | } else if (*s == "ALIAS") { |
| 50 | ++s; |
| 51 | isAlias = true; |
| 52 | } else { |
| 53 | break; |
| 54 | } |
| 55 | } |
| 56 | |
| 57 | if (importTarget && !importGlobal) { |
| 58 | importGlobal = mf.IsImportedTargetGlobalScope(); |
| 59 | } |
| 60 | |
| 61 | bool nameOk = cmGeneratorExpression::IsValidTargetName(exename) && |
| 62 | !cmGlobalGenerator::IsReservedTarget(exename); |
| 63 | |
| 64 | if (nameOk && !importTarget && !isAlias) { |
| 65 | nameOk = exename.find(':') == std::string::npos; |
| 66 | } |
| 67 | if (!nameOk) { |
| 68 | mf.IssueInvalidTargetNameError(exename); |
| 69 | return false; |
| 70 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…