| 193 | } |
| 194 | |
| 195 | bool cmFileInstaller::Parse(std::vector<std::string> const& args) |
| 196 | { |
| 197 | if (!this->cmFileCopier::Parse(args)) { |
| 198 | return false; |
| 199 | } |
| 200 | |
| 201 | if (!this->Rename.empty()) { |
| 202 | if (!this->FilesFromDir.empty()) { |
| 203 | this->Status.SetError("INSTALL option RENAME may not be " |
| 204 | "combined with FILES_FROM_DIR."); |
| 205 | return false; |
| 206 | } |
| 207 | if (this->InstallType != cmInstallType_FILES && |
| 208 | this->InstallType != cmInstallType_PROGRAMS) { |
| 209 | this->Status.SetError("INSTALL option RENAME may be used " |
| 210 | "only with FILES or PROGRAMS."); |
| 211 | return false; |
| 212 | } |
| 213 | if (this->Files.size() > 1) { |
| 214 | this->Status.SetError("INSTALL option RENAME may be used " |
| 215 | "only with one file."); |
| 216 | return false; |
| 217 | } |
| 218 | } |
| 219 | |
| 220 | if (!this->HandleInstallDestination()) { |
| 221 | return false; |
| 222 | } |
| 223 | |
| 224 | if (((this->MessageAlways ? 1 : 0) + (this->MessageLazy ? 1 : 0) + |
| 225 | (this->MessageNever ? 1 : 0)) > 1) { |
| 226 | this->Status.SetError("INSTALL options MESSAGE_ALWAYS, " |
| 227 | "MESSAGE_LAZY, and MESSAGE_NEVER " |
| 228 | "are mutually exclusive."); |
| 229 | return false; |
| 230 | } |
| 231 | |
| 232 | static std::map<cm::string_view, cmInstallMode> const install_mode_dict{ |
| 233 | { "ABS_SYMLINK"_s, cmInstallMode::ABS_SYMLINK }, |
| 234 | { "ABS_SYMLINK_OR_COPY"_s, cmInstallMode::ABS_SYMLINK_OR_COPY }, |
| 235 | { "REL_SYMLINK"_s, cmInstallMode::REL_SYMLINK }, |
| 236 | { "REL_SYMLINK_OR_COPY"_s, cmInstallMode::REL_SYMLINK_OR_COPY }, |
| 237 | { "SYMLINK"_s, cmInstallMode::SYMLINK }, |
| 238 | { "SYMLINK_OR_COPY"_s, cmInstallMode::SYMLINK_OR_COPY } |
| 239 | }; |
| 240 | |
| 241 | std::string install_mode; |
| 242 | cmSystemTools::GetEnv("CMAKE_INSTALL_MODE", install_mode); |
| 243 | if (install_mode.empty() || install_mode == "COPY"_s) { |
| 244 | this->InstallMode = cmInstallMode::COPY; |
| 245 | } else { |
| 246 | auto it = install_mode_dict.find(install_mode); |
| 247 | if (it != install_mode_dict.end()) { |
| 248 | this->InstallMode = it->second; |
| 249 | } else { |
| 250 | auto e = cmStrCat("Unrecognized value '", install_mode, |
| 251 | "' for environment variable CMAKE_INSTALL_MODE"); |
| 252 | this->Status.SetError(e); |