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

Function CreateGeneratedSource

Source/cmLocalGenerator.cxx:4886–4932  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4884}
4885
4886void 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
4934std::string ComputeCustomCommandRuleFileName(cmLocalGenerator& lg,
4935 cmListFileBacktrace const& bt,

Callers 1

Calls 10

CustomOutputRoleKeywordFunction · 0.85
CanIWriteThisFileMethod · 0.80
UseBorlandMakeMethod · 0.80
find_first_ofMethod · 0.80
cmStrCatFunction · 0.70
IssueMessageMethod · 0.45
GetCMakeInstanceMethod · 0.45
GetMakefileMethod · 0.45
GetStateMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…