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

Function ComputeCustomCommandRuleFileName

Source/cmLocalGenerator.cxx:4934–4969  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

4932}
4933
4934std::string ComputeCustomCommandRuleFileName(cmLocalGenerator& lg,
4935 cmListFileBacktrace const& bt,
4936 std::string const& output)
4937{
4938 // If the output path has no generator expressions, use it directly.
4939 if (cmGeneratorExpression::Find(output) == std::string::npos) {
4940 return output;
4941 }
4942
4943 // The output path contains a generator expression, but we must choose
4944 // a single source file path to which to attach the custom command.
4945 // Use some heuristics to provide a nice-looking name when possible.
4946
4947 // If the only genex is $<CONFIG>, replace that gracefully.
4948 {
4949 std::string simple = output;
4950 cmSystemTools::ReplaceString(simple, "$<CONFIG>", "(CONFIG)");
4951 if (cmGeneratorExpression::Find(simple) == std::string::npos) {
4952 return simple;
4953 }
4954 }
4955
4956 // If the genex evaluates to the same value in all configurations, use that.
4957 {
4958 std::vector<std::string> allConfigOutputs =
4959 lg.ExpandCustomCommandOutputGenex(output, bt);
4960 if (allConfigOutputs.size() == 1) {
4961 return allConfigOutputs.front();
4962 }
4963 }
4964
4965 // Fall back to a deterministic unique name.
4966 cmCryptoHash h(cmCryptoHash::AlgoSHA256);
4967 return cmStrCat(lg.GetCurrentBinaryDirectory(), "/CMakeFiles/",
4968 h.HashString(output).substr(0, 16));
4969}
4970
4971cmSourceFile* AddCustomCommand(cmLocalGenerator& lg, cmCommandOrigin origin,
4972 std::unique_ptr<cmCustomCommand> cc,

Callers 1

AddCustomCommandFunction · 0.85

Calls 6

HashStringMethod · 0.80
cmStrCatFunction · 0.70
sizeMethod · 0.45
frontMethod · 0.45
substrMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…