CMakeLists.txt 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. cmake_minimum_required(VERSION 3.3)
  2. PROJECT(unetd C)
  3. SET(SOURCES
  4. main.c network.c host.c service.c pex.c pex-stun.c
  5. wg.c wg-user.c
  6. )
  7. SET(RUNSTATEDIR /var/run)
  8. ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations -DRUNSTATEDIR="${RUNSTATEDIR}")
  9. FIND_LIBRARY(libjson NAMES json-c json)
  10. OPTION(UBUS_SUPPORT "enable ubus support" ON)
  11. OPTION(VXLAN_SUPPORT "enable VXLAN support" ON)
  12. IF(CMAKE_SYSTEM_NAME STREQUAL "Linux")
  13. FIND_LIBRARY(nl nl-tiny)
  14. SET(SOURCES ${SOURCES} wg-linux.c)
  15. ELSE()
  16. SET(nl "")
  17. SET(VXLAN_SUPPORT OFF)
  18. ENDIF()
  19. IF(VXLAN_SUPPORT)
  20. find_library(bpf NAMES bpf)
  21. find_library(elf NAMES elf)
  22. find_library(zlib NAMES z)
  23. SET(SOURCES ${SOURCES} bpf.c vxlan.c rtnl.c)
  24. ADD_DEFINITIONS(-DVXLAN_SUPPORT)
  25. ELSE()
  26. SET(bpf "")
  27. SET(elf "")
  28. SET(zlib "")
  29. ENDIF()
  30. IF(UBUS_SUPPORT)
  31. SET(SOURCES ${SOURCES} ubus.c)
  32. SET(DHT_SOURCES ${DHT_SOURCES} udht-ubus.c)
  33. ADD_DEFINITIONS(-DUBUS_SUPPORT=1)
  34. FIND_LIBRARY(ubus ubus)
  35. ELSE()
  36. SET(ubus "")
  37. ENDIF()
  38. ADD_LIBRARY(unet SHARED curve25519.c siphash.c sha512.c fprime.c f25519.c ed25519.c edsign.c auth-data.c chacha20.c pex-msg.c utils.c stun.c)
  39. TARGET_LINK_LIBRARIES(unet ubox)
  40. ADD_EXECUTABLE(unetd ${SOURCES})
  41. TARGET_LINK_LIBRARIES(unetd unet ubox ${ubus} blobmsg_json ${libjson} ${nl} ${bpf} ${elf} ${zlib})
  42. ADD_EXECUTABLE(unet-tool cli.c)
  43. TARGET_LINK_LIBRARIES(unet-tool unet blobmsg_json ${libjson} ubox)
  44. ADD_EXECUTABLE(unet-dht dht.c udht.c ${DHT_SOURCES})
  45. TARGET_LINK_LIBRARIES(unet-dht unet ${ubus} ubox)
  46. INSTALL(TARGETS unetd unet unet-tool unet-dht
  47. RUNTIME DESTINATION sbin
  48. LIBRARY DESTINATION lib
  49. )