This repository has been archived by the owner on Jul 4, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 38
/
CMakeLists.txt
133 lines (111 loc) · 5.13 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
cmake_minimum_required (VERSION 2.8)
set(CMAKE_LEGACY_CYGWIN_WIN32 0) # Remove when CMake >= 2.8.4 is required
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake")
include (CheckFunctionExists)
include (CheckStructHasMember)
set (HAVE_CMAKE true)
project (taskd)
include (CXXSniffer)
set (PROJECT_VERSION "1.2.0")
OPTION(USE_GNUTLS "Build gnutls support." ON)
message ("-- Looking for SHA1 references")
if (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
set (HAVE_COMMIT true)
execute_process (COMMAND git log -1 --pretty=format:%h
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
OUTPUT_VARIABLE COMMIT)
configure_file ( ${CMAKE_SOURCE_DIR}/commit.h.in
${CMAKE_SOURCE_DIR}/commit.h)
message ("-- Found SHA1 reference: ${COMMIT}")
endif (EXISTS ${CMAKE_SOURCE_DIR}/.git/index)
set (PACKAGE "${PROJECT_NAME}")
set (VERSION "${PROJECT_VERSION}")
set (PACKAGE_BUGREPORT "[email protected]")
set (PACKAGE_NAME "${PACKAGE}")
set (PACKAGE_TARNAME "${PACKAGE}")
set (PACKAGE_VERSION "${VERSION}")
set (PACKAGE_STRING "${PACKAGE} ${VERSION}")
if (FREEBSD OR DRAGONFLY)
SET (TASKD_MAN1DIR man/man1 CACHE STRING "Installation directory for man pages, section 1")
SET (TASKD_MAN5DIR man/man5 CACHE STRING "Installation directory for man pages, section 5")
else (FREEBSD OR DRAGONFLY)
SET (TASKD_MAN1DIR share/man/man1 CACHE STRING "Installation directory for man pages, section 1")
SET (TASKD_MAN5DIR share/man/man5 CACHE STRING "Installation directory for man pages, section 5")
endif (FREEBSD OR DRAGONFLY)
SET (TASKD_DOCDIR share/doc/taskd CACHE STRING "Installation directory for doc files")
SET (TASKD_EXTDIR libexec/taskd CACHE STRING "Installation directory for the extensions")
SET (TASKD_BINDIR bin CACHE STRING "Installation directory for the program")
message ("-- Looking for GnuTLS")
find_package (GnuTLS REQUIRED)
if (GNUTLS_FOUND)
set (HAVE_LIBGNUTLS true)
set (TASKD_INCLUDE_DIRS ${TASKD_INCLUDE_DIRS} ${GNUTLS_INCLUDE_DIR})
set (TASKD_LIBRARIES ${TASKD_LIBRARIES} ${GNUTLS_LIBRARIES})
endif (GNUTLS_FOUND)
check_function_exists (timegm HAVE_TIMEGM)
check_function_exists (get_current_dir_name HAVE_GET_CURRENT_DIR_NAME)
check_struct_has_member ("struct tm" tm_gmtoff time.h HAVE_TM_GMTOFF)
check_struct_has_member ("struct stat" st_birthtime "sys/types.h;sys/stat.h" HAVE_ST_BIRTHTIME)
message ("-- Looking for libuuid")
if (DARWIN OR FREEBSD OR OPENBSD)
# Apple and FreeBSD include the uuid functions in their libc, rather than libuuid
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
else (DARWIN OR FREEBSD OR OPENBSD)
find_path (UUID_INCLUDE_DIR uuid/uuid.h)
find_library (UUID_LIBRARY NAMES uuid)
if (UUID_INCLUDE_DIR AND UUID_LIBRARY)
set (TASKD_INCLUDE_DIRS ${TASKD_INCLUDE_DIRS} ${UUID_INCLUDE_DIR})
set (TASKD_LIBRARIES ${TASKD_LIBRARIES} ${UUID_LIBRARY})
# Look for uuid_unparse_lower
set (CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${UUID_INCLUDE_DIR})
set (CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${UUID_LIBRARY})
check_function_exists (uuid_unparse_lower HAVE_UUID_UNPARSE_LOWER)
else (UUID_INCLUDE_DIR AND UUID_LIBRARY)
message (FATAL_ERROR "-- libuuid not found.")
endif (UUID_INCLUDE_DIR AND UUID_LIBRARY)
endif (DARWIN OR FREEBSD OR OPENBSD)
if (HAVE_UUID_UNPARSE_LOWER)
message ("-- Found libuuid")
else (HAVE_UUID_UNPARSE_LOWER)
message ("-- Found libuuid, using internal uuid_unparse_lower")
endif (HAVE_UUID_UNPARSE_LOWER)
if (SOLARIS)
# accept() is in libsocket according to its manpage
message("-- Looking for libsocket")
find_library (SOCKET_LIBRARY NAMES socket)
if (SOCKET_LIBRARY)
set (TASKD_LIBRARIES ${TASKD_LIBRARIES} ${SOCKET_LIBRARY})
else (SOCKET_LIBRARY)
message(FATAL_ERROR "-- libsocket not found.")
endif (SOCKET_LIBRARY)
# inet_ntop() is in libnsl according to its manpage
message("-- Looking for libnsl")
find_library (NSL_LIBRARY NAMES nsl)
if (NSL_LIBRARY)
set (TASKD_LIBRARIES ${TASKD_LIBRARIES} ${NSL_LIBRARY})
else (NSL_LIBRARY)
message(FATAL_ERROR "-- libnsl not found.")
endif (NSL_LIBRARY)
endif (SOLARIS)
message ("-- Configuring cmake.h")
configure_file (
${CMAKE_SOURCE_DIR}/cmake.h.in
${CMAKE_SOURCE_DIR}/cmake.h)
add_subdirectory (src)
add_subdirectory (doc)
if (EXISTS ${CMAKE_SOURCE_DIR}/test)
add_subdirectory (test EXCLUDE_FROM_ALL)
endif (EXISTS ${CMAKE_SOURCE_DIR}/test)
set (doc_FILES NEWS ChangeLog INSTALL AUTHORS COPYING)
foreach (doc_FILE ${doc_FILES})
install (FILES ${doc_FILE} DESTINATION ${TASKD_DOCDIR})
endforeach (doc_FILE)
install (PROGRAMS src/taskdctl DESTINATION ${TASKD_BINDIR})
# ---
set (CPACK_SOURCE_GENERATOR "TGZ")
set (CPACK_SOURCE_PACKAGE_FILE_NAME ${PACKAGE_NAME}-${PACKAGE_VERSION})
set (CPACK_SOURCE_IGNORE_FILES "CMakeCache" "CMakeFiles" "CPackConfig" "CPackSourceConfig"
"_CPack_Packages" "cmake_install" "install_manifest"
"Makefile$" "test" "package-config"
"src/taskd$" "src/tls" "/\\\\.gitignore" "/\\\\.git/" "swp$")
include (CPack)