| 4884 | } |
| 4885 | |
| 4886 | void CreateGeneratedSource(cmLocalGenerator& lg, std::string const& output, |
| 4887 | cmLocalGenerator::OutputRole role, |
| 4888 | cmCommandOrigin origin, |
| 4889 | cmListFileBacktrace const& lfbt) |
| 4890 | { |
| 4891 | if (cmGeneratorExpression::Find(output) != std::string::npos) { |
| 4892 | lg.GetCMakeInstance()->IssueMessage( |
| 4893 | MessageType::FATAL_ERROR, |
| 4894 | "Generator expressions in custom command outputs are not implemented!", |
| 4895 | lfbt); |
| 4896 | return; |
| 4897 | } |
| 4898 | |
| 4899 | // Make sure the file will not be generated into the source |
| 4900 | // directory during an out of source build. |
| 4901 | if (!lg.GetMakefile()->CanIWriteThisFile(output)) { |
| 4902 | lg.GetCMakeInstance()->IssueMessage( |
| 4903 | MessageType::FATAL_ERROR, |
| 4904 | cmStrCat(CustomOutputRoleKeyword(role), " path\n ", output, |
| 4905 | "\nin a source directory as an output of custom command."), |
| 4906 | lfbt); |
| 4907 | return; |
| 4908 | } |
| 4909 | |
| 4910 | // Make sure the output file name has no invalid characters. |
| 4911 | bool const hashNotAllowed = lg.GetState()->UseBorlandMake(); |
| 4912 | std::string::size_type pos = output.find_first_of("<>"); |
| 4913 | if (pos == std::string::npos && hashNotAllowed) { |
| 4914 | pos = output.find_first_of('#'); |
| 4915 | } |
| 4916 | |
| 4917 | if (pos != std::string::npos) { |
| 4918 | lg.GetCMakeInstance()->IssueMessage( |
| 4919 | MessageType::FATAL_ERROR, |
| 4920 | cmStrCat(CustomOutputRoleKeyword(role), " containing a \"", output[pos], |
| 4921 | "\" is not allowed."), |
| 4922 | lfbt); |
| 4923 | return; |
| 4924 | } |
| 4925 | |
| 4926 | // Outputs without generator expressions from the project are already |
| 4927 | // created and marked as generated. Do not mark them again, because |
| 4928 | // other commands might have overwritten the property. |
| 4929 | if (origin == cmCommandOrigin::Generator) { |
| 4930 | lg.GetMakefile()->GetOrCreateGeneratedSource(output); |
| 4931 | } |
| 4932 | } |
| 4933 | |
| 4934 | std::string ComputeCustomCommandRuleFileName(cmLocalGenerator& lg, |
| 4935 | cmListFileBacktrace const& bt, |
no test coverage detected
searching dependent graphs…