1message(STATUS "Running rpcapd/CMakeLists.txt") 2if(UNIX) 3 check_function_exists(crypt HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 4 if(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 5 set(HAVE_CRYPT TRUE) 6 else(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 7 check_library_exists(crypt crypt "" HAVE_CRYPT_IN_LIBCRYPT) 8 if(HAVE_CRYPT_IN_LIBCRYPT) 9 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} crypt) 10 set(HAVE_CRYPT TRUE) 11 else(HAVE_CRYPT_IN_LIBCRYPT) 12 message(WARNING "crypt() not found. Won't be able to build rpcapd.") 13 endif(HAVE_CRYPT_IN_LIBCRYPT) 14 endif(HAVE_CRYPT_IN_SYSTEM_LIBRARIES) 15endif(UNIX) 16 17# 18# On UN*X, we need pthreads and crypt(). 19# 20if(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT)) 21 if(UNIX) 22 # 23 # Do we have getspnam()? 24 # 25 check_function_exists(getspnam HAVE_GETSPNAM) 26 27 # 28 # Find library needed for getaddrinfo. 29 # NOTE: if you hand check_library_exists as its last argument a variable 30 # that's been set, it skips the test, so we need different variables. 31 # 32 include(CheckLibraryExists) 33 check_function_exists(getaddrinfo STDLIBS_HAVE_GETADDRINFO) 34 if(NOT STDLIBS_HAVE_GETADDRINFO) 35 check_library_exists(xnet getaddrinfo "" LIBXNET_HAS_GETADDRINFO) 36 if(LIBXNET_HAS_GETADDRINFO) 37 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} xnet) 38 else(LIBXNET_HAS_GETADDRINFO) 39 include(CMakePushCheckState) 40 cmake_push_check_state() 41 set(CMAKE_REQUIRED_LIBRARIES nsl) 42 check_library_exists(socket getaddrinfo "" LIBSOCKET_HAS_GETADDRINFO) 43 cmake_pop_check_state() 44 if(LIBSOCKET_HAS_GETADDRINFO) 45 set(RPCAPD_LINK_LIBRARIES ${RPCAPD_LINK_LIBRARIES} socket nsl) 46 endif(LIBSOCKET_HAS_GETADDRINFO) 47 endif(LIBXNET_HAS_GETADDRINFO) 48 endif(NOT STDLIBS_HAVE_GETADDRINFO) 49 endif(UNIX) 50 51 if(WIN32) 52 set(RPCAPD_EXTRA_SOURCES 53 win32-svc.c 54 ${pcap_SOURCE_DIR}/charconv.c 55 ${pcap_SOURCE_DIR}/missing/getopt.c 56 rpcapd.rc) 57 include_directories(${pcap_SOURCE_DIR}/rpcapd ${pcap_SOURCE_DIR}/missing) 58 endif(WIN32) 59 60 add_executable(rpcapd 61 daemon.c 62 fileconf.c 63 log.c 64 rpcapd.c 65 ${pcap_SOURCE_DIR}/rpcap-protocol.c 66 ${pcap_SOURCE_DIR}/sockutils.c 67 ${pcap_SOURCE_DIR}/sslutils.c 68 ${pcap_SOURCE_DIR}/fmtutils.c 69 ${RPCAPD_EXTRA_SOURCES} 70 ) 71 72 if(NOT C_ADDITIONAL_FLAGS STREQUAL "") 73 set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 74 endif() 75 76 if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 77 set_target_properties(rpcapd PROPERTIES 78 LINK_FLAGS "${SANITIZER_FLAGS}") 79 endif() 80 81 # 82 # By default, build rpcapd universal with the appropriate set of 83 # architectures for the OS on which we're doing the build. 84 # 85 if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") 86 set_target_properties(rpcapd PROPERTIES 87 OSX_ARCHITECTURES "${OSX_EXECUTABLE_ARCHITECTURES}") 88 endif() 89 90 if(WIN32) 91 target_link_libraries(rpcapd ${LIBRARY_NAME} 92 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 93 else(WIN32) 94 target_link_libraries(rpcapd ${LIBRARY_NAME}_static 95 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 96 endif(WIN32) 97 98 ###################################### 99 # Install rpcap daemon and man pages 100 ###################################### 101 102 # 103 # "Define GNU standard installation directories", which actually 104 # are also defined, to some degree, by autotools, and at least 105 # some of which are general UN*X conventions. 106 # 107 include(GNUInstallDirs) 108 109 set(MANADMIN_EXPAND rpcapd.manadmin.in) 110 111 set(MANFILE_EXPAND rpcapd-config.manfile.in) 112 113 if(WIN32) 114 # 115 # XXX - where should the install target put rpcapd on Windows? 116 # 117 # Note that if an installer package is being produced 118 # from the results of the build, the installer package 119 # will determine where it goes. 120 # 121 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 122 install(TARGETS rpcapd DESTINATION bin/amd64) 123 else(CMAKE_SIZEOF_VOID_P EQUAL 8) 124 install(TARGETS rpcapd DESTINATION bin) 125 endif(CMAKE_SIZEOF_VOID_P EQUAL 8) 126 else(WIN32) 127 # 128 # On UN*X, we put it in the sbin directory. 129 # 130 # XXX - the Linux Filesystem Hierarchy Standard says /usr/sbin 131 # is for daemons, but some other systems use /usr/libexec instead. 132 # However, since some users might, instead of having rpcapd be 133 # launched by inetd/xinetd/launchd/systemd, just run it on a 134 # machine when remote capture is to be done, a case can be made 135 # for the sbin directory even on systems with /usr/libexec. 136 # 137 install(TARGETS rpcapd DESTINATION ${CMAKE_INSTALL_SBINDIR}) 138 endif(WIN32) 139 140 # On UN*X, and on Windows when not using MSVC, generate process man 141 # pages and arrange that they be installed. 142 if(NOT MSVC) 143 # 144 # Man pages. 145 # 146 # For each section of the manual for which we have man pages 147 # that require macro expansion, do the expansion. 148 # 149 set(MANADMIN "") 150 foreach(TEMPLATE_MANPAGE ${MANADMIN_EXPAND}) 151 string(REPLACE ".manadmin.in" ".${MAN_ADMIN_COMMANDS}" MANPAGE ${TEMPLATE_MANPAGE}) 152 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 153 set(MANADMIN ${MANADMIN} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 154 endforeach(TEMPLATE_MANPAGE) 155 install(FILES ${MANADMIN} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_ADMIN_COMMANDS}) 156 157 set(MANFILE "") 158 foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) 159 string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) 160 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 161 set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 162 endforeach(TEMPLATE_MANPAGE) 163 install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) 164 endif(NOT MSVC) 165endif(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT)) 166