Detect statvfs in CMake builds too

This is a combination of 1b1155305601f2198383188a621255c6837fab9d from
master and minimal changes to make the code compile when both statvfs()
and statfs() are available.

This commit is best viewed with Git --color-moved
--color-moved-ws=ignore-all-space -w options.
This commit is contained in:
Thomas Klausner 2022-07-19 11:37:00 +02:00 committed by Vadim Zeitlin
parent 88b43d3306
commit 1fc52bd453
2 changed files with 31 additions and 19 deletions

View File

@ -290,27 +290,23 @@ if(UNIX)
wx_check_funcs(mkstemp mktemp)
# get the library function to use for wxGetDiskSpace(): it is statfs() under
# Linux and *BSD and statvfs() under Solaris
# Linux and *BSD and statvfs() under Solaris and NetBSD
wx_check_c_source_compiles("
return 0; }
#if defined(__BSD__)
#include <sys/param.h>
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#endif
#include <sys/statvfs.h>
int foo() {
long l;
struct statfs fs;
statfs(\"/\", &fs);
struct statvfs fs;
statvfs(\"/\", &fs);
l = fs.f_bsize;
l += fs.f_blocks;
l += fs.f_bavail;"
HAVE_STATFS)
if(HAVE_STATFS)
set(WX_STATFS_T "struct statfs")
wx_check_cxx_source_compiles("
HAVE_STATVFS)
if(HAVE_STATVFS)
set(WX_STATFS_T "struct statvfs")
else()
wx_check_c_source_compiles("
return 0; }
#if defined(__BSD__)
#include <sys/param.h>
@ -320,13 +316,28 @@ if(UNIX)
#endif
int foo() {
long l;
struct statfs fs;
statfs(\"/\", &fs);"
HAVE_STATFS_DECL)
else()
# TODO: implement statvfs checks
if(HAVE_STATVFS)
set(WX_STATFS_T statvfs_t)
statfs(\"/\", &fs);
l = fs.f_bsize;
l += fs.f_blocks;
l += fs.f_bavail;"
HAVE_STATFS)
if(HAVE_STATFS)
set(WX_STATFS_T "struct statfs")
wx_check_cxx_source_compiles("
return 0; }
#if defined(__BSD__)
#include <sys/param.h>
#include <sys/mount.h>
#else
#include <sys/vfs.h>
#endif
int foo() {
struct statfs fs;
statfs(\"/\", &fs);"
HAVE_STATFS_DECL)
endif()
endif()

View File

@ -243,6 +243,7 @@ wxGTK:
- Fix build with --disable-intl (#22626).
- Fix build under MSW (Tim Stahlhut, #22633).
- Fix statvfs() detection in CMake build under NetBSD (Thomas Klausner, #22643).
wxOSX: