ENH: Add support to INSTALL(DIRECTORY) to install an empty directory. This addresses bug#3572.
This commit is contained in:
parent
7001a88a74
commit
27a67fb72f
|
@ -519,6 +519,11 @@ bool cmFileInstaller::InstallDirectory(const char* source,
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inform the user about this directory installation.
|
||||||
|
std::string message = "Installing ";
|
||||||
|
message += destination;
|
||||||
|
this->Makefile->DisplayStatus(message.c_str(), -1);
|
||||||
|
|
||||||
// Make sure the destination directory exists.
|
// Make sure the destination directory exists.
|
||||||
if(!cmSystemTools::MakeDirectory(destination))
|
if(!cmSystemTools::MakeDirectory(destination))
|
||||||
{
|
{
|
||||||
|
@ -568,7 +573,10 @@ bool cmFileInstaller::InstallDirectory(const char* source,
|
||||||
|
|
||||||
// Load the directory contents to traverse it recursively.
|
// Load the directory contents to traverse it recursively.
|
||||||
cmsys::Directory dir;
|
cmsys::Directory dir;
|
||||||
dir.Load(source);
|
if(source && *source)
|
||||||
|
{
|
||||||
|
dir.Load(source);
|
||||||
|
}
|
||||||
unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
|
unsigned long numFiles = static_cast<unsigned long>(dir.GetNumberOfFiles());
|
||||||
for(unsigned long fileNum = 0; fileNum < numFiles; ++fileNum)
|
for(unsigned long fileNum = 0; fileNum < numFiles; ++fileNum)
|
||||||
{
|
{
|
||||||
|
@ -1280,7 +1288,8 @@ bool cmFileCommand::HandleInstallCommand(
|
||||||
if(!cmSystemTools::SameFile(fromFile.c_str(), toFile.c_str()))
|
if(!cmSystemTools::SameFile(fromFile.c_str(), toFile.c_str()))
|
||||||
{
|
{
|
||||||
if(itype == cmTarget::INSTALL_DIRECTORY &&
|
if(itype == cmTarget::INSTALL_DIRECTORY &&
|
||||||
cmSystemTools::FileIsDirectory(fromFile.c_str()))
|
(fromFile.empty() ||
|
||||||
|
cmSystemTools::FileIsDirectory(fromFile.c_str())))
|
||||||
{
|
{
|
||||||
// Try installing this directory.
|
// Try installing this directory.
|
||||||
if(!installer.InstallDirectory(fromFile.c_str(), toFile.c_str(),
|
if(!installer.InstallDirectory(fromFile.c_str(), toFile.c_str(),
|
||||||
|
|
|
@ -1000,6 +1000,12 @@ cmInstallCommand::HandleDirectoryMode(std::vector<std::string> const& args)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Support installing an empty directory.
|
||||||
|
if(dirs.empty() && destination)
|
||||||
|
{
|
||||||
|
dirs.push_back("");
|
||||||
|
}
|
||||||
|
|
||||||
// Check if there is something to do.
|
// Check if there is something to do.
|
||||||
if(dirs.empty())
|
if(dirs.empty())
|
||||||
{
|
{
|
||||||
|
|
|
@ -107,6 +107,15 @@ IF(STAGE2)
|
||||||
MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]")
|
MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]")
|
||||||
ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
|
ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
|
||||||
|
|
||||||
|
# Check for failure of empty directory installation.
|
||||||
|
IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
|
||||||
|
MESSAGE(FATAL_ERROR "Empty directory installation did not install.")
|
||||||
|
ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
|
||||||
|
FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*")
|
||||||
|
IF(EMPTY_FILES)
|
||||||
|
MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].")
|
||||||
|
ENDIF(EMPTY_FILES)
|
||||||
|
|
||||||
# Make sure the test executable can run from the install tree.
|
# Make sure the test executable can run from the install tree.
|
||||||
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
|
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
|
||||||
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
|
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
|
||||||
|
@ -174,6 +183,9 @@ ELSE(STAGE2)
|
||||||
PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
|
PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Test empty directory installation.
|
||||||
|
INSTALL(DIRECTORY DESTINATION MyTest/share/empty)
|
||||||
|
|
||||||
# Test user-specified install scripts.
|
# Test user-specified install scripts.
|
||||||
INSTALL(
|
INSTALL(
|
||||||
SCRIPT InstallScript1.cmake
|
SCRIPT InstallScript1.cmake
|
||||||
|
|
|
@ -107,6 +107,15 @@ IF(STAGE2)
|
||||||
MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]")
|
MESSAGE(FATAL_ERROR "Bad sample script output: [${SAMPLE_SCRIPT_OUTPUT}]")
|
||||||
ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
|
ENDIF(NOT "${SAMPLE_SCRIPT_OUTPUT}" MATCHES "Sample Script Output")
|
||||||
|
|
||||||
|
# Check for failure of empty directory installation.
|
||||||
|
IF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
|
||||||
|
MESSAGE(FATAL_ERROR "Empty directory installation did not install.")
|
||||||
|
ENDIF(NOT EXISTS "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty")
|
||||||
|
FILE(GLOB EMPTY_FILES "${CMAKE_INSTALL_PREFIX}/MyTest/share/empty/*")
|
||||||
|
IF(EMPTY_FILES)
|
||||||
|
MESSAGE(FATAL_ERROR "Empty directory installed [${EMPTY_FILES}].")
|
||||||
|
ENDIF(EMPTY_FILES)
|
||||||
|
|
||||||
# Make sure the test executable can run from the install tree.
|
# Make sure the test executable can run from the install tree.
|
||||||
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
|
SET_TARGET_PROPERTIES(SimpleInstallS2 PROPERTIES
|
||||||
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
|
INSTALL_RPATH ${CMAKE_INSTALL_PREFIX}/MyTest/lib)
|
||||||
|
@ -174,6 +183,9 @@ ELSE(STAGE2)
|
||||||
PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
|
PATTERN "scripts/*" PERMISSIONS OWNER_EXECUTE OWNER_WRITE OWNER_READ
|
||||||
)
|
)
|
||||||
|
|
||||||
|
# Test empty directory installation.
|
||||||
|
INSTALL(DIRECTORY DESTINATION MyTest/share/empty)
|
||||||
|
|
||||||
# Test user-specified install scripts.
|
# Test user-specified install scripts.
|
||||||
INSTALL(
|
INSTALL(
|
||||||
SCRIPT InstallScript1.cmake
|
SCRIPT InstallScript1.cmake
|
||||||
|
|
Loading…
Reference in New Issue