add OS switch to select system library
authorSteven Barth <steven@midlink.org>
Thu, 22 Sep 2011 20:34:38 +0000 (20:34 +0000)
committerSteven Barth <steven@midlink.org>
Thu, 22 Sep 2011 20:34:38 +0000 (20:34 +0000)
CMakeLists.txt

index 6da39df2baf88402ebb7bc0d089f6f7dcda1e48e..de0c74b35829721d99d6bb6c10c420b9b07f29ef 100644 (file)
@@ -10,15 +10,26 @@ IF(APPLE)
   LINK_DIRECTORIES(/opt/local/lib)
 ENDIF()
 
+SET(SOURCES
+       main.c utils.c interface.c interface-ip.c
+       proto.c proto-static.c proto-shell.c
+       config.c device.c bridge.c vlan.c ubus.c)
+
+SET(LIBS
+       ubox ubus uci json blobmsg_json)
+
+IF("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
+       SET(SOURCES ${SOURCES} system-linux.c)
+       SET(LIBS ${LIBS} nl)
+ELSE()
+       SET(SOURCES ${SOURCES} system-dummy.c)
+ENDIF()
+
 IF(DEBUG)
   ADD_DEFINITIONS(-DDEBUG -O0 --std=gnu99 -g3)
 ENDIF()
 
 
-ADD_EXECUTABLE(netifd
-       main.c utils.c interface.c interface-ip.c
-       proto.c proto-static.c proto-shell.c
-       config.c device.c bridge.c vlan.c ubus.c
-       system-dummy.c)
+ADD_EXECUTABLE(netifd ${SOURCES})
 
-TARGET_LINK_LIBRARIES(netifd ubox ubus uci json blobmsg_json)
+TARGET_LINK_LIBRARIES(netifd ${LIBS})