-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
172 lines (142 loc) · 4.83 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
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
# $NiH: CMakeLists.txt,v 1.7 2007/03/02 11:13:15 wiz Exp $
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
PROJECT(dccserver C)
INCLUDE(CheckFunctionExists)
INCLUDE(CheckIncludeFiles)
INCLUDE(CheckLibraryExists)
SET(PACKAGE_NAME "dccserver")
SET(PACKAGE_VERSION_MAJOR "0")
SET(PACKAGE_VERSION_MINOR "5")
SET(PACKAGE_VERSION_PATCH "0")
SET(PACKAGE_VERSION "${PACKAGE_VERSION_MAJOR}.${PACKAGE_VERSION_MINOR}${PACKAGE_VERSION_PATCH}")
SET(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
ADD_SUBDIRECTORY(lib)
INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_CURRENT_SOURCE_DIR}/lib
${CMAKE_CURRENT_BINARY_DIR})
# Targets
## dccserver
ADD_EXECUTABLE(dccserver dccserver.c child.c)
TARGET_LINK_LIBRARIES(dccserver dcc)
## dccsend
ADD_EXECUTABLE(dccsend dccsend.c)
TARGET_LINK_LIBRARIES(dccsend dcc)
# installation
SET(MAN_PATH man)
SET(PROGRAMS dccserver dccsend)
IF(CMAKE_SYSTEM_NAME MATCHES BSD)
SET(MANFMT mdoc)
ELSE(CMAKE_SYSTEM_NAME MATCHES BSD)
SET(MANFMT man)
ENDIF(CMAKE_SYSTEM_NAME MATCHES BSD)
FOREACH(MAN_PAGE ${PROGRAMS})
INSTALL(FILES ${MAN_PAGE}.${MANFMT} DESTINATION ${MAN_PATH}/man1
RENAME ${MAN_PAGE}.1)
ENDFOREACH(MAN_PAGE ${PROGRAMS})
INSTALL(PROGRAMS dccsend DESTINATION bin)
# XXX: actually, should only be setuid if for root, otherwise there is
# no point
INSTALL(PROGRAMS dccserver DESTINATION bin
PERMISSIONS OWNER_READ OWNER_EXECUTE
GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE SETUID)
# Checks
CHECK_INCLUDE_FILES(err.h HAVE_ERR_H)
CHECK_FUNCTION_EXISTS(getaddrinfo HAVE_GETADDRINFO)
IF(NOT HAVE_GETADDRINFO)
CHECK_LIBRARY_EXISTS(socket getaddrinfo "" HAVE_GETADDRINFO)
IF(HAVE_GETADDRINFO)
TARGET_LINK_LIBRARIES(dccsend socket)
TARGET_LINK_LIBRARIES(dccserver socket)
ELSE(HAVE_GETADDRINFO)
SET(EXTRA_LIB_FILES ${EXTRA_LIB_FILES} getaddrinfo.c)
ENDIF(HAVE_GETADDRINFO)
ENDIF(NOT HAVE_GETADDRINFO)
CHECK_FUNCTION_EXISTS(inet_ntoa HAVE_INET_NTOA)
IF(NOT HAVE_INET_NTOA)
CHECK_LIBRARY_EXISTS(nsl inet_ntoa "" HAVE_INET_NTOA)
IF(HAVE_INET_NTOA)
TARGET_LINK_LIBRARIES(dccserver nsl)
ELSE(HAVE_INET_NTOA)
MESSAGE(FATAL_ERROR "inet_ntoa() not found")
ENDIF(HAVE_INET_NTOA)
ENDIF(NOT HAVE_INET_NTOA)
# Manually check for socklen_t. Using CHECK_SYMBOL_EXISTS doesn't work
# on Irix or Linux, because the compilers don't like
# cmakeRequireSymbol(0,&socklen_t);
#CHECK_SYMBOL_EXISTS(socklen_t "sys/types.h;sys/socket.h" HAVE_SOCKLEN_T)
MESSAGE("-- Looking for socklen_t")
TRY_COMPILE(HAVE_SOCKLEN_T
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/socklen_t.c
OUTPUT_VARIABLE SLT)
IF(HAVE_SOCKLEN_T)
MESSAGE("-- Looking for socklen_t - found")
ELSE(HAVE_SOCKLEN_T)
MESSAGE("-- Looking for socklen_t - not found:\n${SLT}")
ENDIF(HAVE_SOCKLEN_T)
# custom targets
SET(MAN_PAGES dccserver dccsend)
FOREACH(MAN ${MAN_PAGES})
ADD_CUSTOM_TARGET(${MAN}.man
DEPENDS ${MAN}.mdoc
COMMAND mandoc -T man ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.mdoc | sed '/TH/s,"NetBSD [^"]*","NiH",' > ${MAN}.new
COMMAND diff -I NiH ${MAN}.new ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.man || mv ${MAN}.new ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.man
COMMAND rm -f ${MAN}.new
COMMENT Updating man page ${MAN}.man
)
ADD_CUSTOM_TARGET(${MAN}.html
DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.mdoc
COMMAND mandoc -Thtml -Oman="%N.html",style=../nih-man.css ${CMAKE_CURRENT_SOURCE_DIR}/${MAN}.man > ${MAN}.html
COMMENT Updating HTML page ${MAN}.html
)
ENDFOREACH(MAN)
ADD_CUSTOM_TARGET(update-man
DEPENDS dccserver.man dccsend.man)
ADD_CUSTOM_TARGET(update-html
DEPENDS dccserver.html dccsend.html)
# packaging
SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY "simulate mIRC's /dccserver command")
SET(CPACK_PACKAGE_VENDOR "Thomas Klausner <[email protected]>")
SET(CPACK_PACKAGE_DESCRIPTION_FILE "${CMAKE_CURRENT_SOURCE_DIR}/README")
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/COPYING")
SET(CPACK_PACKAGE_VERSION_MAJOR ${PACKAGE_VERSION_MAJOR})
SET(CPACK_PACKAGE_VERSION_MINOR ${PACKAGE_VERSION_MINOR})
SET(CPACK_PACKAGE_VERSION_PATCH ${PACKAGE_VERSION_PATCH})
SET(CPACK_PACKAGE_EXECUTABLES "dccserver" "dccsend")
SET(CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
SET(CPACK_GENERATOR "TGZ")
# XXX: adding "TBZ" gives:
# "CPack Error: Cannot initialize CPack generator:"
SET(CPACK_SOURCE_GENERATOR "TGZ")
SET(CPACK_SOURCE_IGNORE_FILES
".a$"
".cmake$"
".o$"
".so$"
"/.deps/"
"/CMakeFiles/"
"/CVS/"
"/autom4te.cache/"
"/docs/"
"AdditionalInfo.txt$"
"CMakeCache.txt$"
"Makefile$"
"\\\\.sh$"
"_CPack_"
"config.h$"
"config.log$"
"config.status$"
"dccsend$"
"dccserver$"
"html$"
"install_manifest.txt$"
"stamp-h1$"
"tar.bz2"
"tar.gz"
"~$"
)
SET(CPACK_SOURCE_STRIP_FILES "")
INCLUDE(CPack)
ADD_CUSTOM_TARGET(dist make package_source)
# write out config file
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/cmake-config.h.in
${CMAKE_CURRENT_BINARY_DIR}/config.h)