cmake: Add proper library and include files search logic for dependecies
authorPetr Štetiar <ynezz@true.cz>
Wed, 27 Jul 2016 12:45:48 +0000 (14:45 +0200)
committerJohn Crispin <john@phrozen.org>
Sun, 24 Jul 2016 04:12:17 +0000 (06:12 +0200)
Signed-off-by: Petr Štetiar <ynezz@true.cz>
CMakeLists.txt

index 326e649fcdcc7124c90220225dcf133bf5d09045..7fe7a165e56d8f2b56e02426843351af906cee59 100644 (file)
@@ -7,15 +7,19 @@ SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
 
 SET(SOURCES main.c nmea)
 
-SET(LIBS ubox ubus)
-
 IF(DEBUG)
   ADD_DEFINITIONS(-DDEBUG -g3)
 ENDIF()
 
+FIND_LIBRARY(ubus NAMES ubus)
+FIND_LIBRARY(ubox NAMES ubox)
+FIND_PATH(ubus_include_dir NAMES libubus.h)
+FIND_PATH(ubox_include_dir NAMES libubox/usock.h)
+INCLUDE_DIRECTORIES(${ubox_include_dir} ${ubus_include_dir})
+
 ADD_EXECUTABLE(ugps ${SOURCES})
 
-TARGET_LINK_LIBRARIES(ugps ${LIBS})
+TARGET_LINK_LIBRARIES(ugps ${ubox} ${ubus})
 
 INSTALL(TARGETS ugps
        RUNTIME DESTINATION sbin