-
Notifications
You must be signed in to change notification settings - Fork 26
/
CMakeLists.txt
223 lines (201 loc) · 5.76 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
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
cmake_minimum_required(VERSION 3.5)
project(airsaned)
include(GNUInstallDirs)
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/version.cpp
${CMAKE_CURRENT_BINARY_DIR}/_version.cpp
COMMAND ${CMAKE_COMMAND}
-DFILE=${CMAKE_CURRENT_BINARY_DIR}/version.cpp
-P ${CMAKE_CURRENT_SOURCE_DIR}/version.cmake
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fno-rtti -Wreturn-type")
set(LINK_FLAGS_MINSIZEREL "${LINK_FLAGS_MINSIZEREL} -s")
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE MinSizeRel CACHE STRING "Build type" FORCE)
endif()
set(THREADS_PREFER_PTHREAD_FLAG ON)
find_package(Threads REQUIRED)
include_directories(.)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
include_directories(/usr/local/include)
link_directories(/usr/local/lib)
endif()
if(APPLE)
include_directories(
/opt/local/include
/opt/homebrew/include
/usr/local/include
)
if(IS_DIRECTORY /opt/local/lib)
link_directories(/opt/local/lib)
endif()
if(IS_DIRECTORY /opt/homebrew/lib)
link_directories(/opt/homebrew/lib)
endif()
if(IS_DIRECTORY /usr/local/lib)
link_directories(/usr/local/lib)
endif()
set(ZEROCONF_FILES
zeroconf/mdnspublisher-dnssd.mm
zeroconf/networkhotplugnotifier-macos.mm
)
set(ZEROCONF_LIBS
"-lobjc"
"-framework Foundation"
"-framework IOKit"
"-framework CFNetwork"
"-framework CoreFoundation"
)
else()
set(ZEROCONF_FILES
zeroconf/mdnspublisher-avahi.cpp
zeroconf/networkhotplugnotifier.cpp
)
set(ZEROCONF_LIBS
avahi-client
avahi-common
)
endif()
add_executable(${PROJECT_NAME}
${CMAKE_CURRENT_BINARY_DIR}/version.cpp
server/main.cpp
server/optionsfile.cpp
server/server.cpp
server/mainpage.cpp
server/scanner.cpp
server/purgethread.cpp
server/scanjob.cpp
server/scannerpage.cpp
sanecpp/sanecpp.cpp
basic/uuid.cpp
basic/dictionary.cpp
basic/fdbuf.cpp
basic/workerthread.cpp
web/httpserver.cpp
web/webpage.cpp
web/errorpage.cpp
web/accessfile.cpp
imageformats/imageencoder.cpp
imageformats/jpegencoder.cpp
imageformats/pdfencoder.cpp
imageformats/pngencoder.cpp
zeroconf/mdnspublisher.cpp
zeroconf/hotplugnotifier.cpp
${ZEROCONF_FILES}
)
if(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
set(LIBUSB usb)
else()
set(LIBUSB usb-1.0)
endif()
if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(LIBATOMIC atomic)
else()
set(LIBATOMIC)
endif()
target_link_libraries(
${PROJECT_NAME}
Threads::Threads
sane
jpeg
png
${ZEROCONF_LIBS}
${LIBUSB}
${LIBATOMIC}
)
if(APPLE)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION sbin
)
install(FILES launchd/org.simulpiscator.airsaned.plist
DESTINATION /Library/LaunchDaemons
)
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/access.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/access.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/ignore.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/ignore.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/options.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/options.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/Gnome-scanner.png)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/Gnome-scanner.png DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
elseif(CMAKE_SYSTEM_NAME STREQUAL FreeBSD)
if ($ENV{PREFIX})
set(CMAKE_INSTALL_PREFIX $ENV{PREFIX})
else()
# default is "/usr/local"
endif()
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION sbin
)
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/access.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/access.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/ignore.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/ignore.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/options.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/options.conf DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/airsane/Gnome-scanner.png)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/Gnome-scanner.png DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS ${CMAKE_INSTALL_PREFIX}/etc/rc.d/airsaned)
file(INSTALL ${CMAKE_SOURCE_DIR}/freebsd/airsaned DESTINATION ${CMAKE_INSTALL_PREFIX}/etc/rc.d)
endif()
")
else()
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
configure_file(systemd/airsaned.service.in ${CMAKE_BINARY_DIR}/airsaned.service @ONLY)
install(FILES ${CMAKE_BINARY_DIR}/airsaned.service
DESTINATION /lib/systemd/system
)
install(FILES systemd/airsaned.default
DESTINATION /etc/default
RENAME airsane
)
install(CODE "
if(NOT EXISTS /etc/airsane/access.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/access.conf DESTINATION /etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS /etc/airsane/ignore.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/ignore.conf DESTINATION /etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS /etc/airsane/options.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/options.conf DESTINATION /etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS /etc/airsane/Gnome-scanner.png)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/Gnome-scanner.png DESTINATION /etc/airsane)
endif()
")
endif()