forked from davidmoreno/onion
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCMakeLists.txt
157 lines (133 loc) · 4.1 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
cmake_minimum_required (VERSION 2.8)
cmake_policy(VERSION 2.8)
project(libonion)
# Some tweak parameters
SET(ONION_USE_SSL true)
SET(ONION_USE_PAM true)
SET(ONION_USE_PTHREADS true)
SET(ONION_USE_PNG true)
SET(ONION_USE_XML2 true)
SET(ONION_USE_SYSTEMD true)
SET(ONION_VERSION 0.4.0)
########
SET(LIBPATH /usr/lib /usr/local/lib)
IF (NOT DEFINED BINDIR)
SET(BINDIR bin)
ENDIF (NOT DEFINED BINDIR)
IF (NOT DEFINED LIBDIR)
SET(LIBDIR lib)
ENDIF (NOT DEFINED LIBDIR)
IF (NOT DEFINED INCLUDE_PATH)
SET(INCLUDE_PATH /usr/include)
ENDIF (NOT DEFINED INCLUDE_PATH)
IF (NOT DEFINED INCLUDEDIR)
SET(INCLUDEDIR include/onion)
ENDIF(NOT DEFINED INCLUDEDIR)
if (${ONION_USE_SSL})
find_library(GNUTLS_LIB NAMES gnutls PATH ${LIBPATH})
find_library(GCRYPT_LIB NAMES gcrypt PATH ${LIBPATH})
if (GNUTLS_LIB AND GCRYPT_LIB)
set(GNUTLS_ENABLED true)
message(STATUS "Gnutls found. SSL support is compiled in.")
else(GNUTLS_LIB AND GCRYPT_LIB)
message("Gnutls not found. SSL support is not compiled in.")
endif(GNUTLS_LIB AND GCRYPT_LIB)
endif(${ONION_USE_SSL})
if (${ONION_USE_PTHREADS})
find_library(PTHREADS_LIB NAMES pthread PATH ${LIBPATH})
if(PTHREADS_LIB)
message(STATUS "pthreads found. Threading support is compiled in.")
set(PTHREADS true)
else(PTHREADS_LIB)
message("pthreads not found. Threading is not supported.")
endif(PTHREADS_LIB)
endif(${ONION_USE_PTHREADS})
if (${ONION_USE_XML2})
find_library(XML2_LIB NAMES xml2 PATH ${LIBPATH})
find_path(XML2_HEADERS NAMES libxml/xmlwriter.h HINTS ${INCLUDE_PATH} PATH_SUFFIXES libxml2)
if(XML2_HEADERS)
message(STATUS "libxml2 found. WebDAV support is compiled in.")
set(XML2_ENABLED true)
else(XML2_HEADERS)
message("libxml2 not found. WebDAV is not supported. ${XML2_HEADERS} ${XML2_LIB}")
endif(XML2_HEADERS)
endif(${ONION_USE_XML2})
if (${ONION_USE_PAM})
find_library(PAM_LIB NAMES pam pam_misc PATH ${LIBPATH})
if (PAM_LIB)
set(PAM_ENABLED true)
message(STATUS "pam found. PAM support is compiled in in handlers.")
else (PAM_LIB)
message("pam not found. No PAM support.")
endif (PAM_LIB)
endif (${ONION_USE_PAM})
if (${ONION_USE_PNG})
find_library(PNG_LIB NAMES png PATH ${LIBPATH})
if (PNG_LIB)
set(PNG_ENABLED true)
set(PNG_LIB ${PNG_LIB})
message(STATUS "libpng found. png support is compiled in at extras.")
find_library(CAIRO_LIB NAMES cairo PATH ${LIBPATH})
find_file(CAIRO_HEADER cairo/cairo.h ${INCLUDE_PATH})
if (CAIRO_HEADER)
set(CAIRO_ENABLED true)
set(CAIRO_LIB ${CAIRO_LIB})
message(STATUS "libcairo found. Adding cairo examples. ${CAIRO_LIB}")
else (CAIRO_HEADER)
message(STATUS "libcairo NOT found.")
endif (CAIRO_HEADER)
else (PNG_LIB)
message("libpng not found. No png support.")
endif (PNG_LIB)
endif (${ONION_USE_PNG})
find_library(CURL_LIB NAMES curl PATH ${LIBPATH})
if(CURL_LIB)
message(STATUS "curl found. Some extra test are compiled.")
set(CURL true)
else(CURL_LIB)
message("curl not found. Some examples wil not be built.")
endif(CURL_LIB)
if (${ONION_USE_SYSTEMD})
find_library(RT_LIB NAMES rt PATH ${LIBPATH})
if (RT_LIB)
set(SYSTEMD_ENABLED true)
message(STATUS "librt found. Systemd support compiled in.")
else(RT_LIB)
message("librt not found. Systemd support is not compiled in.")
endif(RT_LIB)
endif(${ONION_USE_SYSTEMD})
# defines
if (GNUTLS_ENABLED)
add_definitions(-DHAVE_GNUTLS)
endif(GNUTLS_ENABLED)
if (PTHREADS)
add_definitions(-DHAVE_PTHREADS)
endif(PTHREADS)
if (PAM_ENABLED)
add_definitions(-DHAVE_PAM)
endif(PAM_ENABLED)
if (XML2_ENABLED)
add_definitions(-DHAVE_WEBDAV)
endif(XML2_ENABLED)
if (SYSTEMD_ENABLED)
add_definitions(-DHAVE_SYSTEMD)
endif (SYSTEMD_ENABLED)
##
IF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
add_definitions(-D__DEBUG__)
SET(CMAKE_C_FLAGS "-Wall -Werror -O0 -fPIC")
ELSE (${CMAKE_BUILD_TYPE} MATCHES "Debug")
SET(CMAKE_C_FLAGS "-Wall -Werror -O2 -fPIC")
ENDIF (${CMAKE_BUILD_TYPE} MATCHES "Debug")
project (onion)
INCLUDE(CPackConfig.cmake)
INCLUDE(CPack)
add_subdirectory(src)
if (CROSS_COMPILING)
else (CROSS_COMPILING)
add_subdirectory(tools)
SET(OTEMPLATE otemplate)
SET(OPACK opack)
endif (CROSS_COMPILING)
add_subdirectory(examples)
add_subdirectory(tests)