Browse Source

CMake/private-download: Fix statfs includes on FreeBSD

On FreeBSD, we have to include sys/params.h and sys/mount.h,
not sys/vfs.h.

Gbp-Dch: ignore
Julian Andres Klode 7 years ago
parent
commit
2c391d850f
2 changed files with 13 additions and 5 deletions
  1. 6 5
      CMakeLists.txt
  2. 7 0
      apt-private/private-download.cc

+ 6 - 5
CMakeLists.txt

@@ -89,14 +89,15 @@ if (LZ4_FOUND)
 endif()
 
 # Mount()ing and stat()ing and friends
+check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
+check_include_files(sys/params.h HAVE_PARAMS_H)
+check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
+if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
+  message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
+endif()
 
 check_function_exists(statvfs HAVE_STATVFS)
 if (NOT HAVE_STATVFS)
-  check_symbol_exists(statfs sys/vfs.h HAVE_VFS_H)
-  check_symbol_exists(statfs sys/mount.h HAVE_MOUNT_H)
-  if (NOT HAVE_VFS_H AND NOT HAVE_MOUNT_H)
-    message(FATAL_ERROR "Can find neither statvfs() nor statfs()")
-  endif()
   configure_file(CMake/statvfs.h.in ${PROJECT_BINARY_DIR}/include/statvfs.h COPYONLY)
 endif()
 

+ 7 - 0
apt-private/private-download.cc

@@ -25,7 +25,14 @@
 #include <sys/types.h>
 #include <pwd.h>
 #include <fcntl.h>
+#ifdef HAVE_VFS_H
 #include <sys/vfs.h>
+#else
+#ifdef HAVE_PARAMS_H
+#include <sys/params.h>
+#endif
+#include <sys/mount.h>
+#endif
 #include <sys/statvfs.h>
 #include <sys/stat.h>
 #include <errno.h>