mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-09 17:18:18 +00:00
To manage the generation step, introduce cmGeneratorFileSet and cmGeneratorFileSets classes. These reorganizations of the code are done in preparation of the implementation of SOURCES file set type as well as user's file set types. Issues: #27550, #27383
103 lines
2.1 KiB
C++
103 lines
2.1 KiB
C++
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
|
file LICENSE.rst or https://cmake.org/licensing for details. */
|
|
#include "cmFileSetMetadata.h"
|
|
|
|
#include <string>
|
|
|
|
#include <cmext/algorithm>
|
|
#include <cmext/string_view>
|
|
|
|
#include "cmsys/RegularExpression.hxx"
|
|
|
|
#include "cmMakefile.h"
|
|
#include "cmMessageType.h"
|
|
#include "cmStringAlgorithms.h"
|
|
#include "cmSystemTools.h"
|
|
|
|
namespace cm {
|
|
namespace FileSetMetadata {
|
|
cm::string_view VisibilityToName(Visibility vis)
|
|
{
|
|
switch (vis) {
|
|
case Visibility::Interface:
|
|
return "INTERFACE"_s;
|
|
case Visibility::Public:
|
|
return "PUBLIC"_s;
|
|
case Visibility::Private:
|
|
return "PRIVATE"_s;
|
|
}
|
|
return ""_s;
|
|
}
|
|
|
|
Visibility VisibilityFromName(cm::string_view name, cmMakefile* mf)
|
|
{
|
|
if (name == "INTERFACE"_s) {
|
|
return Visibility::Interface;
|
|
}
|
|
if (name == "PUBLIC"_s) {
|
|
return Visibility::Public;
|
|
}
|
|
if (name == "PRIVATE"_s) {
|
|
return Visibility::Private;
|
|
}
|
|
auto msg = cmStrCat("File set visibility \"", name, "\" is not valid.");
|
|
if (mf) {
|
|
mf->IssueMessage(MessageType::FATAL_ERROR, msg);
|
|
} else {
|
|
cmSystemTools::Error(msg);
|
|
}
|
|
return Visibility::Private;
|
|
}
|
|
|
|
bool VisibilityIsForSelf(Visibility vis)
|
|
{
|
|
switch (vis) {
|
|
case Visibility::Interface:
|
|
return false;
|
|
case Visibility::Public:
|
|
case Visibility::Private:
|
|
return true;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
bool VisibilityIsForInterface(Visibility vis)
|
|
{
|
|
switch (vis) {
|
|
case Visibility::Interface:
|
|
case Visibility::Public:
|
|
return true;
|
|
case Visibility::Private:
|
|
return false;
|
|
}
|
|
return false;
|
|
}
|
|
|
|
cm::string_view const HEADERS = "HEADERS"_s;
|
|
cm::string_view const CXX_MODULES = "CXX_MODULES"_s;
|
|
|
|
namespace {
|
|
std::vector<cm::string_view> KnownTypes{ HEADERS, CXX_MODULES };
|
|
|
|
cmsys::RegularExpression const ValidNameRegex("^[a-z0-9][a-zA-Z0-9_]*$");
|
|
}
|
|
|
|
std::vector<cm::string_view> const& GetKnownTypes()
|
|
{
|
|
return KnownTypes;
|
|
}
|
|
|
|
bool IsKnownType(cm::string_view type)
|
|
{
|
|
return cm::contains(GetKnownTypes(), type);
|
|
}
|
|
|
|
bool IsValidName(cm::string_view name)
|
|
{
|
|
cmsys::RegularExpressionMatch match;
|
|
return ValidNameRegex.find(name.data(), match);
|
|
}
|
|
|
|
}
|
|
}
|