1 cmake_minimum_required(VERSION 2.6)
5 IF(NOT ${CMAKE_VERSION} LESS 3.0)
6 include(CheckCCompilerFlag)
7 check_c_compiler_flag(-Wimplicit-fallthrough HAS_IMPLICIT_FALLTHROUGH)
10 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-unused-parameter -Wno-unused-but-set-parameter)
11 IF(CMAKE_C_COMPILER_VERSION VERSION_GREATER 6)
12 add_definitions(-Wextra -Werror=implicit-function-declaration)
13 add_definitions(-Wformat -Werror=format-security -Werror=format-nonliteral)
16 IF(HAS_IMPLICIT_FALLTHROUGH)
17 ADD_DEFINITIONS(-Wimplicit-fallthrough)
20 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
23 main.c utils.c system.c tunnel.c handler.c
24 interface.c interface-ip.c interface-event.c
25 iprule.c proto.c proto-static.c proto-shell.c
26 config.c device.c bridge.c veth.c vlan.c alias.c
27 macvlan.c ubus.c vlandev.c wireless.c
31 FIND_LIBRARY(uci NAMES uci)
32 FIND_LIBRARY(ubox NAMES ubox)
33 FIND_LIBRARY(ubus NAMES ubus)
34 FIND_LIBRARY(json NAMES json-c json)
35 FIND_LIBRARY(blobmsg_json NAMES blobmsg_json)
37 SET(LIBS ${ubox} ${ubus} ${uci} ${json} ${blobmsg_json})
39 FIND_PATH(ubox_include_dir libubox/usock.h)
40 INCLUDE_DIRECTORIES(${ubox_include_dir})
42 IF (NOT DEFINED LIBNL_LIBS)
43 include(FindPkgConfig)
44 pkg_search_module(LIBNL libnl-3.0 libnl-3 libnl nl-3 nl)
46 include_directories(${LIBNL_INCLUDE_DIRS})
47 SET(LIBNL_LIBS ${LIBNL_LIBRARIES})
51 IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT DUMMY_MODE)
52 SET(SOURCES ${SOURCES} system-linux.c)
53 SET(LIBS ${LIBS} ${LIBNL_LIBS})
55 ADD_DEFINITIONS(-DDUMMY_MODE=1)
56 SET(SOURCES ${SOURCES} system-dummy.c)
60 ADD_DEFINITIONS(-DDEBUG -g3)
67 ADD_EXECUTABLE(netifd ${SOURCES})
69 TARGET_LINK_LIBRARIES(netifd ${LIBS})
71 INSTALL(TARGETS netifd
72 RUNTIME DESTINATION sbin