1if(UNIX) 2 check_function_exists(crypt HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 3 if(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 4 set(HAVE_CRYPT TRUE) 5 else(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 6 check_library_exists(crypt crypt "" HAVE_CRYPT_IN_LIBCRYPT) 7 if(HAVE_CRYPT_IN_LIBCRYPT) 8 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} crypt) 9 set(HAVE_CRYPT TRUE) 10 else(HAVE_CRYPT_IN_LIBCRYPT) 11 message(WARNING "crypt() not found. Won't be able to build rpcapd.") 12 endif(HAVE_CRYPT_IN_LIBCRYPT) 13 endif(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 14endif(UNIX) 15 16# 17# On UN*X, we need pthreads and crypt(). 18# 19if(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT)) 20 if(UNIX) 21 # 22 # Do we have getspnam()? 23 # 24 check_function_exists(getspnam HAVE_GETSPNAM) 25 26 # 27 # Find library needed for getaddrinfo. 28 # NOTE: if you hand check_library_exists as its last argument a variable 29 # that's been set, it skips the test, so we need different variables. 30 # 31 include(CheckLibraryExists) 32 check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO) 33 if(NOT STDLIBS_HAVE_GETADDRINFO) 34 check_library_exists(xnet getaddrinfo "" LIBXNET_HAS_GETADDRINFO) 35 if(LIBXNET_HAS_GETADDRINFO) 36 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} xnet) 37 else(LIBXNET_HAS_GETADDRINFO) 38 include(CMakePushCheckState) 39 cmake_push_check_state() 40 set(CMAKE_REQUIRED_LIBRARIES nsl) 41 check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO) 42 cmake_pop_check_state() 43 if(LIBSOCKET_HAS_GETADDRINFO) 44 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} socket nsl) 45 endif(LIBSOCKET_HAS_GETADDRINFO) 46 endif(LIBXNET_HAS_GETADDRINFO) 47 endif(NOT STDLIBS_HAVE_GETADDRINFO) 48 endif(UNIX) 49 50 if(WIN32) 51 set(RPCAPD_EXTRA_SOURCES 52 win32-svc.c 53 ${pcap_SOURCE_DIR}/missing/getopt.c 54 ${pcap_SOURCE_DIR}/missing/win_snprintf.c 55 rpcapd.rc) 56 include_directories(${pcap_SOURCE_DIR}/rpcapd ${pcap_SOURCE_DIR}/missing) 57 endif(WIN32) 58 59 add_executable(rpcapd 60 daemon.c 61 fileconf.c 62 log-stderr.c 63 rpcapd.c 64 ${pcap_SOURCE_DIR}/rpcap-protocol.c 65 ${pcap_SOURCE_DIR}/sockutils.c 66 ${pcap_SOURCE_DIR}/fmtutils.c 67 ${RPCAPD_EXTRA_SOURCES} 68 ) 69 70 if(NOT C_ADDITIONAL_FLAGS STREQUAL "") 71 set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 72 endif() 73 74 if(WIN32) 75 target_link_libraries(rpcapd ${LIBRARY_NAME} 76 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 77 else(WIN32) 78 target_link_libraries(rpcapd ${LIBRARY_NAME}_static 79 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 80 endif(WIN32) 81 82 ###################################### 83 # Install rpcap daemon and man pages 84 ###################################### 85 86 # 87 # "Define GNU standard installation directories", which actually 88 # are also defined, to some degree, by autotools, and at least 89 # some of which are general UN*X conventions. 90 # 91 include(GNUInstallDirs) 92 93 set(MANADMIN_EXPAND rpcapd.manadmin.in) 94 95 if(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 96 install(TARGETS rpcapd DESTINATION bin/amd64) 97 else(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 98 install(TARGETS rpcapd DESTINATION bin) 99 endif(MSVC AND CMAKE_SIZEOF_VOID_P EQUAL 8) 100 101 # On UN*X, and on Windows when not using MSVC, generate process man 102 # pages and arrange that they be installed. 103 if(NOT MSVC) 104 # 105 # Man pages. 106 # 107 # For each section of the manual for which we have man pages 108 # that require macro expansion, do the expansion. 109 # 110 set(MANADMIN "") 111 foreach(TEMPLATE_MANPAGE ${MANADMIN_EXPAND}) 112 string(REPLACE ".manadmin.in" ".${MAN_ADMIN_COMMANDS}" MANPAGE ${TEMPLATE_MANPAGE}) 113 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 114 set(MANADMIN ${MANADMIN} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 115 endforeach(TEMPLATE_MANPAGE) 116 install(FILES ${MANADMIN} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_ADMIN_COMMANDS}) 117 endif(NOT MSVC) 118endif(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT)) 119