Add abstract fw3_xt_reset() implementation
[project/firewall3.git] / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(firewall3 C)
4 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -Wmissing-declarations)
5
6 SET(sed_match   "^[[:space:]]*__ipt_module(\\(.*\\)).*")
7 SET(sed_replace "-Wl,--undefined=libxt_\\1_init -Wl,--undefined=libipt_\\1_init -Wl,--undefined=libip6t_\\1_init")
8
9 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
10                 OUTPUT_VARIABLE ext_syms OUTPUT_STRIP_TRAILING_WHITESPACE)
11
12 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
13 SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--unresolved-symbols=ignore-all ${ext_syms}")
14
15 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext.a")
16   ADD_LIBRARY(ext STATIC IMPORTED)
17   SET_PROPERTY(TARGET ext PROPERTY IMPORTED_LOCATION ${CMAKE_SOURCE_DIR}/libext.a)
18   LIST(APPEND ext_libs ext)
19 ENDIF()
20
21 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext4.a")
22   ADD_LIBRARY(ext4 STATIC IMPORTED)
23   SET_PROPERTY(TARGET ext4 PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/libext4.a")
24   LIST(APPEND ext_libs ext4)
25 ENDIF()
26
27 IF (EXISTS "${CMAKE_SOURCE_DIR}/libext6.a")
28   ADD_LIBRARY(ext6 STATIC IMPORTED)
29   SET_PROPERTY(TARGET ext6 PROPERTY IMPORTED_LOCATION "${CMAKE_SOURCE_DIR}/libext6.a")
30   LIST(APPEND ext_libs ext6)
31 ENDIF()
32
33 ADD_EXECUTABLE(firewall3 main.c options.c defaults.c zones.c forwards.c rules.c redirects.c utils.c ubus.c ipsets.c includes.c iptables.c)
34 TARGET_LINK_LIBRARIES(firewall3 uci ubox ubus ip4tc ip6tc xtables m ${ext_libs})
35
36 SET(CMAKE_INSTALL_PREFIX /usr)
37
38 INSTALL(TARGETS firewall3 RUNTIME DESTINATION sbin)