]> git.ipfire.org Git - thirdparty/snort3.git/commitdiff
tweaks to Cmakefiles (for building)
authorJosh <jrosenba@cisco.com>
Wed, 20 Aug 2014 19:34:08 +0000 (15:34 -0400)
committerJosh <jrosenba@cisco.com>
Wed, 20 Aug 2014 20:17:18 +0000 (16:17 -0400)
1  2 
CMakeLists.txt
cmake/macros.cmake
cmake/platforms.cmake
config.cmake.h.in
doc/config_changes.txt
extra/CMakeLists.txt
extra/src/CMakeLists.txt
src/codecs/root/root_chdlc.cc
src/ips_options/CMakeLists.txt

diff --cc CMakeLists.txt
index de4c1dc244e5e177bc5568cf46ba2dd49af0b49d,ffe55775ffdb5f01e89c7b5031c57af52b1864db..bb9291beffa01b413150a432dc726e838daba4ee
@@@ -52,10 -52,3 +52,10 @@@ configure_file
  add_custom_target(uninstall
      COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
  
- endif (BUILD_UNIT_TESTS)
 +
 +# Test Plugins!!
 +if (BUILD_EXTRA_PLUGINS)
 +    if (${CMAKE_GENERATOR} MATCHES "Make")
 +        add_subdirectory(extra)
 +    endif()
++endif (BUILD_EXTRA_PLUGINS)
index 9309b11fef3abfd4702e1fbb90b65fd8742d605a,fde5509824836fca7be8b44ee82c83bd373468aa..10f501a62730bf109fd1d392165efd570dcfa412
@@@ -53,10 -53,10 +53,9 @@@ macro (add_shared_library libname insta
          set_target_properties ( ${libname} 
              PROPERTIES
              COMPILE_FLAGS "-DBUILDING_SO"
 -            LINK_FLAGS "-export-dynamic -shared"
 +#            LINK_FLAGS "-export-dynamic -shared"
-             LINK_FLAGS "-shared"
          )
  
 -        #install into given library
          install (TARGETS ${libname}
              LIBRARY DESTINATION "lib/${CMAKE_PROJECT_NAME}/${install_path}"
          )
index afc197e5cbf06757ce9b45a9170e085bd8e2ad61,a5fdf9d1802248aeaf7e47c80573d411b31f1058..51c877c64469b750193311540682bf175ec3e73f
@@@ -79,21 -74,3 +79,27 @@@ if(${CMAKE_SYSTEM_NAME} MATCHES "Darwin
          )
      endif()
  endif()
- set(CMAKE_REQUIRED_FLAGS "-Wl,-undefined -Wl,dynamic_lookup")
 +
 +# More MacOS X fun
-     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -undefined dynamic_lookup")
++set(CMAKE_REQUIRED_FLAGS "-Wl,-undefined,dynamic_lookup")
 +check_cxx_compiler_flag("" HAVE_DYNAMIC_LOOKUP)
 +if(HAVE_DYNAMIC_LOOKUP)
- set (CMAKE_REQUIRED_FLAGS "")
++    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,dynamic_lookup")
 +endif()
-     set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -export-dynamic")
++unset (CMAKE_REQUIRED_FLAGS)
 +
 +
 +set (CMAKE_REQUIRED_FLAGS "-Wl,-export-dynamic")
 +check_cxx_compiler_flag ("" HAVE_EXPORT_DYNAMIC)
 +if (HAVE_EXPORT_DYNAMIC)
++    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export-dynamic")
 +endif ()
++unset(CMAKE_REQUIRED_FLAGS)
 +
 +
++set (CMAKE_REQUIRED_FLAGS "-Wl,-shared")
++check_cxx_compiler_flag ("" HAVE_SHARED)
++if (HAVE_SHARED)
++    set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-shared")
++endif ()
 +unset(CMAKE_REQUIRED_FLAGS)
index 8e14bf8b28fb2b2e5f46a4e00c5ce0b0b70d9ff6,8e14bf8b28fb2b2e5f46a4e00c5ce0b0b70d9ff6..a99305ff31edabc81cba015dc8edb9b0e8b2d577
@@@ -31,6 -31,6 +31,9 @@@
  /* include internal loggers in binary */
  #cmakedefine STATIC_LOGGERS 1
  
++/* include internal ips actions in binary */
++#define STATIC_IPS_ACTIONS 1
++
  /* include internal ips options in binary */
  #cmakedefine STATIC_IPS_OPTIONS 1
  
index 1256ddf5ad75495b13698273fbad17a2655d1c06,1256ddf5ad75495b13698273fbad17a2655d1c06..0e4f5b0dec75d2d104c080ca63b8d30ea05644f4
@@@ -134,9 -134,9 +134,6 @@@ change:  policy bsd-right ==> policy = 
  change:  policy_mode  ==> mode
  change:  ports ==> bindings
  change:  ports ==> gtp_ports
--change:  ports both ==> both_ports
--change:  ports client ==> client_ports
--change:  ports server ==> server_ports
  change:  post_depth [-1:65495] ==> post_depth [-1:65535]
  change:  preprocessor normalize_icmp4 ==> icmp4 == <bool>
  change:  preprocessor normalize_icmp6 ==> icmp6 == <bool>
@@@ -161,6 -161,6 +158,12 @@@ change:  snortfile ==> file = tru
  change:  sort avg_ticks_per_nomatch ==> sort = avg_ticks_per_no_match
  change:  split-any-any ==> split_any_any
  change:  srcport ==> src_port
++change:  stream_tcp: ports ==> binder.when.ports; binder.when.role = any
++change:  stream_tcp: ports ==> binder.when.ports; binder.when.role = client
++change:  stream_tcp: ports ==> binder.when.ports; binder.when.role = server
++change:  stream_tcp: protocol ==> binder.when.proto; binder.when.role = any
++change:  stream_tcp: protocol ==> binder.when.proto; binder.when.role = client
++change:  stream_tcp: protocol ==> binder.when.proto; binder.when.role = server
  change:  suspend-expensive-rules ==> suspend_expensive_rules
  change:  suspend-timeout ==> suspend_timeout
  change:  tcp_cache_nominal_timeout ==> pruning_timeout
index ca713cc0e3d041a858564441f71d913f83f600cb,2e3fd484f1532fb612aec2091eff1b6007f9477a..1271063ec556226c9081c055c00be03d9934774e
@@@ -1,47 -1,40 +1,72 @@@
  
 -cmake_minimum_required(VERSION 2.8.8)
 -project(snort_extra CXX C)
 +if (BUILD_EXTRA_PLUGINS)
 +    add_subdirectory(src)
  
 +else (BUILD_EXTRA_PLUGINS)
  
 -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 -set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
 +    cmake_minimum_required(VERSION 2.8.8)
 +    project(snort_extra CXX C)
  
 -# Look for Snort using pkg-config and our own find-snort module
 -find_package(PkgConfig REQUIRED)
 -pkg_check_modules(SNORT_PKG_MODULE snort)
  
 +    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
 +    set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
  
 -if (SNORT_PKG_MODULE_FOUND)
 -    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SNORT_PKG_MODULE_CFLAGS}")
 -    find_package(SNORT QUIET)
 -else()
 -    find_package(SNORT REQUIRED)
 -endif()
 +    # Look for Snort using pkg-config and our own find-snort module
 +    find_package(PkgConfig REQUIRED)
 +    pkg_check_modules(SNORT_PKG_MODULE snort)
  
 -if ((NOT SNORT_FOUND) AND (NOT SNORT_PKG_MODULE_FOUND))
 -    message(FATAL_ERROR "Unable to find Snort includes!!")
 -endif()
  
 -string (REPLACE ";" " " CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}")
 -string (REPLACE "-DHAVE_CONFIG_H" " " CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}")
 -message(STATUS "${CMAKE_CXX_FLAGS}")
 +    if (SNORT_PKG_MODULE_FOUND)
 +        set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${SNORT_PKG_MODULE_CFLAGS}")
 +        find_package(SNORT QUIET)
 +    else()
 +        find_package(SNORT REQUIRED)
 +    endif()
  
 -add_subdirectory(src)
 +    if ((NOT SNORT_FOUND) AND (NOT SNORT_PKG_MODULE_FOUND))
 +        message(FATAL_ERROR "Unable to find Snort includes!!")
 +    endif()
  
 +    string (REPLACE ";" " " CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}")
 +    string (REPLACE "-DHAVE_CONFIG_H" " " CMAKE_CXX_FLAGS  "${CMAKE_CXX_FLAGS}")
 +    message(STATUS "${CMAKE_CXX_FLAGS}")
  
 -# adding make unisntall
 -configure_file(
 -    "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
 -    "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
 -    IMMEDIATE @ONLY)
 -add_custom_target(uninstall
 -    COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
++    # Some shared library flags for the two platforms which I am using
++    set(CMAKE_REQUIRED_FLAGS "-Wl,-undefined,dynamic_lookup")
++    check_cxx_compiler_flag("" HAVE_DYNAMIC_LOOKUP)
++    if(HAVE_DYNAMIC_LOOKUP)
++        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-undefined,dynamic_lookup")
++    endif()
++    unset (CMAKE_REQUIRED_FLAGS)
++
++    set (CMAKE_REQUIRED_FLAGS "-Wl,-export-dynamic")
++    check_cxx_compiler_flag ("" HAVE_EXPORT_DYNAMIC)
++    if (HAVE_EXPORT_DYNAMIC)
++        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-export-dynamic")
++    endif ()
++    unset(CMAKE_REQUIRED_FLAGS)
++
++
++    set (CMAKE_REQUIRED_FLAGS "-Wl,-shared")
++    check_cxx_compiler_flag ("" HAVE_SHARED)
++    if (HAVE_SHARED)
++        set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-shared")
++    endif ()
++    unset(CMAKE_REQUIRED_FLAGS)
++
 +    add_subdirectory(src)
 +
 +
 +
 +    # adding make unisntall
 +    configure_file(
 +        "${CMAKE_CURRENT_SOURCE_DIR}/cmake_uninstall.cmake.in"
 +        "${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake"
 +        IMMEDIATE @ONLY)
 +
 +    add_custom_target(uninstall
 +        COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake)
 +
 +endif (BUILD_EXTRA_PLUGINS)
index 270a01ab60c8d4d942572f6fccf2b5cb01a95313,3a3cba68c621dfd194fe695aba9dc5426b37ecf5..4ec4ff0e93468a44176bac07a8f61e0dab9d5649
  
 -include_directories(${SNORT_INCLUDE_DIR})
 +################################################
 +#  MACRO FOR ADDING EXAMPLE LIBRARIES
 +#
 +#  Look in subdirecties for examples. This macro
 +#  will take care of all the logic, especially adding
 +#  this to the test configuration
 +#
 +#  PARAMS:
 +#       library ==>  library name to be installed
 +#       install_path ==> install into folder lib/[snort/snort_ex]/install_path
 +#       SOURCES ==> all arguments after install path are library sources
 +#
 +################################################
  
 -set(EX_INSTALL_PATH "lib/snort_examples")
 +macro (add_example_library libname install_path)
 +    set (sources ${ARGN})
  
 -add_subdirectory(codecs)
 -add_subdirectory(inspectors)
 -add_subdirectory(ips_options)
 -add_subdirectory(loggers)
 -add_subdirectory(search_engines)
 -add_subdirectory(so_rules)
 +    # Did we get any sources?
 +    list(LENGTH sources num_extra_args)
 +    if (${num_extra_args} GREATER 0)
 +
 +        add_library (${libname} SHARED ${sources} )
 +        set_target_properties ( ${libname}
 +            PROPERTIES
 +            COMPILE_FLAGS "-DBUILDING_SO"
-             LINK_FLAGS "-export-dynamic -shared"
 +        )
 +
 +        # If we're testing plugins, set a variable for later use.
 +        if (BUILD_EXTRA_PLUGINS)
 +            set (TMP_PLUGINS "${BUILT_PLUGINS}")
 +            list (APPEND TMP_PLUGINS ${libname})
 +
 +            # Force implied, but making this explicit
 +            set (BUILT_PLUGINS "${TMP_PLUGINS}" CACHE INTERNAL "example plugin libraries" FORCE)
 +        endif (BUILD_EXTRA_PLUGINS)
 +
 +
 +        install (TARGETS ${libname}
 +            LIBRARY DESTINATION "${EX_INSTALL_PATH}/${install_path}"
 +        )
 +
 +    else (${num_extra_args} GREATER 0)
 +
 +        message (STATUS "add_static_library requires at least one source file!")
 +        message (FATAL "usage: add_static_library lib_name source_1 source_2 source_3 ...")
 +
 +    endif (${num_extra_args} GREATER 0)
 +endmacro (add_example_library)
 +
 +
 +
 +################################################
 +#### SETTING CORRECT VARIABLES FOR BULIDING ####
 +################################################
 +
 +if (BUILD_EXTRA_PLUGINS)
 +    set (TEST_INSTALL_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/test_install")
 +    set (EX_INSTALL_PATH "lib/snort")
 +    include_directories ("${TEST_INSTALL_DIRECTORY}/include/snort")
++    include_directories (${DAQ_INCLUDE_DIR})
 +
 +    # reset this variable in case Cmake is reconfigured. i.e.,
 +    # we will keep appending the same libraries multiple times otherwise
 +    unset (BUILT_PLUGINS CACHE)
 +
 +
 +else (BUILD_EXTRA_PLUGINS)
 +    include_directories (${SNORT_INCLUDE_DIR})
 +    set (EX_INSTALL_PATH "lib/snort_examples")
 +
 +endif (BUILD_EXTRA_PLUGINS)
 +
 +
 +################################################
 +#######  FINALLY, ADDING SUBDIRECTORIES  #######
 +################################################
 +
 +
 +add_subdirectory (codecs)
 +add_subdirectory (inspectors)
 +add_subdirectory (ips_options)
 +add_subdirectory (loggers)
 +add_subdirectory (search_engines)
 +add_subdirectory (so_rules)
 +
 +
 +##############################################################################
 +# When Testing plugins, I want to build snort, install it, and then include
 +# the installed directory.  This makes sure we install all correct files.
 +# The result is below.
 +##############################################################################
 +
 +if (BUILD_EXTRA_PLUGINS)
 +
 +    ################################################
 +    # This variable, DBUILD_EXTRA_PLUGINS, is toggled because
 +    # when Snort++ builds unit test, this directory will
 +    # get recursively called from 'make install'. Infinite loops
 +    # seem like a poor life choice.
 +    ################################################
 +
 +    ################################################
 +    #  Breaking this down by command
 +    #  1) Remove the previously installed directory (if it exists)
 +    #       While this may strictly not necessary, this is a
 +    #       safegaurd to ensure only current files are included.
 +    #  2) Clean this directory and all subdirectories. This command
 +    #       works in tandem with WORKING_DIRECTORY to ensure it
 +    #       only cleans extra plugins.  Also, we check in the top
 +    #       level cmake file to ensure that Makefiles have been
 +    #       generated. So, the command is definitely valid.
 +    #  3) Ensure we don't recursively build this directly. Also,
 +    #       make sure we install into a temporary directory
 +    #  4) build snort. Can technically be combined with 'make install'
 +    #       but lets keep them seperate for clarity.
 +    #  5) install snort into the temp install directory.
 +    #  6) reset cmake options
 +    #  7) Another make is required to ensure the all the configured files
 +    #       revert to their original form.  I chose u2spewfoo because
 +    #       it only has one source file
 +    #  8) possible cmake bug?  timestamp on installed binary not updating.
 +    #       Manually touch file to ensure we don't needlesly rebuild
 +    ################################################
 +
 +    set (TMP_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
 +
 +    # install Snort into temporary directory
 +    add_custom_command(
 +        OUTPUT "${TEST_INSTALL_DIRECTORY}/bin/snort"
 +        COMMAND ${CMAKE_COMMAND} -E remove_directory ${TEST_INSTALL_DIRECTORY}
 +        COMMAND make clean
 +        COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DCMAKE_INSTALL_PREFIX=${TEST_INSTALL_DIRECTORY} -DBUILD_EXTRA_PLUGINS=OFF
 +        COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target snort
 +        COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target install
 +        COMMAND ${CMAKE_COMMAND} ${CMAKE_BINARY_DIR} -DCMAKE_INSTALL_PREFIX=${TMP_INSTALL_PREFIX} -DBUILD_EXTRA_PLUGINS=ON
 +        COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target u2spewfoo
 +        COMMAND ${CMAKE_COMMAND} -E touch_nocreate ${TEST_INSTALL_DIRECTORY}/bin/snort
 +        DEPENDS snort
 +        COMMENT "Building extra plugins using installed Snort"
 +        WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
 +    )
 +    add_custom_target(install_snort DEPENDS "${TEST_INSTALL_DIRECTORY}/bin/snort")
 +
 +
 +    #  set in Macro above
 +    foreach (lib ${BUILT_PLUGINS})
 +        add_dependencies(${lib} install_snort)
 +    endforeach(lib)
 +endif (BUILD_EXTRA_PLUGINS)
Simple merge
index 4ef3652a8974a8a3972f3d126eb2ed89bab1ad46,2806466b9a7d3860a0e0adb2b5386c350c550f21..1ef5e35cb5b6ef2b55704c6ad90a978602b8b62d
@@@ -120,3 -118,3 +118,6 @@@ else (STATIC_IPS_OPTIONS
  
  endif (STATIC_IPS_OPTIONS)
  
++target_link_libraries(ips_options
++    helpers
++)