Skip to content

Commit d9afc6c

Browse files
bradkingkwrobot
authored andcommitted
Merge topic 'revert-install-DIRECTORY-exclude-empty' into release-4.1
21e99db install(DIRECTORY): Revert "Add EXCLUDE_EMPTY_DIRECTORIES option" Acked-by: Kitware Robot <[email protected]> Merge-request: !10977
2 parents 6d9c380 + 21e99db commit d9afc6c

11 files changed

+0
-128
lines changed

Help/command/install.rst

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -648,7 +648,6 @@ Signatures
648648
[USE_SOURCE_PERMISSIONS] [OPTIONAL] [MESSAGE_NEVER]
649649
[CONFIGURATIONS <config>...]
650650
[COMPONENT <component>] [EXCLUDE_FROM_ALL]
651-
[EXCLUDE_EMPTY_DIRECTORIES]
652651
[FILES_MATCHING]
653652
[<match-rule> <match-option>...]...
654653
)
@@ -751,13 +750,6 @@ Signatures
751750

752751
Disable file installation status output.
753752

754-
``EXCLUDE_EMPTY_DIRECTORIES``
755-
.. versionadded:: 4.1
756-
757-
Exclude empty directories from installation. A directory is
758-
considered empty if it contains no files, no symbolic links,
759-
and no non-empty subdirectories.
760-
761753
``FILES_MATCHING``
762754
This option may be given before the first ``<match-rule>`` to
763755
disable installation of files (but not directories) not matched

Help/release/4.1.rst

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,6 @@ Commands
7171
``POPULATE`` subcommands for interfacing CMake targets with pkg-config based
7272
dependencies.
7373

74-
* The :command:`install(DIRECTORY)` command gained a new
75-
``EXCLUDE_EMPTY_DIRECTORIES`` option to skip installation
76-
of empty directories.
77-
7874
* The :command:`project` command now has experimental support for the
7975
``COMPAT_VERSION`` keyword, gated by
8076
``CMAKE_EXPERIMENTAL_EXPORT_PACKAGE_INFO``.

Source/cmFileCopier.cxx

Lines changed: 0 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,6 @@
2525

2626
#include <cstring>
2727
#include <sstream>
28-
#include <utility>
29-
30-
#include <cm/string_view>
31-
#include <cmext/string_view>
3228

3329
using namespace cmFSPermissions;
3430

@@ -298,13 +294,6 @@ bool cmFileCopier::CheckKeyword(std::string const& arg)
298294
this->Doing = DoingNone;
299295
this->MatchlessFiles = false;
300296
}
301-
} else if (arg == "EXCLUDE_EMPTY_DIRECTORIES") {
302-
if (this->CurrentMatchRule) {
303-
this->NotAfterMatch(arg);
304-
} else {
305-
this->Doing = DoingNone;
306-
this->ExcludeEmptyDirectories = true;
307-
}
308297
} else {
309298
return false;
310299
}
@@ -658,29 +647,6 @@ bool cmFileCopier::InstallFile(std::string const& fromFile,
658647
return this->SetPermissions(toFile, permissions);
659648
}
660649

661-
static bool IsEmptyDirectory(std::string const& path,
662-
std::unordered_map<std::string, bool>& cache)
663-
{
664-
auto i = cache.find(path);
665-
if (i == cache.end()) {
666-
bool isEmpty = (!cmSystemTools::FileIsSymlink(path) &&
667-
cmSystemTools::FileIsDirectory(path));
668-
if (isEmpty) {
669-
cmsys::Directory d;
670-
d.Load(path);
671-
unsigned long numFiles = d.GetNumberOfFiles();
672-
for (unsigned long fi = 0; isEmpty && fi < numFiles; ++fi) {
673-
std::string const& name = d.GetFileName(fi);
674-
if (name != "."_s && name != ".."_s) {
675-
isEmpty = IsEmptyDirectory(d.GetFilePath(fi), cache);
676-
}
677-
}
678-
}
679-
i = cache.emplace(path, isEmpty).first;
680-
}
681-
return i->second;
682-
}
683-
684650
bool cmFileCopier::InstallDirectory(std::string const& source,
685651
std::string const& destination,
686652
MatchProperties match_properties)
@@ -753,11 +719,6 @@ bool cmFileCopier::InstallDirectory(std::string const& source,
753719
strcmp(dir.GetFile(fileNum), "..") == 0)) {
754720
std::string fromPath = cmStrCat(source, '/', dir.GetFile(fileNum));
755721
std::string toPath = cmStrCat(destination, '/', dir.GetFile(fileNum));
756-
if (this->ExcludeEmptyDirectories &&
757-
IsEmptyDirectory(fromPath, this->DirEmptyCache)) {
758-
continue;
759-
}
760-
761722
if (!this->Install(fromPath, toPath)) {
762723
return false;
763724
}

Source/cmFileCopier.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
#include "cmConfigure.h" // IWYU pragma: keep
66

77
#include <string>
8-
#include <unordered_map>
98
#include <vector>
109

1110
#include "cmsys/RegularExpression.hxx"
@@ -31,7 +30,6 @@ struct cmFileCopier
3130
char const* Name;
3231
bool Always = false;
3332
cmFileTimeCache FileTimes;
34-
std::unordered_map<std::string, bool> DirEmptyCache;
3533

3634
// Whether to install a file not matching any expression.
3735
bool MatchlessFiles = true;
@@ -91,7 +89,6 @@ struct cmFileCopier
9189
bool UseGivenPermissionsFile = false;
9290
bool UseGivenPermissionsDir = false;
9391
bool UseSourcePermissions = true;
94-
bool ExcludeEmptyDirectories = false;
9592
bool FollowSymlinkChain = false;
9693
std::string Destination;
9794
std::string FilesFromDir;

Source/cmInstallCommand.cxx

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1787,14 +1787,6 @@ bool HandleDirectoryMode(std::vector<std::string> const& args,
17871787
}
17881788
exclude_from_all = true;
17891789
doing = DoingNone;
1790-
} else if (args[i] == "EXCLUDE_EMPTY_DIRECTORIES") {
1791-
if (in_match_mode) {
1792-
status.SetError(cmStrCat(args[0], " does not allow \"", args[i],
1793-
"\" after PATTERN or REGEX."));
1794-
return false;
1795-
}
1796-
literal_args += " EXCLUDE_EMPTY_DIRECTORIES";
1797-
doing = DoingNone;
17981790
} else if (doing == DoingDirs) {
17991791
// Convert this directory to a full path.
18001792
std::string dir = args[i];

Tests/RunCMake/install/DIRECTORY-EXCLUDE_EMPTY_DIRECTORIES-check.cmake

Lines changed: 0 additions & 30 deletions
This file was deleted.

Tests/RunCMake/install/DIRECTORY-EXCLUDE_EMPTY_DIRECTORIES.cmake

Lines changed: 0 additions & 27 deletions
This file was deleted.

Tests/RunCMake/install/DIRECTORY-PATTERN-EXCLUDE_EMPTY_DIRECTORIES-result.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

Tests/RunCMake/install/DIRECTORY-PATTERN-EXCLUDE_EMPTY_DIRECTORIES-stderr.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

Tests/RunCMake/install/DIRECTORY-PATTERN-EXCLUDE_EMPTY_DIRECTORIES.cmake

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)