diff options
author | Brad King <brad.king@kitware.com> | 2015-05-15 15:22:29 (GMT) |
---|---|---|
committer | CMake Topic Stage <kwrobot@kitware.com> | 2015-05-15 15:22:29 (GMT) |
commit | 912dff6253891dacb6a0196456adab26516a0949 (patch) | |
tree | db3d3e311f203e08b46044b6f572731f6c47becd /Source | |
parent | e0a2be659f0e7262291ce2e9ece09c1812e41565 (diff) | |
parent | b85d3b66c63afa1ce7f30439deee524241b1efdc (diff) | |
download | CMake-912dff6253891dacb6a0196456adab26516a0949.zip CMake-912dff6253891dacb6a0196456adab26516a0949.tar.gz CMake-912dff6253891dacb6a0196456adab26516a0949.tar.bz2 |
Merge topic 'disallow-install-of-export'
b85d3b66 install: Disallow installing export() result.
501c237a install: Use an intermediate filesVector variable.
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmInstallCommand.cxx | 49 | ||||
-rw-r--r-- | Source/cmPolicies.h | 3 |
2 files changed, 49 insertions, 3 deletions
diff --git a/Source/cmInstallCommand.cxx b/Source/cmInstallCommand.cxx index 78603c8..899b088 100644 --- a/Source/cmInstallCommand.cxx +++ b/Source/cmInstallCommand.cxx @@ -848,13 +848,15 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) return false; } + const std::vector<std::string>& filesVector = files.GetVector(); + // Check if there is something to do. - if(files.GetVector().empty()) + if(filesVector.empty()) { return true; } - if(!ica.GetRename().empty() && files.GetVector().size() > 1) + if(!ica.GetRename().empty() && filesVector.size() > 1) { // The rename option works only with one file. std::ostringstream e; @@ -864,11 +866,52 @@ bool cmInstallCommand::HandleFilesMode(std::vector<std::string> const& args) } std::vector<std::string> absFiles; - if (!this->MakeFilesFullPath(args[0].c_str(), files.GetVector(), absFiles)) + if (!this->MakeFilesFullPath(args[0].c_str(), filesVector, absFiles)) { return false; } + cmPolicies::PolicyStatus status = + this->Makefile->GetPolicyStatus(cmPolicies::CMP0062); + + cmGlobalGenerator *gg = this->Makefile->GetGlobalGenerator(); + for(std::vector<std::string>::const_iterator fileIt = filesVector.begin(); + fileIt != filesVector.end(); ++fileIt) + { + if (gg->IsExportedTargetsFile(*fileIt)) + { + const char *modal = 0; + std::ostringstream e; + cmake::MessageType messageType = cmake::AUTHOR_WARNING; + + switch(status) + { + case cmPolicies::WARN: + e << cmPolicies::GetPolicyWarning(cmPolicies::CMP0062) << "\n"; + modal = "should"; + case cmPolicies::OLD: + break; + case cmPolicies::REQUIRED_IF_USED: + case cmPolicies::REQUIRED_ALWAYS: + case cmPolicies::NEW: + modal = "may"; + messageType = cmake::FATAL_ERROR; + } + if (modal) + { + e << "The file\n " << *fileIt << "\nwas generated by the export() " + "command. It " << modal << " not be installed with the " + "install() command. Use the install(EXPORT) mechanism " + "instead. See the cmake-packages(7) manual for more.\n"; + this->Makefile->IssueMessage(messageType, e.str()); + if (messageType == cmake::FATAL_ERROR) + { + return false; + } + } + } + } + if (!ica.Finalize()) { return false; diff --git a/Source/cmPolicies.h b/Source/cmPolicies.h index 536dcdc..eb56494 100644 --- a/Source/cmPolicies.h +++ b/Source/cmPolicies.h @@ -211,6 +211,9 @@ class cmPolicy; 3, 3, 0, cmPolicies::WARN) \ SELECT(POLICY, CMP0061, \ "CTest does not by default tell make to ignore errors (-i).", \ + 3, 3, 0, cmPolicies::WARN) \ + SELECT(POLICY, CMP0062, \ + "Disallow install() of export() result.", \ 3, 3, 0, cmPolicies::WARN) #define CM_SELECT_ID(F, A1, A2, A3, A4, A5, A6) F(A1) |