-
Notifications
You must be signed in to change notification settings - Fork 2
/
CMakeLists.txt
147 lines (122 loc) · 3.94 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# CMakeLists.txt for ELOG project
project(ELOG)
cmake_minimum_required(VERSION 3.0)
# compile options
option(USE_SSL "Use OpenSSL library for https" ON)
option(USE_KRB5 "Use Kerberos library for authentication" OFF)
option(USE_LDAP "Use LDAP library for authentication" OFF)
option(USE_PAM "Use PAM library for authentication" OFF)
option(BUILD_DAEMON "Build daemon" ON)
# install directory
set(ELOGDIR ${CMAKE_INSTALL_PREFIX}/elog)
set(RCDIR /etc/rc.d/init.d)
set(SRVDIR /usr/lib/systemd/system)
#----------------------------------
include_directories(${CMAKE_SOURCE_DIR}/mxml)
# default compiler flags
if (!MSVC)
add_compile_options(-W -Wall -Wno-deprecated-declarations)
endif()
if (MSVC)
add_compile_options(/D_CRT_SECURE_WARNINGS /wd4005 /wd4244 /wd4267 /wd4996 /nologo)
endif()
# find git
find_package(Git)
# disable warnings for regex.c
set_source_files_properties(${CMAKE_SOURCE_DIR}/src/regex.c PROPERTIES COMPILE_FLAGS -w)
# Package finders
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_LIST_DIR}/cmake)
include(GitVersion)
include_directories(${CMAKE_BINARY_DIR}/generated/)
# optional SSL library
if (USE_SSL)
add_definitions(-DHAVE_SSL)
find_package(OpenSSL REQUIRED)
include_directories(${OPENSSL_INCLUDE_DIR})
endif (USE_SSL)
# optional KRB5 library
if (USE_KRB5)
add_definitions(-DHAVE_KRB5)
find_package(KRB5 REQUIRED)
include_directories(${KERBROS5_INCLUDE_DIR})
endif (USE_KRB5)
# optional LDAP library
if (USE_LDAP)
add_definitions(-DHAVE_LDAP)
find_package(LDAP REQUIRED)
include_directories(${LDAP_INCLUDE_DIR})
endif (USE_LDAP)
# optional PAM library
if (USE_PAM)
add_compile_definitions(HAVE_PAM)
find_package(PAM REQUIRED)
include_directories(${PAM_INCLUDE_DIR})
endif (USE_PAM)
add_executable(elog
${CMAKE_SOURCE_DIR}/src/elog.c
${CMAKE_SOURCE_DIR}/src/crypt.c
${CMAKE_SOURCE_DIR}/mxml/strlcpy.c
)
if(USE_SSL)
target_link_libraries(elog ${OPENSSL_LIBRARIES})
endif(USE_SSL)
if (WIN32)
target_link_libraries(elog wsock32 ws2_32)
endif()
if(BUILD_DAEMON)
add_executable(elogd
${CMAKE_SOURCE_DIR}/src/elogd.c
${CMAKE_SOURCE_DIR}/src/auth.c
${CMAKE_SOURCE_DIR}/mxml/mxml.c
${CMAKE_SOURCE_DIR}/mxml/strlcpy.c
${CMAKE_SOURCE_DIR}/src/crypt.c
${CMAKE_SOURCE_DIR}/src/regex.c
)
if(USE_SSL)
target_link_libraries(elogd ${OPENSSL_LIBRARIES})
endif(USE_SSL)
if(USE_KRB5)
target_link_libraries(elogd ${KRB5_LIBRARIES})
endif(USE_KRB5)
if(USE_LDAP)
target_link_libraries(elogd ${LDAP_LIBRARIES})
endif(USE_LDAP)
if(USE_PAM)
target_link_libraries(elogd ${PAM_LIBRARIES})
endif(USE_PAM)
if (WIN32)
target_link_libraries(elogd wsock32 ws2_32)
endif()
endif()
install(TARGETS elog
DESTINATION bin)
install(FILES ${CMAKE_SOURCE_DIR}/man/elog.1
DESTINATION man/man1)
if(BUILD_DAEMON)
install(TARGETS elogd
DESTINATION sbin)
install(FILES ${CMAKE_SOURCE_DIR}/man/elogd.8
DESTINATION man/man8)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/scripts
${CMAKE_SOURCE_DIR}/resources
${CMAKE_SOURCE_DIR}/themes
MESSAGE_NEVER
DESTINATION ${ELOGDIR})
install(FILES ${CMAKE_SOURCE_DIR}/ssl/server.crt
${CMAKE_SOURCE_DIR}/ssl/server.key
DESTINATION ${ELOGDIR}/ssl/)
install(DIRECTORY ${CMAKE_SOURCE_DIR}/logbooks/demo
MESSAGE_NEVER
DESTINATION ${ELOGDIR}/logbooks)
# only install elogd.cfg if not existing
set(COPY_ELOGD_CFG "cp -n ${CMAKE_SOURCE_DIR}/elogd.cfg.example ${ELOGDIR}/elogd.cfg")
install(CODE "execute_process(COMMAND ${COPY_ELOGD_CFG})")
if (${CMAKE_SYSTEM_NAME} MATCHES Darwin)
install(FILES ${CMAKE_SOURCE_DIR}/elogd.plist
DESTINATION /Library/LaunchDaemons/ch.psi.elogd.plist)
install(CODE "message(\"\nThe elogd servie can be started with:\")")
install(CODE "message(\"$ sudo launchctl load /Library/LaunchDaemons/ch.psi.elogd.plist\n\")")
endif()
#install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -E cmake_echo_color --cyan
# \"$ sudo launchctl load /Library/LaunchDaemons/ch.psi.elogd.plist\")")
endif()