CMakeLists.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. include_directories(${CMAKE_CURRENT_BINARY_DIR})
  2. set(NCD_ADDITIONAL_SOURCES)
  3. if (BADVPN_USE_LINUX_RFKILL)
  4. list(APPEND NCD_ADDITIONAL_SOURCES
  5. NCDRfkillMonitor.c
  6. modules/net_backend_rfkill.c
  7. )
  8. endif ()
  9. if (BADVPN_USE_LINUX_INPUT)
  10. list(APPEND NCD_ADDITIONAL_SOURCES
  11. modules/sys_evdev.c
  12. )
  13. endif ()
  14. if (BADVPN_USE_INOTIFY)
  15. list(APPEND NCD_ADDITIONAL_SOURCES
  16. modules/sys_watch_directory.c
  17. )
  18. endif ()
  19. add_library(ncdconfig
  20. NCDConfig.c
  21. NCDConfigTokenizer.c
  22. NCDConfigParser.c
  23. )
  24. target_link_libraries(ncdconfig base)
  25. add_executable(badvpn-ncd
  26. ncd.c
  27. NCDValue.c
  28. NCDModule.c
  29. NCDIfConfig.c
  30. NCDInterfaceMonitor.c
  31. BEventLock.c
  32. modules/command_template.c
  33. modules/event_template.c
  34. modules/var.c
  35. modules/list.c
  36. modules/depend.c
  37. modules/multidepend.c
  38. modules/concat.c
  39. modules/concatv.c
  40. modules/concatlist.c
  41. modules/if.c
  42. modules/strcmp.c
  43. modules/regex_match.c
  44. modules/logical.c
  45. modules/sleep.c
  46. modules/print.c
  47. modules/blocker.c
  48. modules/ip_in_network.c
  49. modules/run.c
  50. modules/runonce.c
  51. modules/spawn.c
  52. modules/call.c
  53. modules/ref.c
  54. modules/index.c
  55. modules/alias.c
  56. modules/process_manager.c
  57. modules/net_backend_waitdevice.c
  58. modules/net_backend_waitlink.c
  59. modules/net_backend_badvpn.c
  60. modules/net_backend_wpa_supplicant.c
  61. modules/net_up.c
  62. modules/net_dns.c
  63. modules/net_iptables.c
  64. modules/net_ipv4_addr.c
  65. modules/net_ipv4_route.c
  66. modules/net_ipv4_dhcp.c
  67. modules/net_watch_interfaces.c
  68. modules/sys_watch_input.c
  69. ${NCD_ADDITIONAL_SOURCES}
  70. )
  71. target_link_libraries(badvpn-ncd system flow flowextra dhcpclient ncdconfig udevmonitor)
  72. if (BADVPN_USE_LINUX_INPUT)
  73. string(REPLACE " " ";" FLAGS_LIST "${CMAKE_C_FLAGS}")
  74. execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_LIST} -E ${CMAKE_CURRENT_SOURCE_DIR}/include_linux_input.h
  75. RESULT_VARIABLE LINUX_INPUT_PREPROCESS_RESULT
  76. OUTPUT_VARIABLE LINUX_INPUT_PREPROCESS_OUTPUT)
  77. if (NOT LINUX_INPUT_PREPROCESS_RESULT EQUAL 0)
  78. message(FATAL_ERROR "failed to preprocess linux/input.h include")
  79. endif ()
  80. string(REGEX MATCH "\"(/[^\"]+/linux/input.h)\"" LINUX_INPUT_MATCH ${LINUX_INPUT_PREPROCESS_OUTPUT})
  81. if (NOT LINUX_INPUT_MATCH)
  82. message(FATAL_ERROR "failed to match preprocessor output for path of linux/input.h")
  83. endif ()
  84. set(LINUX_INPUT_H_PATH ${CMAKE_MATCH_1})
  85. message(STATUS "Generating linux_input_names.h from ${LINUX_INPUT_H_PATH}")
  86. execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/parse_linux_input.sh
  87. ${LINUX_INPUT_H_PATH}
  88. ${CMAKE_CURRENT_BINARY_DIR}/linux_input_names.h
  89. RESULT_VARIABLE LINUX_INPUT_PARSE_RESULT)
  90. if (NOT LINUX_INPUT_PARSE_RESULT EQUAL 0)
  91. message(FATAL_ERROR "failed to generate linux_input_names.h")
  92. endif ()
  93. endif ()
  94. install(
  95. TARGETS badvpn-ncd
  96. RUNTIME DESTINATION bin
  97. )