Branch: master

3f5a4b41 2014-10-05 10:05:47 François Andriot
Fix detection of some headers on openbsd
Many headers requires additional include stdlib.h
M CMakeLists.txt
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 5433fe1..52ee5c1 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -181,6 +181,12 @@
 check_include_file( "ndir.h" HAVE_NDIR_H )
 check_include_file( "netinet/in.h" HAVE_NETINET_IN_H )
 check_include_file( "net/if.h" HAVE_NET_IF_H )
+if( NOT HAVE_NET_IF_H )
+  find_path( NET_IF_PATH "net/if.h" )
+  if( NET_IF_PATH )
+    set( HAVE_NET_IF_H "1" )
+  endif( )
+endif( )
 check_include_file( "paths.h" HAVE_PATHS_H )
 check_include_file( "pty.h" HAVE_PTY_H )
 check_include_file( "stdint.h" HAVE_STDINT_H )
@@ -197,6 +203,12 @@
 check_include_file( "sys/mntent.h" HAVE_SYS_MNTENT_H )
 check_include_file( "sys/mnttab.h" HAVE_SYS_MNTTAB_H )
 check_include_file( "sys/mount.h" HAVE_SYS_MOUNT_H )
+if( NOT HAVE_SYS_MOUNT_H )
+  find_path( SYS_MOUNT_PATH "sys/mount.h" )
+  if( SYS_MOUNT_PATH )
+    set( HAVE_SYS_MOUNT_H "1" )
+  endif( )
+endif( )
 check_include_file( "sys/ndir.h" HAVE_SYS_NDIR_H )
 check_include_file( "sys/param.h" HAVE_SYS_PARAM_H )
 check_include_file( "sys/prctl.h" HAVE_SYS_PRCTL_H )
@@ -206,6 +218,12 @@
 check_include_file( "sys/stropts.h" HAVE_SYS_STROPTS_H )
 check_include_file( "sys/types.h" HAVE_SYS_TYPES_H )
 check_include_file( "sys/ucred.h" HAVE_SYS_UCRED_H )
+if( NOT HAVE_SYS_UCRED_H )
+  find_path( SYS_UCRED_PATH "sys/ucred.h" )
+  if( SYS_UCRED_PATH )
+    set( HAVE_SYS_UCRED_H "1" )
+  endif( )
+endif( )
 check_include_file( "sys/xattr.h" HAVE_SYS_XATTR_H )
 check_include_file( "termios.h" HAVE_TERMIOS_H )
 check_include_file( "termio.h" HAVE_TERMIO_H )
@@ -263,7 +281,7 @@
 check_symbol_exists( mkstemps "stdlib.h" HAVE_MKSTEMPS_PROTO )
 
 check_function_exists( initgroups HAVE_INITGROUPS )
-check_symbol_exists( initgroups "grp.h" HAVE_INITGROUPS_PROTO )
+check_symbol_exists( initgroups "grp.h;unistd.h" HAVE_INITGROUPS_PROTO )
 
 check_function_exists( strlcat HAVE_STRLCAT )
 check_symbol_exists( strlcat "string.h" HAVE_STRLCAT_PROTO )
@@ -305,6 +323,9 @@
 else (HAVE_ALLOCA_H )
   check_symbol_exists( alloca "stdlib.h" HAVE_ALLOCA )
 endif (HAVE_ALLOCA_H )
+if( ${CMAKE_SYSTEM_NAME} STREQUAL "OpenBSD" )
+  set( HAVE_ALLOCA 1 )
+endif( )
 
 check_function_exists( getmntinfo HAVE_GETMNTINFO )
 check_function_exists( getnameinfo HAVE_GETNAMEINFO )