find_package(LuaJIT REQUIRED)
- if ((NOT SNORT_FOUND) AND (NOT SNORT_PKG_MODULE_FOUND))
- find_package(SNORT REQUIRED) # to print the helpful Snort message
- 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}")
+ # add Snort++ properties to the current build
+ string (REPLACE "-DHAVE_CONFIG_H" " " tmp_cmp_flags "${SNORT_INTERFACE_COMPILE_OPTIONS}")
+ string (STRIP "${CMAKE_CXX_FLAGS} ${tmp_cmp_flags}" tmp_cmp_flags)
+ set (CMAKE_CXX_FLAGS "${tmp_cmp_flags}" CACHE STRING
+ "Flags used by the compiler during all build types." FORCE)
+ include_directories(${SNORT_INTERFACE_INCLUDE_DIRECTORIES})
+ string (STRIP "${CMAKE_EXE_LINKER_FLAGS} ${SNORT_INTERFACE_LINK_FLAGS}" tmp_link_flags)
+ set (CMAKE_EXE_LINKER_FLAGS "${tmp_link_flags}" CACHE STRING
+ "Flags used by the linker. " FORCE)
include(CheckCXXCompilerFlag)
endif ()
unset(CMAKE_REQUIRED_FLAGS)
- add_subdirectory(src)
+ add_subdirectory(src)
# adding make unisntall
# SNORT_EXECUTABLE - The Snort++ executable
# SNORT_INCLUDE_DIR - Snort include directory
#
+#
+# SNORT_INTERFACE_COMPILE_OPTIONS - Snort++'s compile options. If snort.cmake found,
+# use those compile flags. Else, use
+# `pkg-config snort` compile flags
+# SNORT_INTERFACE_INCLUDE_DIRECTORIES - The directories that Snort++ includes
+# when building. retrieved from snort.cmake
+# SNORT_INTERFACE_LINK_FLAGS - Snort++ link flags. retrived from `pkg-config`
+#
set(ERROR_MESSAGE
"
set(SNORT_EXECUTABLE "${tmp_exe}" CACHE FILEPATH "Snort executable" FORCE)
endif()
- if (NOT SNORT_INCLUDE_DIR)
- get_target_property(tmp_exe snort INTERFACE_INCLUDE_DIRECTORIES)
- set(SNORT_INCLUDE_DIR "${tmp_exe}" CACHE FILEPATH "Snort executable" FORCE)
- endif()
+ get_target_property(tmp_cflags snort INTERFACE_COMPILE_OPTIONS)
+ set (SNORT_INTERFACE_COMPILE_OPTIONS "${tmp_cflags}" CACHE STRING
+ "The compile options with which Snort was linked" FORCE)
+
+ get_target_property(tmp_int_dir snort INTERFACE_INCLUDE_DIRECTORIES)
+ set(SNORT_INTERFACE_INCLUDE_DIRECTORIES "${tmp_int_dir}" CACHE FILEPATH
+ "The directories that Snort include's when building" FORCE)
+
+
endif(SNORT_IMPORT_FILE)
if (SNORT_PKG_FOUND)
- # add Snort link flags
- string(REPLACE ";" " " tmp_cflags "${SNORT_PKG_CFLAGS}")
- set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${tmp_cflags}" CACHE STRING
- "Flags used by the compiler during all build types." FORCE)
+ # CMake file takes precedence over pkg-config file
+ if (NOT SNORT_INTERFACE_COMPILE_OPTIONS)
+ string(REPLACE ";" " " tmp_cflags "${SNORT_PKG_CFLAGS}")
+ set (SNORT_INTERFACE_COMPILE_OPTIONS "${tmp_cflags}" CACHE STRING
+ "The compile options with which Snort was linked" FORCE)
+ endif()
+
# add Snort link flags
string(REPLACE ";" " " tmp_lflags "${SNORT_PKG_LDFLAGS}")
- set (CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${tmp_lflags}"
- CACHE STRING "Flags used by the linker." FORCE)
+ set (SNORT_INTERFACE_LINK_FLAGS "${tmp_lflags}"
+ CACHE STRING "The link flags with which the Snort++ binary was linked" FORCE)
+
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
set (CMAKE_INSTALL_PREFIX "${SNORT_PKG_PREFIX}" CACHE PATH
"Install path prefix, prepended onto install directories." FORCE)
endif (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
-
endif (SNORT_PKG_FOUND)
endif (PKG_CONFIG_FOUND)
find_path (SNORT_INCLUDE_DIR
NAMES main/snort_types.h
- HINTS ${SNORT_PKG_INCLUDE_DIRS} ENV SNORT_DIR
+ HINTS ${SNORT_INTERFACE_INCLUDE_DIRECTORIES} ENV SNORT_DIR
PATH_SUFFIXES snort include/snort
)
)
-
include(FindPackageHandleStandardArgs)
-find_package_handle_standard_args(SNORT
+find_package_handle_standard_args( Snort
REQUIRED_VARS SNORT_INCLUDE_DIR SNORT_EXECUTABLE
FAIL_MESSAGE "${ERROR_MESSAGE}"
)
SNORT_INCLUDE_DIR
SNORT_EXECUTABLE
SNORT_IMPORT_FILE
+ SNORT_INTERFACE_COMPILE_OPTIONS
+ SNORT_INTERFACE_INCLUDE_DIRECTORIES
+ SNORT_INTERFACE_LINK_FLAGS
)