1 cmake_minimum_required(VERSION 2.6)
4 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
8 SET(sed_match "^[[:space:]]*__ipt_module(\\(.*\\)).*")
9 SET(sed_replace "-Wl,--undefined=libxt_\\1_init -Wl,--undefined=libipt_\\1_init -Wl,--undefined=libip6t_\\1_init")
11 EXECUTE_PROCESS(COMMAND sed -n -e "s/${sed_match}/${sed_replace}/; T n; H; :n; \${ x; s/^\\n//; s/\\n/ /gp }" ${CMAKE_SOURCE_DIR}/iptables.h
12 OUTPUT_VARIABLE ext_syms OUTPUT_STRIP_TRAILING_WHITESPACE)
14 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
15 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unresolved-symbols=ignore-all ${ext_syms}")
17 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext.a")
18 ADD_LIBRARY(ext STATIC IMPORTED)
19 SET_PROPERTY(TARGET ext PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libext.a)
20 LIST(APPEND ext_libs ext)
23 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext4.a")
24 ADD_LIBRARY(ext4 STATIC IMPORTED)
25 SET_PROPERTY(TARGET ext4 PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/libext4.a")
26 LIST(APPEND ext_libs ext4)
30 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext6.a")
31 ADD_LIBRARY(ext6 STATIC IMPORTED)
32 SET_PROPERTY(TARGET ext6 PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/libext6.a")
33 LIST(APPEND ext_libs ext6)
35 LIST(APPEND iptc_libs ip6tc)
37 ADD_DEFINITIONS(-DDISABLE_IPV6)
40 ADD_EXECUTABLE(firewall3 main.c options.c defaults.c zones.c forwards.c rules.c redirects.c snats.c utils.c ubus.c ipsets.c includes.c iptables.c)
41 TARGET_LINK_LIBRARIES(firewall3 uci ubox ubus xtables m dl ${iptc_libs} ${ext_libs})
43 SET(CMAKE_INSTALL_PREFIX /usr)
45 INSTALL(TARGETS firewall3 RUNTIME DESTINATION sbin)