forked from SimulPiscator/AirSane
-
Notifications
You must be signed in to change notification settings - Fork 1
/
CMakeLists.txt
135 lines (122 loc) · 3.24 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
cmake_minimum_required(VERSION 3.1)
project(airsaned)
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(APPLE)
include_directories(/opt/local/include)
link_directories(/opt/local/lib)
set(ZEROCONF_FILES
zeroconf/mdnspublisher-dnssd.mm
)
set(ZEROCONF_LIBS
"-lobjc"
"-framework IOKit"
"-framework CFNetwork"
)
else()
set(ZEROCONF_FILES
zeroconf/mdnspublisher-avahi.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/mainserver.cpp
server/mainpage.cpp
server/scanner.cpp
server/scanjob.cpp
server/scannerserver.cpp
server/scannerpage.cpp
sanecpp/sanecpp.cpp
basic/uuid.cpp
basic/dictionary.cpp
basic/fdbuf.cpp
web/httpserver.cpp
web/webpage.cpp
web/errorpage.cpp
imageformats/imageencoder.cpp
imageformats/jpegencoder.cpp
imageformats/pdfencoder.cpp
imageformats/pngencoder.cpp
zeroconf/mdnspublisher.cpp
zeroconf/hotplugnotifier.cpp
${ZEROCONF_FILES}
)
target_link_libraries(
${PROJECT_NAME}
Threads::Threads
sane
jpeg
png
${ZEROCONF_LIBS}
usb-1.0
)
if(APPLE)
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION /usr/local/sbin
)
install(FILES launchd/org.simulpiscator.airsaned.plist
DESTINATION /Library/LaunchDaemons
)
install(CODE "
if(NOT EXISTS /usr/local/etc/airsane/ignore.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/ignore.conf DESTINATION /usr/local/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS /usr/local/etc/airsane/options.conf)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/options.conf DESTINATION /usr/local/etc/airsane)
endif()
")
install(CODE "
if(NOT EXISTS /usr/local/etc/airsane/Gnome-scanner.png)
file(INSTALL ${CMAKE_SOURCE_DIR}/etc/Gnome-scanner.png DESTINATION /usr/local/etc/airsane)
endif()
")
else()
install(TARGETS ${PROJECT_NAME}
RUNTIME DESTINATION bin
)
install(FILES systemd/airsaned.service
DESTINATION /lib/systemd/system
)
install(FILES systemd/airsaned.default
DESTINATION /etc/default
RENAME airsane
)
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()