Skip to content

Commit

Permalink
Fix check for CMake not detecting struct cmsg
Browse files Browse the repository at this point in the history
This check seems to have never worked and on Linux we hard coded
the check instead. Remove this hard coded assumption and use a
working check based on check_struct_has_member instead.

This is has the side-effect of port-sharing being enabled on macOS
when compiled with cmake.

Change-Id: Ia020c696f63a2a317f001c061b2ab4da69977750
Signed-off-by: Arne Schwabe <[email protected]>
Acked-by: Frank Lichtenheld <[email protected]>
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg29448.html
Signed-off-by: Gert Doering <[email protected]>
  • Loading branch information
schwabe authored and cron2 committed Sep 25, 2024
1 parent bae48c1 commit f77f298
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ if (${CMAKE_SYSTEM_NAME} STREQUAL "Linux")
set(ENABLE_FEATURE_TUN_PERSIST 1)
set(HAVE_LINUX_TYPES_H 1)
set(ENABLE_DCO YES)
set(HAVE_CMSGHDR YES)
elseif (${CMAKE_SYSTEM_NAME} STREQUAL "FreeBSD")
set(TARGET_FREEBSD YES)
set(ENABLE_DCO YES)
Expand Down Expand Up @@ -185,14 +184,18 @@ check_symbol_exists(mlockall sys/mman.h HAVE_MLOCKALL)

check_symbol_exists(sendmsg sys/socket.h HAVE_SENDMSG)
check_symbol_exists(recvmsg sys/socket.h HAVE_RECVMSG)
check_symbol_exists(cmsghdr sys/socket.h HAVE_CMSGHDR)
check_symbol_exists(openlog syslog.h HAVE_OPENLOG)
check_symbol_exists(syslog syslog.h HAVE_SYSLOG)
check_symbol_exists(getgrnam grp.h HAVE_GETGRNAM)
check_symbol_exists(getpwnam pwd.h HAVE_GETPWNAM)
check_symbol_exists(getsockname sys/socket.h HAVE_GETSOCKNAME)
check_symbol_exists(getrlimit "sys/time.h;sys/resource.h" HAVE_GETRLIMIT)

# Checking for existence of structs with check_symbol_exists does not work,
# so we use check_struct_hash_member with a member instead
check_struct_has_member("struct cmsghdr" cmsg_len sys/socket.h HAVE_CMSGHDR)


# Some OS (e.g. FreeBSD) need some basic headers to allow
# including network headers
set(NETEXTRA sys/types.h)
Expand Down

0 comments on commit f77f298

Please sign in to comment.