-
Notifications
You must be signed in to change notification settings - Fork 17
/
CMakeLists.txt
116 lines (93 loc) · 4.19 KB
/
CMakeLists.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
cmake_minimum_required ( VERSION 3.4.3 )
project( extra CXX C )
set (EXTRA_VERSION_MAJOR 1)
set (EXTRA_VERSION_MINOR 0)
set (EXTRA_VERSION_PATCH 0)
set (EXTRA_VERSION "${EXTRA_VERSION_MAJOR}.${EXTRA_VERSION_MINOR}.${EXTRA_VERSION_PATCH}")
set (CMAKE_CXX_STANDARD 11)
set (CMAKE_CXX_STANDARD_REQUIRED ON)
set (CMAKE_CXX_EXTENSIONS OFF)
set (CMAKE_C_STANDARD 99)
set (CMAKE_C_STANDARD_REQUIRED ON)
set (CMAKE_C_EXTENSIONS ON)
set (CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake")
# Pull in definitions of various install directories
include (GNUInstallDirs)
include (${CMAKE_MODULE_PATH}/create_options.cmake)
include (${CMAKE_MODULE_PATH}/configure_options.cmake)
set (CPACK_GENERATOR TGZ)
set (CPACK_PACKAGE_NAME "snort_extra")
set (CPACK_PACKAGE_VENDOR "Cisco")
set (CPACK_PACKAGE_VERSION_MAJOR "${EXTRA_VERSION_MAJOR}")
set (CPACK_PACKAGE_VERSION_MINOR "${EXTRA_VERSION_MINOR}")
set (CPACK_PACKAGE_VERSION_PATCH "${EXTRA_VERSION_PATCH}")
set (CPACK_PACKAGE_ICON "${CMAKE_SOURCE_DIR}/doc/images/snort.png")
set (CPACK_PACKAGE_INSTALL_DIRECTORY "snort")
set (CPACK_RESOURCE_FILE_LICENSE "${CMAKE_SOURCE_DIR}/LICENSE")
set (CPACK_RESOURCE_FILE_README "${CMAKE_SOURCE_DIR}/README")
set (CPACK_SOURCE_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${CPACK_PACKAGE_VERSION_MAJOR}.${CPACK_PACKAGE_VERSION_MINOR}.${CPACK_PACKAGE_VERSION_PATCH}")
set (CPACK_SOURCE_IGNORE_FILES "${CMAKE_BINARY_DIR}/*")
set (CPACK_SOURCE_GENERATOR TGZ)
set (LIB_INSTALL_PATH "${CMAKE_INSTALL_LIBDIR}/snort")
set (PLUGIN_INSTALL_PATH "${LIB_INSTALL_PATH}/plugins/${CMAKE_PROJECT_NAME}")
include(CPack)
set ( C_FLAGS "" CACHE STRING "" )
set ( CXX_FLAGS "" CACHE STRING "" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${C_FLAGS}" CACHE STRING "" FORCE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX_FLAGS}" CACHE STRING "" FORCE )
execute_process (
COMMAND pkg-config --variable=cpp_opts snort
OUTPUT_VARIABLE CPP_OPTS
)
string ( REGEX REPLACE "[\r\n]" " " CPP_OPTS "${CPP_OPTS}" )
separate_arguments ( CPP_OPTS )
foreach ( OPT ${CPP_OPTS} )
execute_process (
COMMAND pkg-config --variable=${OPT}_CPPFLAGS snort
OUTPUT_VARIABLE CPPFLAGS
)
string ( REGEX REPLACE "[\r\n]" " " CPPFLAGS "${CPPFLAGS}" )
set ( ${OPT}_CPPFLAGS "${CPPFLAGS}" CACHE STRING "" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${OPT}_CPPFLAGS}" CACHE STRING "" FORCE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${OPT}_CPPFLAGS}" CACHE STRING "" FORCE )
endforeach ( OPT )
execute_process (
COMMAND pkg-config --variable=cpp_opts_other snort
OUTPUT_VARIABLE CPP_OPTS_OTHER
)
string ( REGEX REPLACE "[\r\n]" " " CPP_OPTS_OTHER "${CPP_OPTS_OTHER}" )
separate_arguments ( CPP_OPTS_OTHER )
foreach ( OPT ${CPP_OPTS_OTHER} )
execute_process (
COMMAND pkg-config --variable=${OPT}_CPPFLAGS snort
OUTPUT_VARIABLE CPPFLAGS
)
string ( REGEX REPLACE "[\r\n]" " " CPPFLAGS "${CPPFLAGS}" )
set ( ${OPT}_CPPFLAGS "${CPPFLAGS}" CACHE STRING "" )
set ( CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${${OPT}_CPPFLAGS}" CACHE STRING "" FORCE )
set ( CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${${OPT}_CPPFLAGS}" CACHE STRING "" FORCE )
endforeach ( OPT )
# Set these after all tests are done but *before* any subdirectories are included
# or other targets declared.
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${EXTRA_LINKER_FLAGS}")
foreach (EXTRA_LIBRARY IN LISTS EXTRA_LIBRARIES)
link_libraries(${EXTRA_LIBRARY})
endforeach (EXTRA_LIBRARY)
add_subdirectory ( src )
string(TOUPPER "${CMAKE_BUILD_TYPE}" CMAKE_BUILD_TYPE_UPPER)
message("
-------------------------------------------------------
${CMAKE_PROJECT_NAME} version ${EXTRA_VERSION}
Install options:
prefix: ${CMAKE_INSTALL_PREFIX}
Compiler options:
CC: ${CMAKE_C_COMPILER}
CXX: ${CMAKE_CXX_COMPILER}
CFLAGS: ${CMAKE_C_FLAGS} ${CMAKE_C_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}
CXXFLAGS: ${CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE_UPPER}}
EXE_LDFLAGS: ${CMAKE_EXE_LINKER_FLAGS}
MODULE_LDFLAGS: ${CMAKE_MODULE_LINKER_FLAGS}
")