Blame view

Network/libpcap-1.9.0/rpcapd/CMakeLists.txt 4.09 KB
1f9d795a   Speedclocker   Sniffer et sender
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
  if(UNIX)
    check_function_exists(crypt HAVE_CRYPT_IN_SYSTEM_LIBRARIES)
    if(HAVE_CRYPT_IN_SYSTEM_LIBRARIES)
      set(HAVE_CRYPT TRUE)
    else(HAVE_CRYPT_IN_SYSTEM_LIBRARIES)
      check_library_exists(crypt crypt "" HAVE_CRYPT_IN_LIBCRYPT)
      if(HAVE_CRYPT_IN_LIBCRYPT)
        set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} crypt)
        set(HAVE_CRYPT TRUE)
      else(HAVE_CRYPT_IN_LIBCRYPT)
        message(WARNING "crypt() not found. Won't be able to build rpcapd.")
      endif(HAVE_CRYPT_IN_LIBCRYPT)
    endif(HAVE_CRYPT_IN_SYSTEM_LIBRARIES)
  endif(UNIX)
  
  #
  # On UN*X, we need pthreads and crypt().
  #
  if(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT))
    if(UNIX)
      #
      # Do we have getspnam()?
      #
      check_function_exists(getspnam HAVE_GETSPNAM)
  
      #
      # Find library needed for getaddrinfo.
      # NOTE: if you hand check_library_exists as its last argument a variable
      # that's been set, it skips the test, so we need different variables.
      #
      include(CheckLibraryExists)
      check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO)
      if(NOT STDLIBS_HAVE_GETADDRINFO)
        check_library_exists(xnet getaddrinfo "" LIBXNET_HAS_GETADDRINFO)
        if(LIBXNET_HAS_GETADDRINFO)
          set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} xnet)
        else(LIBXNET_HAS_GETADDRINFO)
          include(CMakePushCheckState)
          cmake_push_check_state()
          set(CMAKE_REQUIRED_LIBRARIES nsl)
          check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO)
          cmake_pop_check_state()
          if(LIBSOCKET_HAS_GETADDRINFO)
            set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} socket nsl)
          endif(LIBSOCKET_HAS_GETADDRINFO)
        endif(LIBXNET_HAS_GETADDRINFO)
      endif(NOT STDLIBS_HAVE_GETADDRINFO)
    endif(UNIX)
  
    if(WIN32)
      set(RPCAPD_EXTRA_SOURCES
          win32-svc.c
          ${pcap_SOURCE_DIR}/missing/getopt.c
          ${pcap_SOURCE_DIR}/missing/win_snprintf.c
          rpcapd.rc)
      include_directories(${pcap_SOURCE_DIR}/rpcapd ${pcap_SOURCE_DIR}/missing)
    endif(WIN32)
  
    add_executable(rpcapd
      daemon.c
      fileconf.c
      log-stderr.c
      rpcapd.c
      ${pcap_SOURCE_DIR}/rpcap-protocol.c
      ${pcap_SOURCE_DIR}/sockutils.c
      ${pcap_SOURCE_DIR}/fmtutils.c
      ${RPCAPD_EXTRA_SOURCES}
    )
  
    if(NOT C_ADDITIONAL_FLAGS STREQUAL "")
      set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS})
    endif()
  
    if(WIN32)
      target_link_libraries(rpcapd ${LIBRARY_NAME}
        ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
    else(WIN32)
      target_link_libraries(rpcapd ${LIBRARY_NAME}_static
        ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT})
    endif(WIN32)
  
    ######################################
    # Install rpcap daemon and man pages
    ######################################
  
    #
    # "Define GNU standard installation directories", which actually
    # are also defined, to some degree, by autotools, and at least
    # some of which are general UN*X conventions.
    #
    include(GNUInstallDirs)
  
    set(MANADMIN_EXPAND rpcapd.manadmin.in)
  
    if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
      install(TARGETS rpcapd DESTINATION bin/amd64)
    else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
      install(TARGETS rpcapd DESTINATION bin)
    endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8)
  
    # On UN*X, and on Windows when not using MSVC, generate process man
    # pages and arrange that they be installed.
    if(NOT MSVC)
      #
      # Man pages.
      #
      # For each section of the manual for which we have man pages
      # that require macro expansion, do the expansion.
      #
      set(MANADMIN "")
      foreach(TEMPLATE_MANPAGE ${MANADMIN_EXPAND})
          string(REPLACE ".manadmin.in" ".${MAN_ADMIN_COMMANDS}" MANPAGE ${TEMPLATE_MANPAGE})
          configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY)
          set(MANADMIN ${MANADMIN} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE})
      endforeach(TEMPLATE_MANPAGE)
      install(FILES ${MANADMIN} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_ADMIN_COMMANDS})
    endif(NOT MSVC)
  endif(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT))