File: Sockets.cmake

package info (click to toggle)
swi-prolog 9.0.4%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 82,408 kB
  • sloc: ansic: 387,503; perl: 359,326; cpp: 6,613; lisp: 6,247; java: 5,540; sh: 3,147; javascript: 2,668; python: 1,900; ruby: 1,594; yacc: 845; makefile: 428; xml: 317; sed: 12; sql: 6
file content (56 lines) | stat: -rw-r--r-- 1,298 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
include(CheckTypeSize)

if(WIN32)
  set(SOCKET_LIBRARIES ws2_32.lib gdi32.lib)
  set(HAVE_SOCKET 1)
else()
  check_library_exists(socket    socket      "" HAVE_LIBSOCKET)
  check_library_exists(nsl       gethostent  "" HAVE_LIBNSL)

  if(HAVE_LIBSOCKET)
    set(SOCKET_LIBRARIES ${SOCKET_LIBRARIES} -lsocket)
  endif()
  if(HAVE_LIBNSL)
    set(SOCKET_LIBRARIES ${SOCKET_LIBRARIES} -lnsl)
  endif()

  if(HAVE_LIBSOCKET)
    set(HAVE_SOCKET 1)
  else()
    check_function_exists(socket HAVE_SOCKET)
  endif()
endif()

if(HAVE_SOCKET)
  AC_CHECK_HEADERS(sys/socket.h)
  AC_CHECK_HEADERS(sys/un.h)
  if(HAVE_SYS_SOCKET_H)
    set(CMAKE_EXTRA_INCLUDE_FILES ${CMAKE_EXTRA_INCLUDE_FILES} sys/socket.h)
  endif()

  check_type_size(socklen_t SIZEOF_SOCKLEN_T)
  if(NOT SIZEOF_SOCKLEN_T STREQUAL "")
    set(HAVE_SOCKLEN_T 1)
  endif()

  check_c_source_compiles(
      "#include <sys/types.h>
       #include <sys/socket.h>
       #include <netdb.h>
       #include <netinet/in.h>

       int main() { int x = h_errno; return 0;}"
      HAVE_H_ERRNO)

  check_c_source_compiles(
    "#include <sys/types.h>
     #include <sys/socket.h>
     #include <netdb.h>
     #include <netinet/in.h>

     int main(void)
     { struct ip_mreqn mreqn;
       return 0;
     }"
     HAVE_IP_MREQN)
endif(HAVE_SOCKET)