| 226 | } |
| 227 | |
| 228 | std::string cmGeneratorExpressionEvaluationFile::FixRelativePath( |
| 229 | std::string const& relativePath, PathRole role, cmLocalGenerator const* lg) |
| 230 | { |
| 231 | std::string resultPath; |
| 232 | switch (this->PolicyStatusCMP0070) { |
| 233 | case cmPolicies::WARN: { |
| 234 | std::string arg; |
| 235 | switch (role) { |
| 236 | case PathForInput: |
| 237 | arg = "INPUT"; |
| 238 | break; |
| 239 | case PathForOutput: |
| 240 | arg = "OUTPUT"; |
| 241 | break; |
| 242 | } |
| 243 | std::ostringstream w; |
| 244 | /* clang-format off */ |
| 245 | w << |
| 246 | cmPolicies::GetPolicyWarning(cmPolicies::CMP0070) << "\n" |
| 247 | "file(GENERATE) given relative " << arg << " path:\n" |
| 248 | " " << relativePath << "\n" |
| 249 | "This is not defined behavior unless CMP0070 is set to NEW. " |
| 250 | "For compatibility with older versions of CMake, the previous " |
| 251 | "undefined behavior will be used." |
| 252 | ; |
| 253 | /* clang-format on */ |
| 254 | lg->IssueMessage(MessageType::AUTHOR_WARNING, w.str()); |
| 255 | } |
| 256 | CM_FALLTHROUGH; |
| 257 | case cmPolicies::OLD: |
| 258 | // OLD behavior is to use the relative path unchanged, |
| 259 | // which ends up being used relative to the working dir. |
| 260 | resultPath = relativePath; |
| 261 | break; |
| 262 | case cmPolicies::NEW: |
| 263 | // NEW behavior is to interpret the relative path with respect |
| 264 | // to the current source or binary directory. |
| 265 | switch (role) { |
| 266 | case PathForInput: |
| 267 | resultPath = cmSystemTools::CollapseFullPath( |
| 268 | relativePath, lg->GetCurrentSourceDirectory()); |
| 269 | break; |
| 270 | case PathForOutput: |
| 271 | resultPath = cmSystemTools::CollapseFullPath( |
| 272 | relativePath, lg->GetCurrentBinaryDirectory()); |
| 273 | break; |
| 274 | } |
| 275 | break; |
| 276 | } |
| 277 | return resultPath; |
| 278 | } |
no test coverage detected