]> the.earth.li Git - onak.git/blob - keydb/CMakeLists.txt
3d09dc4b065acb0ea9f60beb7bb1e6f7fe0ae9ed
[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         pkg_check_modules(SYSTEMD libsystemd)
41         if (SYSTEMD_FOUND)
42                 set(HAVE_SYSTEMD true)
43                 target_include_directories(keyd SYSTEM PUBLIC
44                         ${SYSTEMD_INCLUDE_DIRS})
45                 target_link_libraries(keyd ${SYSTEMD_LIBRARIES})
46         endif()
47
48         install(TARGETS keydctl RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})
49         install(TARGETS keyd RUNTIME DESTINATION ${CMAKE_INSTALL_SBINDIR})
50         install(FILES keyd.8 keydctl.8
51                 DESTINATION ${CMAKE_INSTALL_MANDIR}/man8/)
52 endif()
53
54 if (DBTYPE STREQUAL "dynamic")
55         foreach(BACKEND IN LISTS BACKENDS)
56                 add_library(keydb_${BACKEND} SHARED keydb_${BACKEND}.c)
57                 target_include_directories(keydb_${BACKEND} SYSTEM PUBLIC
58                         ${BACKEND_${BACKEND}_INC})
59                 target_link_libraries(keydb_${BACKEND} libonak
60                         ${BACKEND_${BACKEND}_LIBS})
61                 install(TARGETS keydb_${BACKEND} LIBRARY DESTINATION
62                         ${CMAKE_INSTALL_LIBDIR}/onak/backends/)
63         endforeach(BACKEND)
64 endif()