From e8a5a41045ea1af89a2111701df3c03093b59373 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Mayer?= Date: Tue, 24 Oct 2006 17:39:32 +0000 Subject: Parts of http://bugs.wireshark.org/bugzilla/show_bug.cgi?id=1179 Frederic Heem: * More cmake system checks. It compiles dumpcap without running configure, svn path=/trunk/; revision=19672 --- CMakeLists.txt | 259 +++++++++++++++++++++++++++++++++++++++++---------------- 1 file changed, 186 insertions(+), 73 deletions(-) (limited to 'CMakeLists.txt') diff --git a/CMakeLists.txt b/CMakeLists.txt index a3d5e6d85f..beba685be4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -25,91 +25,204 @@ project(wireshark C) set(dumpcap_LIBS wiretap) +# Under linux the release mode (CMAKE_BUILD_TYPE=release) defines NDEBUG + # Disable this later. Alternative: "make VERBOSE=1" set(CMAKE_VERBOSE_MAKEFILE ON) set(BUILD_SHARED_LIBS ON) set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/modules) -set(dumpcap_PLATFORM_SRC - capture-pcap-util-unix.c -) - -set(dumpcap_FILES - capture_opts.c - capture_loop.c - capture-pcap-util.c - capture_stop_conditions.c - clopts_common.c - conditions.c - dumpcap.c - pcapio.c - ringbuffer.c - sync_pipe_write.c - tempfile.c - version_info.c - - ${dumpcap_PLATFORM_SRC} -) - -include_directories(${CMAKE_BINARY_DIR} - ${CMAKE_SOURCE_DIR} - ${CMAKE_SOURCE_DIR}/wiretap) +include_directories(${CMAKE_BINARY_DIR} ${CMAKE_SOURCE_DIR} ${CMAKE_SOURCE_DIR}/include ${CMAKE_SOURCE_DIR}/wiretap) add_definitions(-DHAVE_CONFIG_H -D_U_=\"__attribute__\(\(unused\)\)\") -link_directories(wiretap) - -add_executable(dumpcap ${dumpcap_FILES}) - -option(BUILD_WITH_GLIB2 "Build using gtk2/glib2 instead of gtk/glib" ON) -option(BUILD_WIRESHARK "Build the GUI version of Wireshark" ON) -option(ENABLE_STATIC "Build a static version of Wireshark" OFF) - -if (BUILD_WITH_GLIB2) - if (BUILD_WIRESHARK) - find_package(GTK2 REQUIRED) - if (GTK2_FOUND) - message(GTK2_FOUND) - include_directories(${GTK2_INCLUDE_DIR}) - # set(dumpcap_LIBS ${dumpcap_LIBS} ${GTK2_LIBRARIES}) - endif (GTK2_FOUND) - endif (BUILD_WIRESHARK) - find_package(GLIB2 REQUIRED) - if (GLIB2_FOUND) - message(GLIB2_FOUND) - include_directories(${GLIB2_INCLUDE_DIR}) - set(dumpcap_LIBS ${dumpcap_LIBS} ${GLIB2_glib_LIBRARY}) - endif (GLIB2_FOUND) -else (BUILD_WITH_GLIB2) - if (BUILD_WIRESHARK) - find_package(GTK REQUIRED) - if (GTK_FOUND) - message(GTK_FOUND) - include_directories(${GTK_INCLUDE_DIR}) - # set(dumpcap_LIBS ${dumpcap_LIBS} ${GTK_LIBRARIES}) - endif (GTK_FOUND) - endif (BUILD_WIRESHARK) - find_package(GLIB REQUIRED) - if (GLIB_FOUND) - message(GLIB_FOUND) - include_directories(${GLIB_INCLUDE_DIR}) - set(dumpcap_LIBS ${dumpcap_LIBS} ${GLIB_glib_LIBRARIES}) - endif (GLIB_FOUND) -endif (BUILD_WITH_GLIB2) - -set(PACKAGELIST ZLIB PCAP) - +#Where to put libraries +if(NOT LIBRARY_OUTPUT_PATH) + set(LIBRARY_OUTPUT_PATH ${wireshark_BINARY_DIR}/lib CACHE INTERNAL + "Single output directory for building all libraries.") +endif(NOT LIBRARY_OUTPUT_PATH) + +option(BUILD_WIRESHARK "Build the GUI version of Wireshark" ON) +option(BUILD_TSHARK "Build tshark" ON) +option(BUILD_DUMPCAP "Build dumpcap" ON) +option(ENABLE_STATIC "Build a static version of Wireshark" OFF) +option(ENABLE_ADNS "Build with adns support" ON) +option(ENABLE_DBUS "Build with D-Bus support" OFF) +option(ENABLE_DBUS_TEST "Build with D-Bus unitest support" OFF) + +if(BUILD_WIRESHARK OR BUILD_TSHARK) + subdirs(wiretap) +endif(BUILD_WIRESHARK OR BUILD_TSHARK) + +#The minimum package list +set(PACKAGELIST GLIB2 ZLIB PCAP ${PACKAGELIST}) + +#build the gui ? +if(BUILD_WIRESHARK) + set(PACKAGELIST GTK2 ${PACKAGELIST}) +endif(BUILD_WIRESHARK) + +#Gnu asynchronous dns +if(ENABLE_ADNS) + set(PACKAGELIST ADNS ${PACKAGELIST}) + set(HAVE_GNU_ADNS 1) +endif(ENABLE_ADNS) + +#D-Bus +if(ENABLE_DBUS) + set(PACKAGELIST DBUS DBUSGLIB ${PACKAGELIST}) + subdirs(dbus) + set(dumpcap_LIBS ${dumpcap_LIBS} capdbus) +endif(ENABLE_DBUS) + +#Let's loop the package list foreach(PACKAGE ${PACKAGELIST}) - find_package(${PACKAGE}) - message(${PACKAGE}_FOUND) - if (${PACKAGE}_FOUND) - include_directories(${${PACKAGE}_INCLUDE_DIR}) - set(dumpcap_LIBS ${dumpcap_LIBS} ${${PACKAGE}_LIBRARIES}) - endif (${PACKAGE}_FOUND) + find_package(${PACKAGE} REQUIRED) + message(${PACKAGE}_FOUND) + if (${PACKAGE}_FOUND) + set(HAVE_LIB${PACKAGE} "1") + include_directories(${${PACKAGE}_INCLUDE_DIRS}) + message(STATUS "${PACKAGE} include ${${PACKAGE}_INCLUDE_DIRS}") + set(dumpcap_LIBS ${dumpcap_LIBS} ${${PACKAGE}_LIBRARIES}) + message(STATUS "${PACKAGE} lib ${${PACKAGE}_LIBRARIES}") + endif (${PACKAGE}_FOUND) endforeach(PACKAGE) +#packaging +set(CPACK_PACKAGE_NAME wireshark) +set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "capture packet") +set(CPACK_PACKAGE_VENDOR "wireshark") +set(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README") +#set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/Copyright.txt") +set(CPACK_PACKAGE_VERSION_MAJOR "0") +set(CPACK_PACKAGE_VERSION_MINOR "94") +set(CPACK_PACKAGE_VERSION_PATCH "0") +set(CPACK_PACKAGE_VERSION "${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}") + +set(CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION}") +set(CPACK_PACKAGE_INSTALL_DIRECTORY "/usr") +set(CPACK_GENERATOR "TGZ") +set(CPACK_SOURCE_GENERATOR "TGZ") + +#check system for includes +include(CheckIncludeFile) +check_include_file("arpa/inet.h" HAVE_ARPA_INET_H) +check_include_file("arpa/nameser.h" HAVE_ARPA_NAMESER_H) +check_include_file("direct.h" HAVE_DIRECT_H) +check_include_file("dirent.h" HAVE_DIRENT_H) +check_include_file("dlfcn.h" HAVE_DLFCN_H) +check_include_file("fcntl.h" HAVE_FCNTL_H) +check_include_file("getopt.h" NEED_GETOPT_H) +check_include_file("g_ascii_strtoull.h" NEED_G_ASCII_STRTOULL_H) +check_include_file("inet/aton.h" NEED_INET_ATON_H) +check_include_file("inttypes.h" HAVE_INTTYPES_H) +check_include_file("lauxlib.h" HAVE_LAUXLIB_H) +check_include_file("memory.h" HAVE_MEMORY_H) +check_include_file("netinet/in.h" HAVE_NETINET_IN_H) +check_include_file("netdb.h" HAVE_NETDB_H) +check_include_file("portaudio.h" HAVE_PORTAUDIO_H) +check_include_file("stdarg.h" HAVE_STDARG_H) +check_include_file("stddef.h" HAVE_STDDEF_H) +check_include_file("stdint.h" HAVE_STDINT_H) +check_include_file("stdlib.h" HAVE_STDLIB_H) +check_include_file("strerror.h" NEED_STRERROR_H) +check_include_file("strings.h" HAVE_STRINGS_H) +check_include_file("string.h" HAVE_STRING_H) +check_include_file("sys/ioctl.h" HAVE_SYS_IOCTL_H) +check_include_file("sys/param.h" HAVE_SYS_PARAM_H) +check_include_file("sys/socket.h" HAVE_SYS_SOCKET_H) +check_include_file("sys/sockio.h" HAVE_SYS_SOCKIO_H) +check_include_file("sys/stat.h" HAVE_SYS_STAT_H) +check_include_file("sys/time.h" HAVE_SYS_TIME_H) +check_include_file("sys/types.h" HAVE_SYS_TYPES_H) +check_include_file("sys/utsname.h" HAVE_SYS_UTSNAME_H) +check_include_file("sys/wait.h" HAVE_SYS_WAIT_H) +check_include_file("unistd.h" HAVE_UNISTD_H) + +#Functions +include(CheckFunctionExists) +check_function_exists("gethostbyname2" HAVE_GETHOSTBYNAME2) +check_function_exists("getprotobynumber" HAVE_GETPROTOBYNUMBER) +check_function_exists("iconv" HAVE_ICONV) +check_function_exists("inet_ntop" HAVE_INET_NTOP_PROTO) +check_function_exists("issetugid" HAVE_ISSETUGID) +check_function_exists("mmap" HAVE_MMAP) +check_function_exists("mprotect" HAVE_MPROTECT) +check_function_exists("sysconf" HAVE_SYSCONF) + +#Big or little endian ? +include(TestBigEndian) +test_big_endian(WORDS_BIGENDIAN) + +set(DATAFILE_DIR "${CMAKE_INSTALL_PREFIX}/share/${CPACK_PACKAGE_NAME}") + +#64 Bit format +include(Check64BitFormat) + +check_64bit_format(ll FORMAT_64BIT) +check_64bit_format(L FORMAT_64BIT) +check_64bit_format(q FORMAT_64BIT) +check_64bit_format(I64 FORMAT_64BIT) + +if(NOT FORMAT_64BIT) + message(FATAL " 64 bit formart missing") +endif(NOT FORMAT_64BIT) + +set(PRIX64 "${FORMAT_64BIT}X") +set(PRIx64 "${FORMAT_64BIT}x") +set(PRId64 "${FORMAT_64BIT}d") +set(PRIo64 "${FORMAT_64BIT}o") +set(PRIu64 "${FORMAT_64BIT}u") + +#Platform specific +if(UNIX) + set(WS_VAR_IMPORT "extern") +endif(UNIX) + +if(APPLE) +#TODO verify that APPLE implies HAVE_OS_X_FRAMEWORKS + set(HAVE_OS_X_FRAMEWORKS 1) +endif(APPLE) + +if(WIN32) + add_definitions(-DHAVE_WIN32_LIBWIRESHARK_LIB -D_NEED_VAR_IMPORT_) + set(WS_VAR_IMPORT "__declspec(dllimport) extern") +endif(WIN32) + + configure_file(${CMAKE_SOURCE_DIR}/cmakeconfig.h.in ${CMAKE_BINARY_DIR}/config.h) -target_link_libraries(dumpcap ${dumpcap_LIBS}) +link_directories(wiretap) + + +if(BUILD_DUMPCAP) + + set(DUMPCAP_PLATFORM_SRC + capture-pcap-util-unix.c + ) + + set(DUMPCAP_FILES + capture_opts.c + capture_loop.c + capture-pcap-util.c + capture_stop_conditions.c + clopts_common.c + conditions.c + dumpcap.c + pcapio.c + ringbuffer.c + sync_pipe_write.c + tempfile.c + version_info.c + ${DUMPCAP_PLATFORM_SRC} + ) + + add_executable(dumpcap ${DUMPCAP_FILES}) + target_link_libraries(dumpcap ${dumpcap_LIBS}) + install(TARGETS dumpcap RUNTIME DESTINATION bin) + +endif(BUILD_DUMPCAP) + + -- cgit v1.2.3