firewall3: fix left shift on 64 bit systems in fw3_bitlen2netmask
[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(iptc_libs   ip4tc)
7
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")
10
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)
13
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}")
16
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)
21 ENDIF()
22
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)
27 ENDIF()
28
29 IF (NOT DISABLE_IPV6)
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)
34   ENDIF()
35   LIST(APPEND iptc_libs ip6tc)
36 ELSE()
37   ADD_DEFINITIONS(-DDISABLE_IPV6)
38 ENDIF()
39
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})
42
43 SET(CMAKE_INSTALL_PREFIX /usr)
44
45 INSTALL(TARGETS firewall3 RUNTIME DESTINATION sbin)