| 2201 | } |
| 2202 | |
| 2203 | std::string cmLocalUnixMakefileGenerator3::ConvertToQuotedOutputPath( |
| 2204 | std::string const& p, bool useWatcomQuote) |
| 2205 | { |
| 2206 | // Split the path into its components. |
| 2207 | std::vector<std::string> components; |
| 2208 | cmSystemTools::SplitPath(p, components); |
| 2209 | |
| 2210 | // Open the quoted result. |
| 2211 | std::string result; |
| 2212 | if (useWatcomQuote) { |
| 2213 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 2214 | result = "'"; |
| 2215 | #else |
| 2216 | result = "\"'"; |
| 2217 | #endif |
| 2218 | } else { |
| 2219 | result = "\""; |
| 2220 | } |
| 2221 | |
| 2222 | // Return an empty path if there are no components. |
| 2223 | if (!components.empty()) { |
| 2224 | // Choose a slash direction and fix root component. |
| 2225 | char const* slash = "/"; |
| 2226 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 2227 | if (!cmSystemTools::GetForceUnixPaths()) { |
| 2228 | slash = "\\"; |
| 2229 | for (char& i : components[0]) { |
| 2230 | if (i == '/') { |
| 2231 | i = '\\'; |
| 2232 | } |
| 2233 | } |
| 2234 | } |
| 2235 | #endif |
| 2236 | |
| 2237 | // Begin the quoted result with the root component. |
| 2238 | result += components[0]; |
| 2239 | |
| 2240 | if (components.size() > 1) { |
| 2241 | // Now add the rest of the components separated by the proper slash |
| 2242 | // direction for this platform. |
| 2243 | auto compEnd = std::remove(components.begin() + 1, components.end() - 1, |
| 2244 | std::string()); |
| 2245 | auto compStart = components.begin() + 1; |
| 2246 | result += cmJoin(cmMakeRange(compStart, compEnd), slash); |
| 2247 | // Only the last component can be empty to avoid double slashes. |
| 2248 | result += slash; |
| 2249 | result += components.back(); |
| 2250 | } |
| 2251 | } |
| 2252 | |
| 2253 | // Close the quoted result. |
| 2254 | if (useWatcomQuote) { |
| 2255 | #if defined(_WIN32) && !defined(__CYGWIN__) |
| 2256 | result += "'"; |
| 2257 | #else |
| 2258 | result += "'\""; |
| 2259 | #endif |
| 2260 | } else { |