cm_cxx_filesystem: Improve detection of std::filesystem support on GCC

The check added by commit 40af103402 (cmCMakePath: do not use
std::filesystem::path with RH gcc-toolset-10, 2023-12-02, v3.28.0~5^2)
fails unnecessarily in some cases due to not inheriting
`std::string_view` publicly.

Inheritance into a class is private by default, and this std class has
public members that would be access restricted when used to create
public objects in the current scope.

On some versions of GCC, depending on standards options, this causes
either template instantiation errors, or "inaccessible base" or "not
declared" errors.

Fix by setting the inheritance to public.  This does not affect the
intention of the previous fix because the check still fails when using
gcc-toolset-10's standard library with clang.

Issue: #25458, #25453
This commit is contained in:
Michael Pratt
2024-08-13 06:03:15 -04:00
committed by Brad King
parent 8733dcd115
commit 2216843fd5

View File

@@ -47,7 +47,7 @@ int main()
#if defined(__GLIBCXX__)
// RH gcc-toolset-10 has a strange bug: it selects, in some circumstances,
// the wrong constructor which generate error in template instantiation.
class my_string_view : std::string_view
class my_string_view : public std::string_view
{
public:
my_string_view(const char* p)