CMakeLists.txt 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. cmake_minimum_required(VERSION 2.6)
  2. PROJECT(netifd C)
  3. ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -Wmissing-declarations)
  4. SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
  5. IF(APPLE)
  6. INCLUDE_DIRECTORIES(/opt/local/include)
  7. LINK_DIRECTORIES(/opt/local/lib)
  8. ENDIF()
  9. SET(SOURCES
  10. main.c utils.c system.c tunnel.c
  11. interface.c interface-ip.c interface-event.c
  12. iprule.c proto.c proto-static.c proto-shell.c
  13. config.c device.c bridge.c vlan.c alias.c
  14. ubus.c)
  15. find_library(json NAMES json-c json)
  16. SET(LIBS
  17. ubox ubus uci ${json} blobmsg_json)
  18. IF (NOT DEFINED LIBNL_LIBS)
  19. FIND_LIBRARY(libnl NAMES libnl-3 libnl nl-3 nl)
  20. SET(LIBNL_LIBS ${libnl})
  21. ENDIF()
  22. IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux" AND NOT DUMMY_MODE)
  23. SET(SOURCES ${SOURCES} system-linux.c)
  24. SET(LIBS ${LIBS} ${LIBNL_LIBS})
  25. ELSE()
  26. ADD_DEFINITIONS(-DDUMMY_MODE=1)
  27. SET(SOURCES ${SOURCES} system-dummy.c)
  28. ENDIF()
  29. IF(DEBUG)
  30. ADD_DEFINITIONS(-DDEBUG -g3)
  31. IF(NO_OPTIMIZE)
  32. ADD_DEFINITIONS(-O0)
  33. ENDIF()
  34. ENDIF()
  35. ADD_EXECUTABLE(netifd ${SOURCES})
  36. TARGET_LINK_LIBRARIES(netifd ${LIBS})
  37. INSTALL(TARGETS netifd
  38. RUNTIME DESTINATION sbin
  39. )