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

Method WriteUnitySource

Source/cmLocalGenerator.cxx:3060–3092  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3058}
3059
3060cmLocalGenerator::UnitySource cmLocalGenerator::WriteUnitySource(
3061 cmGeneratorTarget* target, std::vector<std::string> const& configs,
3062 cmRange<std::vector<UnityBatchedSource>::const_iterator> sources,
3063 cmValue beforeInclude, cmValue afterInclude, std::string filename,
3064 std::string const& unityFileDirectory, UnityPathMode pathMode) const
3065{
3066 cmValue uniqueIdName = target->GetProperty("UNITY_BUILD_UNIQUE_ID");
3067 cmGeneratedFileStream file(
3068 filename, false, target->GetGlobalGenerator()->GetMakefileEncoding());
3069 file.SetCopyIfDifferent(true);
3070 file << "/* generated by CMake */\n\n";
3071
3072 bool perConfig = false;
3073 for (UnityBatchedSource const& ubs : sources) {
3074 cm::optional<std::string> cond;
3075 if (ubs.Configs.size() != configs.size()) {
3076 perConfig = true;
3077 cond = std::string();
3078 cm::string_view sep;
3079 for (size_t ci : ubs.Configs) {
3080 cond = cmStrCat(*cond, sep, "defined(CMAKE_UNITY_CONFIG_",
3081 cmSystemTools::UpperCase(configs[ci]), ')');
3082 sep = " || "_s;
3083 }
3084 }
3085 RegisterUnitySources(target, ubs.Source, filename);
3086 WriteUnitySourceInclude(file, cond, ubs.Source->ResolveFullPath(),
3087 beforeInclude, afterInclude, uniqueIdName,
3088 pathMode, unityFileDirectory);
3089 }
3090
3091 return UnitySource(std::move(filename), perConfig);
3092}
3093
3094void cmLocalGenerator::WriteUnitySourceInclude(
3095 std::ostream& unity_file, cm::optional<std::string> const& cond,

Callers 2

AddUnityFilesModeAutoMethod · 0.95

Calls 9

RegisterUnitySourcesFunction · 0.85
UnitySourceClass · 0.85
moveFunction · 0.85
SetCopyIfDifferentMethod · 0.80
cmStrCatFunction · 0.70
GetPropertyMethod · 0.45
GetMakefileEncodingMethod · 0.45
GetGlobalGeneratorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected