-
Notifications
You must be signed in to change notification settings - Fork 15
/
Copy pathCMakeLists.txt
87 lines (82 loc) · 2.15 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
cmake_minimum_required(VERSION 3.0)
# Allow setting PROJECT_VERSION through project():
cmake_policy(SET CMP0048 NEW)
# Don't bother writing the project name all the time:
set(PROJECT dhcpoptinj)
if(DEFINED CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose the type of build, Debug or Release")
else()
SET(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build, Debug or Release")
endif()
if (DEFINED CMAKE_INSTALL_PREFIX)
set(CMAKE_BUILD_TYPE ${CMAKE_BUILD_TYPE} CACHE STRING "Choose install prefix")
else()
set(CMAKE_INSTALL_PREFIX /usr CACHE STRING "Choose install prefix")
endif()
project(
${PROJECT}
VERSION 0.5.3
DESCRIPTION "DHCP option injector"
LANGUAGES C
)
add_definitions(-DDHCPOPTINJ_VERSION="${PROJECT_VERSION}")
set(SOURCES
src/config.c
src/dhcp.c
src/dhcpoptinj.c
src/ipv4.c
src/options.c
)
set(HEADERS
src/config.h
src/dhcp.h
src/ipv4.h
src/options.h
src/udp.h
)
add_executable(${PROJECT} ${SOURCES} ${HEADERS})
set_property(TARGET ${PROJECT} PROPERTY C_STANDARD 99)
target_compile_options(${PROJECT} PRIVATE
-Wall
-Wextra
-pedantic
-Wcast-align
-Wcast-qual
-Wdisabled-optimization
-Wformat=2
-Winit-self
-Wmissing-declarations
-Wmissing-include-dirs
-Wredundant-decls
-Wshadow
-Wsign-conversion
-Wstrict-overflow=5
-Wno-error=strict-overflow
-Wswitch-default
-Wundef
-Werror
-Wno-unused
-Wmissing-prototypes
-Wstrict-prototypes
-Wold-style-definition
-fstack-protector
-Wwrite-strings
-Wmissing-field-initializers
-D_POSIX_SOURCE
-D_DEFAULT_SOURCE
-D_FORTIFY_SOURCE=2
)
# Only add -Wlogical-op if using gcc; clang does not support this warning option:
if (CMAKE_C_COMPILER_ID STREQUAL "GNU")
target_compile_options(${PROJECT} PRIVATE "-Wlogical-op")
endif()
find_library(NFQ_LIB netfilter_queue REQUIRED)
target_link_libraries(${PROJECT} ${NFQ_LIB})
install(TARGETS ${PROJECT} DESTINATION sbin)
# Add uninstall target, since cmake does not:
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)