-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
96 lines (77 loc) · 2.23 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
cmake_minimum_required(VERSION 3.12)
project(fail2abuseipdb VERSION 0.2.0 LANGUAGES CXX DESCRIPTION "A simple utility for converting fail2ban jail info to abuseipdb csv format")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)
set(CMAKE_CXX_EXTENSIONS ON) # optional
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/include/version.hpp.in ${CMAKE_CURRENT_BINARY_DIR}/include/version.hpp)
# Set options for submodules
# I don't want to build Nils' tests
set(JSON_BuildTests OFF CACHE BOOL "Disable JSON test utils")
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/submodules/fmt)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/submodules/json)
# Set compiler options
add_compile_options(
-Wpedantic
-Werror
-Wall
)
include_directories(
include/
${CMAKE_CURRENT_BINARY_DIR}/include
)
if (DEFINED fail2abuseipdb_DEBUG)
message(STATUS "### ENABLED DEBUG ###")
add_compile_options(
-O0
-ggdb
)
else()
add_compile_options(
-O2
-s
)
endif()
file(GLOB_RECURSE FILES FOLLOW_SYMLINKS ${CMAKE_CURRENT_SOURCE_DIR} src/*.cpp)
include_directories(
include/
)
add_executable(
${PROJECT_NAME}
${FILES}
)
target_link_libraries(
${PROJECT_NAME}
fmt
nlohmann_json
)
###
# Docs target
###
add_custom_target("docs" COMMENT "Create Doxygen documentation")
add_custom_command(
TARGET "docs"
POST_BUILD
COMMENT "Generate Doxygen documentation for publication or reading"
COMMAND doxygen ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
)
###
# Install and Remove targets and their configs go here
###
set(fail2abuseipdb_INSTALL_DIR "/usr/local/bin")
install(
TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION ${fail2abuseipdb_INSTALL_DIR}
)
add_custom_target("uninstall" COMMENT "Uninstall fail2abuseipdb")
add_custom_command(
TARGET "uninstall"
POST_BUILD
COMMENT "Uninstall fail2abuseipdb from the current system"
COMMAND xargs rm -Rfv < install_manifest.txt || echo "Nothing to be removed from system!"
)
set(CPACK_PACKAGE_NAME ${PROJECT_NAME})
set(CPACK_PACKAGE_CONTACT "Simon Cahill <[email protected]>")
set(CPACK_PACKAGE_VENDOR "Simon Cahill")
set(CPACK_GENERATOR DEB)
include(CPack)