diff options
author | Brad King <brad.king@kitware.com> | 2006-02-19 21:12:29 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2006-02-19 21:12:29 (GMT) |
commit | e14d59119410314538ede3dd819f7d1fcf9f43f2 (patch) | |
tree | 0970c9209431dda6035aee16eb38092e7a442527 | |
parent | 39f4e7f5e0aac2af3e4e02e9d563dbb88757fd8a (diff) | |
download | CMake-e14d59119410314538ede3dd819f7d1fcf9f43f2.zip CMake-e14d59119410314538ede3dd819f7d1fcf9f43f2.tar.gz CMake-e14d59119410314538ede3dd819f7d1fcf9f43f2.tar.bz2 |
BUG: Do not report files as installed if they are optional and do not exist.
-rw-r--r-- | Source/cmInstallGenerator.cxx | 35 | ||||
-rw-r--r-- | Source/cmInstallGenerator.h | 2 |
2 files changed, 25 insertions, 12 deletions
diff --git a/Source/cmInstallGenerator.cxx b/Source/cmInstallGenerator.cxx index 5448383..fd337ea 100644 --- a/Source/cmInstallGenerator.cxx +++ b/Source/cmInstallGenerator.cxx @@ -50,14 +50,24 @@ cmInstallGenerator void cmInstallGenerator::AddInstallRule(std::ostream& os, const char* dest, int type, - const char* files, + const char* file, bool optional /* = false */, const char* properties /* = 0 */) { - // TODO: Make optional files use IF(EXISTS) to not report if not - // installing. - std::string sfiles = files; - std::string destination = dest; + // If the file is optional test its existence before installing. + const char* indent = ""; + if(optional) + { + os << "IF(EXISTS \"" << file << "\")\n"; + indent = " "; + } + + // Write a message indicating the file is being installed. + std::string fname = cmSystemTools::GetFilenameName(file); + os << indent << "MESSAGE(STATUS \"Installing " << dest + << "/" << fname.c_str() << "\")\n"; + + // Use the FILE command to install the file. std::string stype; switch(type) { @@ -69,14 +79,17 @@ void cmInstallGenerator::AddInstallRule(std::ostream& os, case cmTarget::INSTALL_FILES: default: stype = "FILE"; break; } - std::string fname = cmSystemTools::GetFilenameName(sfiles.c_str()); - os << "MESSAGE(STATUS \"Installing " << destination.c_str() - << "/" << fname.c_str() << "\")\n" - << "FILE(INSTALL DESTINATION \"" << destination.c_str() - << "\" TYPE " << stype.c_str() << (optional?" OPTIONAL":"") ; + os << indent << "FILE(INSTALL DESTINATION \"" << dest + << "\" TYPE " << stype.c_str() ; if(properties && *properties) { os << " PROPERTIES" << properties; } - os << " FILES \"" << sfiles.c_str() << "\")\n"; + os << " FILES \"" << file << "\")\n"; + + // If the file is optional close the IF block. + if(optional) + { + os << "ENDIF(EXISTS \"" << file << "\")\n"; + } } diff --git a/Source/cmInstallGenerator.h b/Source/cmInstallGenerator.h index fcb496c..e04ba52 100644 --- a/Source/cmInstallGenerator.h +++ b/Source/cmInstallGenerator.h @@ -35,7 +35,7 @@ public: std::vector<std::string> const& configurationTypes); static void AddInstallRule(std::ostream& os, const char* dest, int type, - const char* files, bool optional = false, + const char* file, bool optional = false, const char* properties = 0); protected: |