File: AddNetworkBits.cmake

package info (click to toggle)
cdrkit 9%3A1.1.11-5
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,904 kB
  • sloc: ansic: 107,271; perl: 968; sh: 481; makefile: 142; sed: 4
file content (60 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (9)
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
57
58
59
60

# various checks add additional of extra libs, most likely for SunOS
# using own checks and not CHECK_SYMBOLE because of spurios problems seen with
# it

INCLUDE(CheckCSourceCompiles)

SET(TESTSRC "
#include <sys/types.h>
#include <sys/socket.h>

int main(int argc, char **argv) {
return socket(AF_INET, SOCK_STREAM, 0);
}
")

SET(CMAKE_REQUIRED_LIBRARIES )
CHECK_C_SOURCE_COMPILES("${TESTSRC}" USE_LIBC_SOCKET)

IF(NOT USE_LIBC_SOCKET)

   LIST(APPEND EXTRA_LIBS socket)

   SET(CMAKE_REQUIRED_LIBRARIES socket)
   CHECK_C_SOURCE_COMPILES("${TESTSRC}" USE_LIBSOCKET)
   IF(NOT USE_LIBSOCKET)
      MESSAGE(FATAL_ERROR "No working socket(...) found in libc or libsocket")
   ENDIF(NOT USE_LIBSOCKET)

ENDIF(NOT USE_LIBC_SOCKET)

SET(TESTSRC "
#include <sys/types.h>
#include <sys/socket.h>
#include <netdb.h>

int main(int argc, char **argv) {
struct hostent *h = gethostbyname(argv[0]);
return sizeof(h);
}
")

CHECK_C_SOURCE_COMPILES("${TESTSRC}" USE_LIBC_NLS)
IF(NOT USE_LIBC_NLS)
   SET(CMAKE_REQUIRED_LIBRARIES nls)
   CHECK_C_SOURCE_COMPILES("${TESTSRC}" USE_LIBNLS)
   IF(USE_LIBNLS)
      LIST(APPEND EXTRA_LIBS nls)
   ELSE(USE_LIBNLS)
      SET(CMAKE_REQUIRED_LIBRARIES xnet)
      CHECK_C_SOURCE_COMPILES("${TESTSRC}" USE_LIBXNET)
      IF(NOT USE_LIBXNET)
         MESSAGE(FATAL_ERROR "Error: Could not find a system library providing gethostbyname.")
      ELSE(NOT USE_LIBXNET)
         LIST(APPEND EXTRA_LIBS xnet)
      ENDIF(NOT USE_LIBXNET)
   ENDIF(USE_LIBNLS)
ENDIF(NOT USE_LIBC_NLS)
SET(CMAKE_REQUIRED_LIBRARIES )