summaryrefslogtreecommitdiffstats
path: root/Source/cmFileSet.cxx
diff options
context:
space:
mode:
authorBen Boeckel <ben.boeckel@kitware.com>2022-04-07 20:49:07 (GMT)
committerBen Boeckel <ben.boeckel@kitware.com>2022-04-11 17:41:40 (GMT)
commit05783b168d47c2062817d58cb0a905dd6893cf8b (patch)
tree671b0bad415aa64850bc97051f2ced469af3ed3d /Source/cmFileSet.cxx
parent4515d82088c5dcd8e08e117532c500992262b84b (diff)
downloadCMake-05783b168d47c2062817d58cb0a905dd6893cf8b.zip
CMake-05783b168d47c2062817d58cb0a905dd6893cf8b.tar.gz
CMake-05783b168d47c2062817d58cb0a905dd6893cf8b.tar.bz2
cmFileSet: store visibility with the fileset
The visibility is intrinsic to the fileset, so store it with it. This avoids recalculating it on every addition to the fileset.
Diffstat (limited to 'Source/cmFileSet.cxx')
-rw-r--r--Source/cmFileSet.cxx62
1 files changed, 61 insertions, 1 deletions
diff --git a/Source/cmFileSet.cxx b/Source/cmFileSet.cxx
index 2c06dc6..1d1d29e 100644
--- a/Source/cmFileSet.cxx
+++ b/Source/cmFileSet.cxx
@@ -7,19 +7,79 @@
#include <utility>
#include <vector>
+#include <cmext/string_view>
+
#include "cmsys/RegularExpression.hxx"
#include "cmGeneratorExpression.h"
#include "cmListFileCache.h"
#include "cmLocalGenerator.h"
+#include "cmMakefile.h"
#include "cmMessageType.h"
#include "cmStringAlgorithms.h"
#include "cmSystemTools.h"
#include "cmake.h"
-cmFileSet::cmFileSet(std::string name, std::string type)
+cm::static_string_view cmFileSetVisibilityToName(cmFileSetVisibility vis)
+{
+ switch (vis) {
+ case cmFileSetVisibility::Interface:
+ return "INTERFACE"_s;
+ case cmFileSetVisibility::Public:
+ return "PUBLIC"_s;
+ case cmFileSetVisibility::Private:
+ return "PRIVATE"_s;
+ }
+ return ""_s;
+}
+
+cmFileSetVisibility cmFileSetVisibilityFromName(cm::string_view name,
+ cmMakefile* mf)
+{
+ if (name == "INTERFACE"_s) {
+ return cmFileSetVisibility::Interface;
+ }
+ if (name == "PUBLIC"_s) {
+ return cmFileSetVisibility::Public;
+ }
+ if (name == "PRIVATE"_s) {
+ return cmFileSetVisibility::Private;
+ }
+ mf->IssueMessage(
+ MessageType::FATAL_ERROR,
+ cmStrCat("File set visibility \"", name, "\" is not valid."));
+ return cmFileSetVisibility::Private;
+}
+
+bool cmFileSetVisibilityIsForSelf(cmFileSetVisibility vis)
+{
+ switch (vis) {
+ case cmFileSetVisibility::Interface:
+ return false;
+ case cmFileSetVisibility::Public:
+ case cmFileSetVisibility::Private:
+ return true;
+ }
+ return false;
+}
+
+bool cmFileSetVisibilityIsForInterface(cmFileSetVisibility vis)
+{
+ switch (vis) {
+ case cmFileSetVisibility::Interface:
+ case cmFileSetVisibility::Public:
+ return true;
+ case cmFileSetVisibility::Private:
+ return false;
+ }
+ return false;
+}
+
+cmFileSet::cmFileSet(std::string name, std::string type,
+ cmFileSetVisibility visibility)
: Name(std::move(name))
, Type(std::move(type))
+ , Visibility(visibility)
{
}