| 3058 | } |
| 3059 | |
| 3060 | cmLocalGenerator::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 | |
| 3094 | void cmLocalGenerator::WriteUnitySourceInclude( |
| 3095 | std::ostream& unity_file, cm::optional<std::string> const& cond, |
no test coverage detected