include_directories(${CMAKE_CURRENT_BINARY_DIR}) set(NCD_ADDITIONAL_SOURCES) if (BADVPN_USE_LINUX_RFKILL) list(APPEND NCD_ADDITIONAL_SOURCES NCDRfkillMonitor.c modules/net_backend_rfkill.c ) endif () if (BADVPN_USE_LINUX_INPUT) list(APPEND NCD_ADDITIONAL_SOURCES modules/sys_evdev.c ) endif () if (BADVPN_USE_INOTIFY) list(APPEND NCD_ADDITIONAL_SOURCES modules/sys_watch_directory.c ) endif () add_library(ncdtokenizer NCDConfigTokenizer.c ) target_link_libraries(ncdtokenizer base) add_library(ncdval NCDVal.c ) target_link_libraries(ncdval base) add_library(ncdvalgenerator NCDValGenerator.c ) target_link_libraries(ncdvalgenerator base ncdval) add_library(ncdvalparser NCDValParser.c ) target_link_libraries(ncdvalparser base ncdval ncdtokenizer ncdvalcons) add_library(ncdast NCDAst.c ) add_library(ncdconfigparser NCDConfigParser.c ) target_link_libraries(ncdconfigparser base ncdtokenizer ncdast) add_library(ncdsugar NCDSugar.c ) target_link_libraries(ncdsugar ncdast) add_library(ncdrequest NCDRequestClient.c ) target_link_libraries(ncdrequest base system ncdvalgenerator ncdvalparser) add_library(ncdinterfacemonitor NCDInterfaceMonitor.c ) target_link_libraries(ncdinterfacemonitor base system) add_library(ncdvalcons NCDValCons.c ) target_link_libraries(ncdvalcons ncdval) add_executable(badvpn-ncd ncd.c NCDModule.c NCDModuleIndex.c NCDIfConfig.c NCDObject.c NCDInterpProcess.c NCDInterpProg.c NCDPlaceholderDb.c NCDMethodIndex.c BEventLock.c modules/command_template.c modules/event_template.c modules/var.c modules/list.c modules/depend.c modules/multidepend.c modules/dynamic_depend.c modules/concat.c modules/concatv.c modules/if.c modules/strcmp.c modules/regex_match.c modules/logical.c modules/sleep.c modules/print.c modules/blocker.c modules/run.c modules/runonce.c modules/daemon.c modules/spawn.c modules/call.c modules/imperative.c modules/ref.c modules/index.c modules/alias.c modules/process_manager.c modules/ondemand.c modules/foreach.c modules/choose.c modules/from_string.c modules/to_string.c modules/value.c modules/try.c modules/net_backend_waitdevice.c modules/net_backend_waitlink.c modules/net_backend_badvpn.c modules/net_backend_wpa_supplicant.c modules/net_up.c modules/net_dns.c modules/net_iptables.c modules/net_ipv4_addr.c modules/net_ipv4_route.c modules/net_ipv4_dhcp.c modules/net_ipv4_arp_probe.c modules/net_watch_interfaces.c modules/sys_watch_input.c modules/sys_watch_usb.c modules/sys_request_server.c modules/net_ipv6_wait_dynamic_addr.c modules/sys_request_client.c modules/exit.c modules/getargs.c modules/arithmetic.c modules/parse.c modules/valuemetic.c modules/file.c modules/netmask.c modules/implode.c modules/call2.c modules/assert.c modules/reboot.c modules/explode.c modules/net_ipv6_addr.c modules/net_ipv6_route.c modules/net_ipv4_addr_in_network.c modules/net_ipv6_addr_in_network.c ${NCD_ADDITIONAL_SOURCES} ) target_link_libraries(badvpn-ncd system flow flowextra dhcpclient arpprobe ncdval ncdvalgenerator ncdvalparser ncdconfigparser ncdsugar udevmonitor ncdinterfacemonitor ncdrequest badvpn_random ) if (BADVPN_USE_LINUX_INPUT) string(REPLACE " " ";" FLAGS_LIST "${CMAKE_C_FLAGS}") execute_process(COMMAND ${CMAKE_C_COMPILER} ${FLAGS_LIST} -E ${CMAKE_CURRENT_SOURCE_DIR}/include_linux_input.c RESULT_VARIABLE LINUX_INPUT_PREPROCESS_RESULT OUTPUT_VARIABLE LINUX_INPUT_PREPROCESS_OUTPUT) if (NOT LINUX_INPUT_PREPROCESS_RESULT EQUAL 0) message(FATAL_ERROR "failed to preprocess linux/input.h include") endif () string(REGEX MATCH "\"(/[^\"]+/linux/input.h)\"" LINUX_INPUT_MATCH ${LINUX_INPUT_PREPROCESS_OUTPUT}) if (NOT LINUX_INPUT_MATCH) message(FATAL_ERROR "failed to match preprocessor output for path of linux/input.h") endif () set(LINUX_INPUT_H_PATH ${CMAKE_MATCH_1}) message(STATUS "Generating linux_input_names.h from ${LINUX_INPUT_H_PATH}") execute_process(COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/parse_linux_input.sh ${LINUX_INPUT_H_PATH} ${CMAKE_CURRENT_BINARY_DIR}/linux_input_names.h RESULT_VARIABLE LINUX_INPUT_PARSE_RESULT) if (NOT LINUX_INPUT_PARSE_RESULT EQUAL 0) message(FATAL_ERROR "failed to generate linux_input_names.h") endif () endif () install( TARGETS badvpn-ncd RUNTIME DESTINATION bin )