-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
93 lines (75 loc) · 3.71 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
CMAKE_MINIMUM_REQUIRED(VERSION 3.0)
PROJECT("http-background" VERSION 1.1.0)
# RPM/DEB and CENTOS7/CENTOS8/ROCKY9/UBU2004/UBU2204/UBU2404
IF (EXISTS "${CMAKE_CURRENT_BINARY_DIR}/OSRELEASE.txt")
FILE(STRINGS ${CMAKE_CURRENT_BINARY_DIR}/OSRELEASE.txt OSRELEASE)
ELSEIF (EXISTS "/OSRELEASE.txt")
FILE(STRINGS /OSRELEASE.txt OSRELEASE)
ELSE()
MESSAGE(FATAL_ERROR "Missing OSRELEASE")
ENDIF()
IF (OSRELEASE MATCHES "CENTOS7")
SET(CPACK_GENERATOR "RPM")
ELSEIF (OSRELEASE MATCHES "CENTOS8")
SET(CPACK_GENERATOR "RPM")
ELSEIF (OSRELEASE MATCHES "ROCKY9")
SET(CPACK_GENERATOR "RPM")
ELSEIF (OSRELEASE MATCHES "UBU2004")
SET(CPACK_GENERATOR "DEB")
ELSEIF (OSRELEASE MATCHES "UBU2204")
SET(CPACK_GENERATOR "DEB")
ELSEIF (OSRELEASE MATCHES "UBU2404")
SET(CPACK_GENERATOR "DEB")
ELSE()
MESSAGE(FATAL_ERROR "Invalid OSRELEASE")
ENDIF()
SET(CMAKE_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS_RELEASE "-std=c++17 -Wall -Wvla -Wshadow -Wconversion -Wno-sign-conversion -Wno-c++11-narrowing -O2 -fno-strict-aliasing -Wextra -Wno-unused-parameter")
ADD_LIBRARY(http-background SHARED
http-background.cpp
)
TARGET_LINK_LIBRARIES(http-background
curl
)
SET_TARGET_PROPERTIES(http-background PROPERTIES PREFIX "")
INCLUDE_DIRECTORIES(
/opt/halon/include
)
IF(EXISTS "/etc/os-release")
EXECUTE_PROCESS(COMMAND "sed" "-ne" "s/^ID=\"\\?\\([a-z]\\+\\)\"\\?$/\\1/p" "/etc/os-release" OUTPUT_VARIABLE OS_RELEASE_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND "sed" "-ne" "s/^VERSION_ID=\"\\?\\([0-9\\.]\\+\\)\"\\?$/\\1/p" "/etc/os-release" OUTPUT_VARIABLE OS_RELEASE_VERSION_ID OUTPUT_STRIP_TRAILING_WHITESPACE)
EXECUTE_PROCESS(COMMAND "uname" "-m" OUTPUT_VARIABLE OS_RELEASE_ARCH OUTPUT_STRIP_TRAILING_WHITESPACE)
SET(SYSTEM_NAME "${OS_RELEASE_ID}-${OS_RELEASE_VERSION_ID}-${OS_RELEASE_ARCH}")
ENDIF()
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/http-background.so DESTINATION plugins)
INSTALL(FILES http-background.schema.json DESTINATION share/plugins)
INSTALL(FILES http-background.functions.json DESTINATION share/plugins)
IF(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.14.0")
FILE(CREATE_LINK "/opt/halon/plugins/http-background.so" "${CMAKE_CURRENT_BINARY_DIR}/http-background.so.link" SYMBOLIC)
ELSE()
ADD_CUSTOM_TARGET(link_target ALL COMMAND ${CMAKE_COMMAND} -E create_symlink "/opt/halon/plugins/http-background.so" "${CMAKE_CURRENT_BINARY_DIR}/http-background.so.link")
ENDIF()
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/http-background.so.link" DESTINATION plugins/autoload/smtpd RENAME http-background.so)
INSTALL(FILES "${CMAKE_CURRENT_BINARY_DIR}/http-background.so.link" DESTINATION plugins/autoload/hsh RENAME http-background.so)
INSTALL(FILES "LICENSE" DESTINATION share/doc/plugins/http-background)
SET(CMAKE_INSTALL_PREFIX "/opt/halon")
SET(CPACK_PACKAGING_INSTALL_PREFIX "/opt/halon")
IF (CPACK_GENERATOR MATCHES "DEB")
SET(CPACK_DEBIAN_PACKAGE_SHLIBDEPS ON)
SET(CPACK_DEBIAN_PACKAGE_DEPENDS "halon (>= 6.1)")
SET(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CMAKE_CURRENT_SOURCE_DIR}/postinst;${CMAKE_CURRENT_SOURCE_DIR}/postrm")
ENDIF()
IF (CPACK_GENERATOR MATCHES "RPM")
SET(CPACK_RPM_PACKAGE_AUTOREQPROV ON)
SET(CPACK_RPM_PACKAGE_REQUIRES "halon >= 6.1")
SET(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postinst")
SET(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/postrm")
ENDIF()
SET(CPACK_PACKAGE_NAME "halon-extras-http-background")
SET(CPACK_PACKAGE_VERSION "${PROJECT_VERSION}")
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "Halon extras http-background")
SET(CPACK_PACKAGE_DESCRIPTION "Halon extras http-background")
SET(CPACK_PACKAGE_CONTACT "Halon support@halon.io")
SET(CPACK_PACKAGE_FILE_NAME "${CPACK_PACKAGE_NAME}-${PROJECT_VERSION}-${SYSTEM_NAME}")
SET(CPACK_DEBIAN_PACKAGE_SECTION "mail")
INCLUDE(CPack)