From 04a8572b9985a7c7c3eec95e52bc1ce144f39c8f Mon Sep 17 00:00:00 2001 From: Andy Cedilnik Date: Fri, 2 Jul 2004 11:51:30 -0400 Subject: BUG: If the destination is the same as source, do not copy file. Fixes Bug #956 - make install broken --- Source/cmFileCommand.cxx | 73 +++++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 35 deletions(-) (limited to 'Source/cmFileCommand.cxx') diff --git a/Source/cmFileCommand.cxx b/Source/cmFileCommand.cxx index 471b92ad3c..a1d85b2d2c 100644 --- a/Source/cmFileCommand.cxx +++ b/Source/cmFileCommand.cxx @@ -549,51 +549,54 @@ bool cmFileCommand::HandleInstallCommand( break; } - if ( cmSystemTools::FileExists(ctarget.c_str()) ) + if ( !cmSystemTools::SameFile(ctarget.c_str(), destfile.c_str()) ) { - cmSystemTools::RemoveFile(destfile.c_str()); - if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(), - destination.c_str()) ) + if ( cmSystemTools::FileExists(ctarget.c_str()) ) { - std::string errstring = "cannot copy file: " + ctarget + - " to directory : " + destination + "."; - this->SetError(errstring.c_str()); - return false; - } - switch( itype ) - { - case cmTarget::MODULE_LIBRARY: - case cmTarget::SHARED_LIBRARY: - case cmTarget::EXECUTABLE: - case cmTarget::INSTALL_PROGRAMS: + cmSystemTools::RemoveFile(destfile.c_str()); + if ( !cmSystemTools::CopyFileAlways(ctarget.c_str(), + destination.c_str()) ) + { + std::string errstring = "cannot copy file: " + ctarget + + " to directory : " + destination + "."; + this->SetError(errstring.c_str()); + return false; + } + switch( itype ) + { + case cmTarget::MODULE_LIBRARY: + case cmTarget::SHARED_LIBRARY: + case cmTarget::EXECUTABLE: + case cmTarget::INSTALL_PROGRAMS: - if ( !cmSystemTools::SetPermissions(destfile.c_str(), + if ( !cmSystemTools::SetPermissions(destfile.c_str(), #if defined( _MSC_VER ) || defined( __MINGW32__ ) - S_IREAD | S_IWRITE | S_IEXEC + S_IREAD | S_IWRITE | S_IEXEC #elif defined( __BORLANDC__ ) - S_IRUSR | S_IWUSR | S_IXUSR + S_IRUSR | S_IWUSR | S_IXUSR #else - S_IRUSR | S_IWUSR | S_IXUSR | - S_IRGRP | S_IXGRP | - S_IROTH | S_IXOTH + S_IRUSR | S_IWUSR | S_IXUSR | + S_IRGRP | S_IXGRP | + S_IROTH | S_IXOTH #endif - ) ) - { - cmOStringStream err; - err << "Problem setting permissions on file: " << destfile.c_str(); - perror(err.str().c_str()); + ) ) + { + cmOStringStream err; + err << "Problem setting permissions on file: " << destfile.c_str(); + perror(err.str().c_str()); + } } + smanifest_files += ";" + destfile; } - smanifest_files += ";" + destfile; - } - else - { - if ( !optional ) + else { - std::string errstring = "cannot find file: " + - ctarget + " to install."; - this->SetError(errstring.c_str()); - return false; + if ( !optional ) + { + std::string errstring = "cannot find file: " + + ctarget + " to install."; + this->SetError(errstring.c_str()); + return false; + } } } } -- cgit v1.2.1