forked from gerbera/gerbera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CMakeLists.txt
618 lines (558 loc) · 23.2 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
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
cmake_minimum_required(VERSION 3.18 FATAL_ERROR)
cmake_policy(VERSION 3.13)
# Only set for release tags
# You should only see version "git" when built from a git snapshot tarball
set(GERBERA_VERSION "git")
project(Gerbera
DESCRIPTION "UPnP Media Server"
HOMEPAGE_URL "https://gerbera.io"
LANGUAGES CXX C)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
# If Conan stuff is present, load it
include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake OPTIONAL)
if(COMMAND conan_basic_setup)
# Prefer the conan FindModules
list(PREPEND CMAKE_MODULE_PATH ${CMAKE_BINARY_DIR})
conan_basic_setup(TARGETS)
endif()
set(WITH_NPUPNP NO CACHE BOOL "Use npupnp instead of libupnp")
set(WITH_MAGIC YES CACHE BOOL "Use libmagic to identify file mime types")
set(WITH_MYSQL NO CACHE BOOL "Store media information in MySQL DB")
set(WITH_CURL YES CACHE BOOL "CURL required for online services")
set(WITH_INOTIFY YES CACHE BOOL "Enable Inotify file monitoring support")
set(WITH_JS YES CACHE BOOL "Enable JavaScript for scripting")
set(WITH_TAGLIB YES CACHE BOOL "Use TagLib to extract audio file metadata")
set(WITH_AVCODEC NO CACHE BOOL "Use ffmpeg/libav to extract file metadata")
set(WITH_WAVPACK NO CACHE BOOL "Use wavpack to extract audio file metadata")
set(WITH_FFMPEGTHUMBNAILER NO CACHE BOOL "Enable Thumbnail generation")
set(WITH_EXIF YES CACHE BOOL "Use libexif to extract image metadata")
set(WITH_EXIV2 NO CACHE BOOL "Use libexiv2 to extract image metadata")
set(WITH_MATROSKA YES CACHE BOOL "Use libmatroska to extract video/mkv metadata")
set(WITH_SYSTEMD YES CACHE BOOL "Install Systemd unit file")
set(WITH_LASTFM NO CACHE BOOL "Enable scrobbling to LastFM")
set(WITH_DEBUG YES CACHE BOOL "Enables debug logging")
set(WITH_DEBUG_OPTIONS YES CACHE BOOL "Enables dedicated debug messages")
set(WITH_TESTS NO CACHE BOOL "Build unit tests")
# For building packages without depending on the old system libupnp
set(STATIC_LIBUPNP 0 CACHE BOOL "Link to libupnp statically")
# Leverage a modern C++
# Set defaults here before we create targets
set(CMAKE_CXX_STANDARD 17)
# Cygwin requires extensions for a lot of the networking stuff.
if(CYGWIN)
set(CMAKE_CXX_STANDARD_REQUIRED NO)
set(CMAKE_CXX_EXTENSIONS YES)
else(CYGWIN)
set(CMAKE_CXX_STANDARD_REQUIRED YES)
set(CMAKE_CXX_EXTENSIONS NO)
endif(CYGWIN)
add_library(libgerbera STATIC
src/action_request.cc
src/action_request.h
src/cds/cds_container.cc
src/cds/cds_container.h
src/cds/cds_item.cc
src/cds/cds_item.h
src/cds/cds_objects.cc
src/cds/cds_objects.h
src/cds/cds_resource.cc
src/cds/cds_resource.h
src/common.h
src/config/client_config.h
src/config/client_config.cc
src/config/config_definition.h
src/config/config_definition.cc
src/config/config_generator.h
src/config/config_generator.cc
src/config/config_manager.cc
src/config/config_manager.h
src/config/config_options.cc
src/config/config_options.h
src/config/setup/config_setup_array.cc
src/config/setup/config_setup_autoscan.cc
src/config/setup/config_setup_bool.cc
src/config/setup/config_setup_client.cc
src/config/setup/config_setup_dictionary.cc
src/config/setup/config_setup_dynamic.cc
src/config/setup/config_setup_int.cc
src/config/setup/config_setup_path.cc
src/config/setup/config_setup_string.cc
src/config/setup/config_setup_transcoding.cc
src/config/setup/config_setup_tweak.cc
src/config/setup/config_setup_vector.cc
src/config/config_setup.cc
src/config/config_setup.h
src/config/directory_tweak.cc
src/config/directory_tweak.h
src/config/dynamic_content.cc
src/config/dynamic_content.h
src/content/autoscan.cc
src/content/autoscan.h
src/content/autoscan_list.cc
src/content/autoscan_list.h
src/content/autoscan_inotify.cc
src/content/autoscan_inotify.h
src/content/content_manager.cc
src/content/content_manager.h
src/content/layout/builtin_layout.cc
src/content/layout/builtin_layout.h
src/content/layout/js_layout.cc
src/content/layout/js_layout.h
src/content/layout/layout.h
src/content/onlineservice/atrailers_content_handler.cc
src/content/onlineservice/atrailers_content_handler.h
src/content/onlineservice/atrailers_service.cc
src/content/onlineservice/atrailers_service.h
src/content/onlineservice/curl_online_service.cc
src/content/onlineservice/curl_online_service.h
src/content/onlineservice/lastfm_scrobbler.cc
src/content/onlineservice/lastfm_scrobbler.h
src/content/onlineservice/online_service.cc
src/content/onlineservice/online_service.h
src/content/onlineservice/online_service_helper.cc
src/content/onlineservice/online_service_helper.h
src/content/onlineservice/task_processor.cc
src/content/onlineservice/task_processor.h
src/content/scripting/import_script.cc
src/content/scripting/import_script.h
src/content/scripting/js_functions.cc
src/content/scripting/js_functions.h
src/content/scripting/playlist_parser_script.cc
src/content/scripting/playlist_parser_script.h
src/content/scripting/scripting_runtime.cc
src/content/scripting/scripting_runtime.h
src/content/scripting/script.cc
src/content/scripting/script.h
src/content/scripting/script_names.h
src/content/update_manager.cc
src/content/update_manager.h
src/context.cc
src/context.h
src/contrib/md5.c
src/contrib/md5.h
src/database/mysql/mysql_database.cc
src/database/mysql/mysql_database.h
src/database/sqlite3/sqlite_database.cc
src/database/sqlite3/sqlite_database.h
src/database/sqlite3/sl_task.cc
src/database/sqlite3/sl_task.h
src/database/sql_database.cc
src/database/sql_database.h
src/database/sql_format.h
src/database/database.cc
src/database/database.h
src/database/search_handler.cc
src/database/search_handler.h
src/device_description_handler.cc
src/device_description_handler.h
src/exceptions.cc
src/exceptions.h
src/file_request_handler.cc
src/file_request_handler.h
src/iohandler/buffered_io_handler.cc
src/iohandler/buffered_io_handler.h
src/iohandler/curl_io_handler.cc
src/iohandler/curl_io_handler.h
src/iohandler/file_io_handler.cc
src/iohandler/file_io_handler.h
src/iohandler/io_handler_buffer_helper.cc
src/iohandler/io_handler_buffer_helper.h
src/iohandler/io_handler.cc
src/iohandler/io_handler_chainer.cc
src/iohandler/io_handler_chainer.h
src/iohandler/io_handler.h
src/iohandler/mem_io_handler.cc
src/iohandler/mem_io_handler.h
src/iohandler/process_io_handler.cc
src/iohandler/process_io_handler.h
src/metadata/exiv2_handler.cc
src/metadata/exiv2_handler.h
src/metadata/ffmpeg_handler.cc
src/metadata/ffmpeg_handler.h
src/metadata/ffmpeg_thumbnailer_handler.cc
src/metadata/ffmpeg_thumbnailer_handler.h
src/metadata/libexif_handler.cc
src/metadata/libexif_handler.h
src/metadata/matroska_handler.cc
src/metadata/matroska_handler.h
src/metadata/metacontent_handler.cc
src/metadata/metacontent_handler.h
src/metadata/metadata_handler.cc
src/metadata/metadata_handler.h
src/metadata/resolution.cc
src/metadata/resolution.h
src/metadata/taglib_handler.cc
src/metadata/taglib_handler.h
src/metadata/wavpack_handler.cc
src/metadata/wavpack_handler.h
src/request_handler.cc
src/request_handler.h
src/server.cc
src/server.h
src/subscription_request.cc
src/subscription_request.h
src/transcoding/transcode_dispatcher.cc
src/transcoding/transcode_dispatcher.h
src/transcoding/transcode_ext_handler.cc
src/transcoding/transcode_ext_handler.h
src/transcoding/transcode_handler.cc
src/transcoding/transcode_handler.h
src/transcoding/transcoding.cc
src/transcoding/transcoding.h
src/upnp_cds.cc
src/upnp_cds.h
src/upnp_cm.cc
src/upnp_cm.h
src/upnp_mrreg.cc
src/upnp_mrreg.h
src/upnp_xml.cc
src/upnp_xml.h
src/url_request_handler.cc
src/url_request_handler.h
src/util/enum_iterator.h
src/util/executor.h
src/util/generic_task.cc
src/util/generic_task.h
src/util/grb_fs.cc
src/util/grb_fs.h
src/util/grb_net.cc
src/util/grb_net.h
src/util/grb_time.cc
src/util/grb_time.h
src/util/jpeg_resolution.cc
src/util/logger.h
src/util/logger.cc
src/util/mime.cc
src/util/mime.h
src/util/mt_inotify.cc
src/util/mt_inotify.h
src/util/process_executor.cc
src/util/process_executor.h
src/util/string_converter.cc
src/util/string_converter.h
src/util/thread_executor.cc
src/util/thread_executor.h
src/util/thread_runner.h
src/util/timer.cc
src/util/timer.h
src/util/tools.cc
src/util/tools.h
src/util/upnp_clients.h
src/util/upnp_clients.cc
src/util/upnp_headers.h
src/util/upnp_headers.cc
src/util/upnp_quirks.h
src/util/upnp_quirks.cc
src/util/url.cc
src/util/url.h
src/util/url_utils.h
src/util/url_utils.cc
src/util/xml_to_json.cc
src/util/xml_to_json.h
src/web/action.cc
src/web/add.cc
src/web/add_object.cc
src/web/auth.cc
src/web/clients.cc
src/web/config_load.cc
src/web/config_save.cc
src/web/containers.cc
src/web/directories.cc
src/web/edit_load.cc
src/web/edit_save.cc
src/web/files.cc
src/web/items.cc
src/web/pages.cc
src/web/pages.h
src/web/remove.cc
src/web/web_request_handler.cc
src/web/web_request_handler.h
src/web/session_manager.cc
src/web/session_manager.h
src/web/tasks.cc
src/web/web_autoscan.cc
src/web/web_update.cc
)
target_include_directories(libgerbera PUBLIC "${CMAKE_SOURCE_DIR}/src")
add_executable(gerbera src/main.cc)
target_link_libraries(gerbera PRIVATE libgerbera)
# Warnings are nice
target_compile_options(gerbera PRIVATE -Wall)
target_compile_options(libgerbera PRIVATE -Wall)
# Add the automatically determined parts of the RPATH which point to
# directories outside the build tree to the install RPATH
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
# System specific stuff
if (${CMAKE_SYSTEM_NAME} MATCHES ".*(SunOS|Solaris).*")
target_compile_definitions(libgerbera PUBLIC SOLARIS)
elseif (${CMAKE_SYSTEM_NAME} MATCHES ".*BSD.*")
target_compile_definitions(libgerbera PUBLIC BSD)
endif()
# Generate Compile Information
include("GenCompileInfo")
generate_compile_info()
target_compile_definitions(gerbera PRIVATE COMPILE_INFO="${COMPILE_INFO}")
target_compile_definitions(gerbera PRIVATE GIT_BRANCH="${GIT_BRANCH}")
target_compile_definitions(gerbera PRIVATE GIT_COMMIT_HASH="${GIT_COMMIT_HASH}")
if ((${GERBERA_VERSION} STREQUAL "git") AND (NOT "${GIT_TAG}" STREQUAL ""))
# Master/git build so use git info
set(GERBERA_VERSION ${GIT_TAG})
endif()
message(STATUS "Gerbera Version: ${GERBERA_VERSION}")
target_compile_definitions(libgerbera PUBLIC GERBERA_VERSION="${GERBERA_VERSION}")
target_compile_definitions(gerbera PRIVATE PACKAGE_DATADIR="${CMAKE_INSTALL_PREFIX}/share/gerbera")
if (WITH_DEBUG)
target_compile_definitions(libgerbera PUBLIC TOMBDEBUG)
if (WITH_DEBUG_OPTIONS)
target_compile_definitions(libgerbera PUBLIC GRBDEBUG)
target_compile_definitions(gerbera PUBLIC GRBDEBUG)
target_compile_definitions(libgerbera PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_TRACE)
else()
target_compile_definitions(libgerbera PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_DEBUG)
endif()
else()
target_compile_definitions(libgerbera PUBLIC SPDLOG_ACTIVE_LEVEL=SPDLOG_LEVEL_INFO)
endif()
find_package(Threads REQUIRED)
target_link_libraries(libgerbera PUBLIC Threads::Threads)
check_library_exists(atomic __atomic_fetch_add_4 "" HAVE_ATOMIC)
if(HAVE_ATOMIC)
target_link_libraries(libgerbera PUBLIC atomic)
endif(HAVE_ATOMIC)
find_package(Filesystem REQUIRED)
target_link_libraries(libgerbera PUBLIC std::filesystem)
find_package(Iconv REQUIRED)
target_link_libraries(libgerbera PUBLIC Iconv::Iconv)
include(CheckPrototypeDefinition)
set(CMAKE_REQUIRED_LIBRARIES Iconv::Iconv)
check_prototype_definition(iconv "size_t iconv(iconv_t cd, const char **src, size_t *srcl, char **dst, size_t *dstl)" 0 "iconv.h" ICONV_CONST)
if(ICONV_CONST)
target_compile_definitions(libgerbera PRIVATE ICONV_CONST)
endif()
unset(CMAKE_REQUIRED_LIBRARIES)
find_package(UUID REQUIRED)
target_link_libraries(libgerbera PUBLIC UUID::UUID)
find_package(LFS REQUIRED)
target_compile_definitions(libgerbera PUBLIC ${LFS_DEFINITIONS})
target_compile_options(libgerbera PUBLIC ${LFS_COMPILE_OPTIONS})
target_link_libraries(libgerbera PUBLIC ${LFS_LIBRARIES})
if (WITH_NPUPNP)
find_package(PkgConfig QUIET)
pkg_check_modules(NPUPNP QUIET libnpupnp>=4.2.1)
if (NOT NPUPNP_FOUND)
find_package(NPUPNP REQUIRED)
endif()
target_include_directories(libgerbera PUBLIC ${NPUPNP_INCLUDE_DIRS})
target_compile_definitions(libgerbera PUBLIC USING_NPUPNP)
target_link_libraries(libgerbera PUBLIC ${NPUPNP_LIBRARIES})
else()
set(REQ_UPNP_VERSION 1.14.6)
# LibUPnP official target since 1.16 (Lib version 18)
# This will prefer the provided UPNPConfig.cmake if found, if not, it will fall back our FindUPNP.cmake
find_package(UPNP ${REQ_UPNP_VERSION} QUIET)
if(NOT TARGET UPNP::UPNP)
# Conan packages have autogenerated CMake packages under pupnp::pupnp
find_package(pupnp ${REQ_UPNP_VERSION} QUIET)
if(TARGET pupnp::pupnp)#
add_library(UPNP::UPNP ALIAS pupnp::pupnp)
endif()
endif()
if(NOT TARGET UPNP::UPNP)
message(FATAL_ERROR "Gerbera failed to find libupnp! at least version ${REQ_UPNP_VERSION} is needed.")
endif()
# Conan autogenerated targets dont set a version, but to set name_VERSION var
get_target_property(_UPNP_VERSION UPNP::UPNP VERSION)
if (NOT _UPNP_VERSION)
set(_UPNP_VERSION ${pupnp_VERSION})
endif()
get_target_property(_UPNP_LIB UPNP::UPNP LOCATION)
# Provide our own status message as we search QUIET-ly
message(STATUS "Found libupnp: ${_UPNP_LIB} (found version ${_UPNP_VERSION})")
# Check and warn for libupnp features
include(CheckCXXSymbolExists)
get_target_property(UPNP_INCLUDE_DIR UPNP::UPNP INTERFACE_INCLUDE_DIRECTORIES)
check_cxx_symbol_exists(UPNP_ENABLE_IPV6 "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_IPV6)
if (NOT UPNP_HAS_IPV6)
message(FATAL_ERROR "Gerbera requires libupnp with IPv6 support.")
endif()
check_cxx_symbol_exists(UPNP_MINISERVER_REUSEADDR "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_REUSEADDR)
if (NOT UPNP_HAS_REUSEADDR)
message(WARNING [=[
!! It is strongly recommended to build libupnp with --enable-reuseaddr !!
Without this option Gerbera will be unable to restart with the same port number.]=])
endif()
check_cxx_symbol_exists(UPNP_ENABLE_BLOCKING_TCP_CONNECTIONS "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_BLOCKING_TCP)
if (UPNP_HAS_BLOCKING_TCP)
message(WARNING [=[
!! It is strongly recommended to build libupnp with --disable-blocking-tcp-connections !!
Without this option non-responsive control points can cause libupnp to hang.]=])
endif()
check_cxx_symbol_exists(UPNP_HAVE_TOOLS "${UPNP_INCLUDE_DIR}/upnpconfig.h" UPNP_HAS_TOOLS)
if (NOT UPNP_HAS_TOOLS)
message(WARNING [=[
!! It is strongly recommended to build libupnp with --enable-tools !!
]=])
endif()
target_link_libraries(libgerbera PUBLIC UPNP::UPNP)
endif()
find_package(fmt 7.1.3 REQUIRED)
target_link_libraries(libgerbera PUBLIC fmt::fmt)
find_package(spdlog 1.8.1 REQUIRED)
target_link_libraries(libgerbera PUBLIC spdlog::spdlog)
find_package(pugixml REQUIRED)
target_link_libraries(libgerbera PUBLIC pugixml::pugixml)
find_package(SQLite3 3.7.11 REQUIRED)
target_link_libraries(libgerbera PUBLIC SQLite::SQLite3)
# We should probably move these two out to their own FindLocale
include(CheckFunctionExists)
check_function_exists(nl_langinfo HAVE_NL_LANGINFO)
if (HAVE_NL_LANGINFO)
target_compile_definitions(libgerbera PUBLIC HAVE_NL_LANGINFO)
endif()
check_function_exists(setlocale HAVE_SETLOCALE)
if (HAVE_SETLOCALE)
target_compile_definitions(libgerbera PUBLIC HAVE_SETLOCALE)
endif()
# Link to the socket library if it exists. This is something you need on Solaris/OmniOS/Joyent
find_library(SOCKET_LIBRARY socket)
if(SOCKET_LIBRARY)
target_link_libraries(libgerbera PUBLIC ${SOCKET_LIBRARY})
endif()
# Link to libnsl (Network services library) if it exists. This is something you need on Solaris/OmniOS/Joyent
find_library(NSL_LIBRARY nsl)
if(NSL_LIBRARY)
target_link_libraries(libgerbera PUBLIC ${NSL_LIBRARY})
endif()
if(WITH_INOTIFY)
find_package(Inotify REQUIRED)
target_link_libraries(libgerbera PUBLIC Inotify::Inotify)
target_compile_definitions(libgerbera PUBLIC HAVE_INOTIFY)
endif()
if(WITH_JS)
find_package(duktape REQUIRED)
target_link_libraries(libgerbera PUBLIC duktape::duktape)
target_compile_definitions(libgerbera PUBLIC HAVE_JS)
endif()
if(WITH_MYSQL)
find_package(mariadb-connector-c QUIET)
if(mariadb-connector-c_FOUND)
target_include_directories(libgerbera PUBLIC ${mariadb-connector-c_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${mariadb-connector-c_LIBS})
target_compile_definitions(libgerbera PUBLIC HAVE_MYSQL)
find_package(OpenSSL REQUIRED)
target_include_directories(libgerbera PUBLIC ${OpenSSL_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${OpenSSL_LIBS})
else()
find_package(MySQL REQUIRED)
target_include_directories(libgerbera PUBLIC ${MYSQL_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${MYSQL_CLIENT_LIBS})
target_compile_definitions(libgerbera PUBLIC HAVE_MYSQL)
endif()
endif()
if(WITH_CURL)
find_package(CURL REQUIRED)
target_link_libraries(libgerbera PUBLIC CURL::libcurl)
target_compile_definitions(libgerbera PUBLIC
HAVE_CURL
ONLINE_SERVICES
ATRAILERS)
endif()
if(WITH_TAGLIB)
find_package(Taglib 1.12 REQUIRED)
target_link_libraries(libgerbera PUBLIC Taglib::Taglib)
target_compile_definitions(libgerbera PUBLIC HAVE_TAGLIB)
endif()
if(WITH_WAVPACK)
find_package(wavpack 5.1.0 REQUIRED)
target_link_libraries(libgerbera PUBLIC wavpack::wavpack)
target_compile_definitions(libgerbera PUBLIC HAVE_WAVPACK)
endif()
if(WITH_MAGIC)
find_package(LibMagic REQUIRED)
target_include_directories(libgerbera PUBLIC ${LibMagic_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${LibMagic_LIBRARIES})
target_compile_definitions(libgerbera PUBLIC HAVE_MAGIC)
endif()
if(WITH_AVCODEC)
find_package(FFMPEG REQUIRED)
target_link_libraries(libgerbera PUBLIC PkgConfig::FFMPEG)
target_compile_definitions(libgerbera PUBLIC HAVE_FFMPEG)
include(CheckStructHasMember)
set(CMAKE_REQUIRED_LIBRARIES PkgConfig::FFMPEG)
check_struct_has_member("struct AVStream" codecpar libavformat/avformat.h HAVE_AVSTREAM_CODECPAR LANGUAGE C)
if (HAVE_AVSTREAM_CODECPAR)
target_compile_definitions(libgerbera PUBLIC HAVE_AVSTREAM_CODECPAR)
endif()
endif()
if(WITH_FFMPEGTHUMBNAILER)
find_package (FFMpegThumbnailer REQUIRED)
target_include_directories(libgerbera PUBLIC ${FFMPEGTHUMBNAILER_INCLUDE_DIR})
target_link_libraries(libgerbera PUBLIC ${FFMPEGTHUMBNAILER_LIBRARIES})
target_compile_definitions(libgerbera PUBLIC HAVE_FFMPEGTHUMBNAILER)
endif()
if(WITH_EXIF)
find_package(EXIF REQUIRED)
target_include_directories(libgerbera PUBLIC ${EXIF_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${EXIF_LIBRARIES})
target_compile_definitions(libgerbera PUBLIC HAVE_LIBEXIF)
endif()
if(WITH_EXIV2)
find_package(LibExiv2 REQUIRED)
target_link_libraries(libgerbera PUBLIC LibExiv2::LibExiv2)
target_compile_definitions(libgerbera PUBLIC HAVE_EXIV2)
# Exiv still uses std::auto_ptr
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
target_compile_definitions(libgerbera PUBLIC _LIBCPP_ENABLE_CXX17_REMOVED_AUTO_PTR)
endif()
endif()
if(WITH_MATROSKA)
find_package(EBML REQUIRED)
target_include_directories(libgerbera PUBLIC ${EBML_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${EBML_LIBRARIES})
find_package(Matroska REQUIRED)
target_include_directories(libgerbera PUBLIC ${Matroska_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${Matroska_LIBRARIES})
target_compile_definitions(libgerbera PUBLIC HAVE_MATROSKA)
endif()
if(WITH_LASTFM)
find_package (LastFMLib REQUIRED)
target_include_directories(libgerbera PUBLIC ${LASTFMLIB_INCLUDE_DIRS})
target_link_libraries(libgerbera PUBLIC ${LASTFMLIB_LIBRARIES})
target_compile_definitions(libgerbera PUBLIC HAVE_LASTFMLIB)
endif()
find_package (ZLIB REQUIRED)
target_link_libraries (libgerbera PUBLIC ZLIB::ZLIB)
if(WITH_SYSTEMD AND (${CMAKE_SYSTEM_NAME} MATCHES "Linux"))
find_package(Systemd)
if(SYSTEMD_FOUND)
if(WITH_MYSQL AND MYSQL_FOUND)
set (SYSTEMD_AFTER_TARGET "mysql.target network-online.target")
set (SYSTEMD_DESCRIPTION "Gerbera Media Server with MySQL")
else()
set (SYSTEMD_AFTER_TARGET "network.target network-online.target")
set (SYSTEMD_DESCRIPTION "Gerbera Media Server")
endif()
set (SYSTEMD_WANTS_TARGET "network-online.target")
configure_file(${CMAKE_SOURCE_DIR}/scripts/systemd/gerbera.service.cmake gerbera.service)
message(STATUS "Configuring systemd unit file: gerbera.service" )
INSTALL(FILES ${CMAKE_CURRENT_BINARY_DIR}/gerbera.service DESTINATION ${SYSTEMD_UNIT_DIR} COMPONENT init)
else()
message(FATAL_ERROR "Systemd not found")
endif()
endif()
if(WITH_TESTS)
message(STATUS "Configuring unit tests")
enable_testing()
add_subdirectory(test)
endif()
INSTALL(TARGETS gerbera DESTINATION bin)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/scripts/js DESTINATION share/gerbera)
INSTALL(DIRECTORY ${PROJECT_SOURCE_DIR}/web DESTINATION share/gerbera)
INSTALL(FILES
src/database/mysql/mysql.sql
src/database/mysql/mysql-upgrade.xml
src/database/sqlite3/sqlite3.sql
src/database/sqlite3/sqlite3-upgrade.xml
DESTINATION share/gerbera)
INSTALL(FILES ${PROJECT_SOURCE_DIR}/doc/gerbera.1 DESTINATION share/man/man1)
include(packaging)