]> the.earth.li Git - onak.git/blob - keydb/CMakeLists.txt
Move key database backends into their own directory
[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 LIST(APPEND BACKENDS db4)
8 set(BACKEND_db4_LIBS db-5.3)
9
10 # HKP backend - needs libcurl
11 pkg_check_modules(CURL libcurl)
12 if (CURL_FOUND)
13         LIST(APPEND BACKENDS hkp)
14         set(BACKEND_hkp_INC ${CURL_INCLUDE_DIRS})
15         set(BACKEND_hkp_LIBS ${CURL_LIBRARIES})
16 endif()
17
18 # PostgreSQL backend - needs libpq
19 pkg_check_modules(POSTGRESQL libpq)
20 if (POSTGRESQL_FOUND)
21         LIST(APPEND BACKENDS pg)
22         set(BACKEND_pg_INC ${POSTGRESQL_INCLUDE_DIRS})
23         set(BACKEND_pg_LIBS ${POSTGRESQL_LIBRARIES})
24 endif()
25
26 # keyd backend - can be disabled entirely
27 if (KEYD STREQUAL "ON")
28         LIST(APPEND BACKENDS keyd)
29
30         add_executable(keyd keyd.c)
31         target_link_libraries(keyd libonak)
32         add_executable(keydctl keydctl.c ../onak-conf.c)
33         target_link_libraries(keydctl libonak)
34         target_compile_definitions(keydctl PRIVATE
35                 CONFIGDIR="${CMAKE_INSTALL_FULL_SYSCONFDIR}")
36
37         pkg_check_modules(SYSTEMD libsystemd)
38         if (SYSTEMD_FOUND)
39                 set(HAVE_SYSTEMD true)
40                 target_include_directories(keyd SYSTEM PUBLIC
41                         ${SYSTEMD_INCLUDE_DIRS})
42                 target_link_libraries(keyd ${SYSTEMD_LIBRARIES})
43         endif()
44
45         install(TARGETS keydctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
46         install(TARGETS keyd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
47         install(FILES keyd.8 keydctl.8
48                 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
49 endif()
50
51 if (DBTYPE STREQUAL "dynamic")
52         foreach(BACKEND IN LISTS BACKENDS)
53                 add_library(keydb_${BACKEND} SHARED keydb_${BACKEND}.c)
54                 target_include_directories(keydb_${BACKEND} SYSTEM PUBLIC
55                         ${BACKEND_${BACKEND}_INC})
56                 target_link_libraries(keydb_${BACKEND} libonak
57                         ${BACKEND_${BACKEND}_LIBS})
58                 install(TARGETS keydb_${BACKEND} LIBRARY DESTINATION
59                         ${CMAKE_INSTALL_LIBDIR}/onak/backends/)
60         endforeach(BACKEND)
61 endif()