1 message(STATUS "Running rpcapd/CMakeLists.txt") 2 if(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) 15 endif(UNIX) 16 17 # 18 # On UN*X, we need pthreads and crypt(). 19 # 20 if(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 set(RPCAPD_SOURCES 52 daemon.c 53 fileconf.c 54 log.c 55 rpcapd.c 56 ${pcap_SOURCE_DIR}/rpcap-protocol.c 57 ${pcap_SOURCE_DIR}/sockutils.c 58 ${pcap_SOURCE_DIR}/fmtutils.c 59 ) 60 if(OPENSSL_FOUND) 61 set(RPCAPD_SOURCES ${RPCAPD_SOURCES} 62 ${pcap_SOURCE_DIR}/sslutils.c) 63 endif(OPENSSL_FOUND) 64 if(WIN32) 65 set(RPCAPD_SOURCES ${RPCAPD_SOURCES} 66 win32-svc.c 67 ${pcap_SOURCE_DIR}/charconv.c 68 ${pcap_SOURCE_DIR}/missing/getopt.c 69 rpcapd.rc 70 ) 71 include_directories(${pcap_SOURCE_DIR}/rpcapd ${pcap_SOURCE_DIR}/missing) 72 endif(WIN32) 73 74 add_executable(rpcapd ${RPCAPD_SOURCES}) 75 76 if(NOT C_ADDITIONAL_FLAGS STREQUAL "") 77 set_target_properties(rpcapd PROPERTIES COMPILE_FLAGS ${C_ADDITIONAL_FLAGS}) 78 endif() 79 80 if(NOT "${SANITIZER_FLAGS}" STREQUAL "") 81 set_target_properties(rpcapd PROPERTIES 82 LINK_FLAGS "${SANITIZER_FLAGS}") 83 endif() 84 85 # 86 # By default, build rpcapd universal with the appropriate set of 87 # architectures for the OS on which we're doing the build. 88 # 89 if(APPLE AND "${CMAKE_OSX_ARCHITECTURES}" STREQUAL "") 90 set_target_properties(rpcapd PROPERTIES 91 OSX_ARCHITECTURES "${OSX_EXECUTABLE_ARCHITECTURES}") 92 endif() 93 94 if(WIN32) 95 target_link_libraries(rpcapd ${LIBRARY_NAME} 96 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 97 else(WIN32) 98 target_link_libraries(rpcapd ${LIBRARY_NAME}_static 99 ${RPCAPD_LINK_LIBRARIES} ${PCAP_LINK_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT}) 100 endif(WIN32) 101 102 ###################################### 103 # Install rpcap daemon and man pages 104 ###################################### 105 106 # 107 # "Define GNU standard installation directories", which actually 108 # are also defined, to some degree, by autotools, and at least 109 # some of which are general UN*X conventions. 110 # 111 include(GNUInstallDirs) 112 113 set(MANADMIN_EXPAND rpcapd.manadmin.in) 114 115 set(MANFILE_EXPAND rpcapd-config.manfile.in) 116 117 if(WIN32) 118 # 119 # XXX - where should the install target put rpcapd on Windows? 120 # 121 # Note that if an installer package is being produced 122 # from the results of the build, the installer package 123 # will determine where it goes. 124 # 125 if(CMAKE_SIZEOF_VOID_P EQUAL 8) 126 install(TARGETS rpcapd DESTINATION bin/amd64) 127 else(CMAKE_SIZEOF_VOID_P EQUAL 8) 128 install(TARGETS rpcapd DESTINATION bin) 129 endif(CMAKE_SIZEOF_VOID_P EQUAL 8) 130 else(WIN32) 131 # 132 # On UN*X, we put it in the sbin directory. 133 # 134 # XXX - the Linux Filesystem Hierarchy Standard says /usr/sbin 135 # is for daemons, but some other systems use /usr/libexec instead. 136 # However, since some users might, instead of having rpcapd be 137 # launched by inetd/xinetd/launchd/systemd, just run it on a 138 # machine when remote capture is to be done, a case can be made 139 # for the sbin directory even on systems with /usr/libexec. 140 # 141 install(TARGETS rpcapd DESTINATION ${CMAKE_INSTALL_SBINDIR}) 142 endif(WIN32) 143 144 # On UN*X, and on Windows when not using MSVC, generate process man 145 # pages and arrange that they be installed. 146 if(NOT MSVC) 147 # 148 # Man pages. 149 # 150 # For each section of the manual for which we have man pages 151 # that require macro expansion, do the expansion. 152 # 153 set(MANADMIN "") 154 foreach(TEMPLATE_MANPAGE ${MANADMIN_EXPAND}) 155 string(REPLACE ".manadmin.in" ".${MAN_ADMIN_COMMANDS}" MANPAGE ${TEMPLATE_MANPAGE}) 156 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 157 set(MANADMIN ${MANADMIN} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 158 endforeach(TEMPLATE_MANPAGE) 159 install(FILES ${MANADMIN} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_ADMIN_COMMANDS}) 160 161 set(MANFILE "") 162 foreach(TEMPLATE_MANPAGE ${MANFILE_EXPAND}) 163 string(REPLACE ".manfile.in" ".${MAN_FILE_FORMATS}" MANPAGE ${TEMPLATE_MANPAGE}) 164 configure_file(${CMAKE_CURRENT_SOURCE_DIR}/${TEMPLATE_MANPAGE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE} @ONLY) 165 set(MANFILE ${MANFILE} ${CMAKE_CURRENT_BINARY_DIR}/${MANPAGE}) 166 endforeach(TEMPLATE_MANPAGE) 167 install(FILES ${MANFILE} DESTINATION ${CMAKE_INSTALL_MANDIR}/man${MAN_FILE_FORMATS}) 168 endif(NOT MSVC) 169 endif(WIN32 OR ((CMAKE_USE_PTHREADS_INIT OR PTHREADS_FOUND) AND HAVE_CRYPT)) 170