]> the.earth.li Git - onak.git/blob - keydb/CMakeLists.txt
Fix systemd detection
[onak.git] / keydb / CMakeLists.txt
1 # Key database backends
2
3 # These have no dependencies and can always be compiled
4 set(BACKENDS "file" "fs" "keyring" "stacked")
5
6 # DB4 backend (add check for existence)
7 find_package(BDB)
8 if (BDB_FOUND)
9         LIST(APPEND BACKENDS db4)
10         set(BACKEND_db4_LIBS db)
11 endif()
12
13 # HKP backend - needs libcurl
14 pkg_check_modules(CURL libcurl)
15 if (CURL_FOUND)
16         LIST(APPEND BACKENDS hkp)
17         set(BACKEND_hkp_INC ${CURL_INCLUDE_DIRS})
18         set(BACKEND_hkp_LIBS ${CURL_LIBRARIES})
19 endif()
20
21 # PostgreSQL backend - needs libpq
22 pkg_check_modules(POSTGRESQL libpq)
23 if (POSTGRESQL_FOUND)
24         LIST(APPEND BACKENDS pg)
25         set(BACKEND_pg_INC ${POSTGRESQL_INCLUDE_DIRS})
26         set(BACKEND_pg_LIBS ${POSTGRESQL_LIBRARIES})
27 endif()
28
29 # keyd backend - can be disabled entirely
30 if (KEYD STREQUAL "ON")
31         LIST(APPEND BACKENDS keyd)
32
33         add_executable(keyd keyd.c)
34         target_link_libraries(keyd libonak)
35         add_executable(keydctl keydctl.c ../onak-conf.c)
36         target_link_libraries(keydctl libonak)
37         target_compile_definitions(keydctl PRIVATE
38                 CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
39
40         if (SYSTEMD_FOUND)
41                 target_include_directories(keyd SYSTEM PUBLIC
42                         ${SYSTEMD_INCLUDE_DIRS})
43                 target_link_libraries(keyd ${SYSTEMD_LIBRARIES})
44         endif()
45
46         install(TARGETS keydctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
47         install(TARGETS keyd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
48         install(FILES keyd.8 keydctl.8
49                 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
50 endif()
51
52 if (DBTYPE STREQUAL "dynamic")
53         foreach(BACKEND IN LISTS BACKENDS)
54                 add_library(keydb_${BACKEND} SHARED keydb_${BACKEND}.c)
55                 target_include_directories(keydb_${BACKEND} SYSTEM PUBLIC
56                         ${BACKEND_${BACKEND}_INC})
57                 target_link_libraries(keydb_${BACKEND} libonak
58                         ${BACKEND_${BACKEND}_LIBS})
59                 install(TARGETS keydb_${BACKEND} LIBRARY DESTINATION
60                         ${CMAKE_INSTALL_LIBDIR}/onak/backends/)
61         endforeach(BACKEND)
62 endif()