CMakeLists.txt 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_library(ncdvalue
  26. NCDValue.c
  27. NCDValueParser.c
  28. NCDValueGenerator.c
  29. )
  30. target_link_libraries(ncdvalue ncdconfig)
  31. add_library(ncdrequest
  32. NCDRequestClient.c
  33. )
  34. target_link_libraries(ncdrequest base system ncdvalue)
  35. add_library(ncdinterfacemonitor
  36. NCDInterfaceMonitor.c
  37. )
  38. target_link_libraries(ncdinterfacemonitor base system)
  39. add_executable(badvpn-ncd
  40. ncd.c
  41. NCDModule.c
  42. NCDModuleIndex.c
  43. NCDIfConfig.c
  44. NCDObject.c
  45. BEventLock.c
  46. modules/command_template.c
  47. modules/event_template.c
  48. modules/var.c
  49. modules/list.c
  50. modules/depend.c
  51. modules/multidepend.c
  52. modules/dynamic_depend.c
  53. modules/concat.c
  54. modules/concatv.c
  55. modules/if.c
  56. modules/strcmp.c
  57. modules/regex_match.c
  58. modules/logical.c
  59. modules/sleep.c
  60. modules/print.c
  61. modules/blocker.c
  62. modules/ip_in_network.c
  63. modules/run.c
  64. modules/runonce.c
  65. modules/daemon.c
  66. modules/spawn.c
  67. modules/call.c
  68. modules/imperative.c
  69. modules/ref.c
  70. modules/index.c
  71. modules/alias.c
  72. modules/process_manager.c
  73. modules/ondemand.c
  74. modules/foreach.c
  75. modules/choose.c
  76. modules/from_string.c
  77. modules/to_string.c
  78. modules/value.c
  79. modules/try.c
  80. modules/net_backend_waitdevice.c
  81. modules/net_backend_waitlink.c
  82. modules/net_backend_badvpn.c
  83. modules/net_backend_wpa_supplicant.c
  84. modules/net_up.c
  85. modules/net_dns.c
  86. modules/net_iptables.c
  87. modules/net_ipv4_addr.c
  88. modules/net_ipv4_route.c
  89. modules/net_ipv4_dhcp.c
  90. modules/net_ipv4_arp_probe.c
  91. modules/net_watch_interfaces.c
  92. modules/sys_watch_input.c
  93. modules/sys_watch_usb.c
  94. modules/sys_request_server.c
  95. modules/net_ipv6_wait_dynamic_addr.c
  96. modules/sys_request_client.c
  97. modules/exit.c
  98. modules/getargs.c
  99. modules/arithmetic.c
  100. modules/parse.c
  101. modules/valuemetic.c
  102. ${NCD_ADDITIONAL_SOURCES}
  103. )
  104. target_link_libraries(badvpn-ncd system flow flowextra dhcpclient arpprobe ncdconfig ncdvalue udevmonitor ncdinterfacemonitor ncdrequest)
  105. if (BADVPN_USE_LINUX_INPUT)
  106. string(REPLACE " " ";" FLAGS_LIST "${CMAKE_C_FLAGS}")
  107. execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_LIST} -E ${CMAKE_CURRENT_SOURCE_DIR}/include_linux_input.h
  108. RESULT_VARIABLE LINUX_INPUT_PREPROCESS_RESULT
  109. OUTPUT_VARIABLE LINUX_INPUT_PREPROCESS_OUTPUT)
  110. if (NOT LINUX_INPUT_PREPROCESS_RESULT EQUAL 0)
  111. message(FATAL_ERROR "failed to preprocess linux/input.h include")
  112. endif ()
  113. string(REGEX MATCH "\"(/[^\"]+/linux/input.h)\"" LINUX_INPUT_MATCH ${LINUX_INPUT_PREPROCESS_OUTPUT})
  114. if (NOT LINUX_INPUT_MATCH)
  115. message(FATAL_ERROR "failed to match preprocessor output for path of linux/input.h")
  116. endif ()
  117. set(LINUX_INPUT_H_PATH ${CMAKE_MATCH_1})
  118. message(STATUS "Generating linux_input_names.h from ${LINUX_INPUT_H_PATH}")
  119. execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/parse_linux_input.sh
  120. ${LINUX_INPUT_H_PATH}
  121. ${CMAKE_CURRENT_BINARY_DIR}/linux_input_names.h
  122. RESULT_VARIABLE LINUX_INPUT_PARSE_RESULT)
  123. if (NOT LINUX_INPUT_PARSE_RESULT EQUAL 0)
  124. message(FATAL_ERROR "failed to generate linux_input_names.h")
  125. endif ()
  126. endif ()
  127. install(
  128. TARGETS badvpn-ncd
  129. RUNTIME DESTINATION bin
  130. )