1 cmake_minimum_required(VERSION 2.6)
5 OPTION(BUILD_STATIC OFF)
7 ADD_DEFINITIONS(-Os -ggdb -Wall -Werror --std=gnu99 -Wmissing-declarations -Wno-enum-conversion)
9 SET(CMAKE_SHARED_LIBRARY_LINK_C_FLAGS "")
11 SET(SOURCES main.c dev.c commands.c qmi-message.c)
13 FIND_PATH(ubox_include_dir libubox/usock.h)
14 FIND_PATH(blobmsg_json_include_dir libubox/blobmsg_json.h)
15 FIND_PATH(json_include_dir json-c/json.h json/json.h json.h)
16 INCLUDE_DIRECTORIES(${ubox_include_dir} ${blobmsg_json_include_dir} ${json_include_dir})
19 FIND_LIBRARY(json_library NAMES libjson.a libjson-c.a)
20 FIND_LIBRARY(blobmsg_json_library NAMES libblobmsg_json.a)
21 FIND_LIBRARY(ubox_library NAMES libubox.a)
23 FIND_LIBRARY(json_library NAMES json-c json)
24 FIND_LIBRARY(blobmsg_json_library NAMES blobmsg_json)
25 FIND_LIBRARY(ubox_library NAMES ubox)
28 SET(LIBS ${ubox_library} ${blobmsg_json_library} ${json_library})
31 ADD_DEFINITIONS(-DDEBUG_PACKET)
35 ADD_DEFINITIONS(-DDEBUG -g3)
40 FOREACH(service ctl dms nas pds wds wms wda)
42 OUTPUT ${CMAKE_SOURCE_DIR}/qmi-message-${service}.h
43 COMMAND ${CMAKE_SOURCE_DIR}/data/gen-header.pl ${service}_ ${CMAKE_SOURCE_DIR}/data/qmi-service-${service}.json > ${CMAKE_SOURCE_DIR}/qmi-message-${service}.h
44 DEPENDS ${CMAKE_SOURCE_DIR}/data/gen-header.pl ${CMAKE_SOURCE_DIR}/data/qmi-service-${service}.json ${CMAKE_SOURCE_DIR}/data/gen-common.pm
46 SET(service_headers ${service_headers} qmi-message-${service}.h)
48 OUTPUT ${CMAKE_SOURCE_DIR}/qmi-message-${service}.c
49 COMMAND ${CMAKE_SOURCE_DIR}/data/gen-code.pl ${service}_ ${CMAKE_SOURCE_DIR}/data/qmi-service-${service}.json > ${CMAKE_SOURCE_DIR}/qmi-message-${service}.c
50 DEPENDS ${CMAKE_SOURCE_DIR}/data/gen-code.pl ${CMAKE_SOURCE_DIR}/data/qmi-service-${service}.json ${CMAKE_SOURCE_DIR}/data/gen-common.pm
52 SET(service_sources ${service_sources} qmi-message-${service}.c)
53 set_property(SOURCE qmi-message-${service}.c PROPERTY COMPILE_FLAGS "-Wno-unused")
57 OUTPUT ${CMAKE_SOURCE_DIR}/qmi-errors.c
58 COMMAND ${CMAKE_SOURCE_DIR}/data/gen-error-list.pl ${CMAKE_SOURCE_DIR}/qmi-errors.h > ${CMAKE_SOURCE_DIR}/qmi-errors.c
59 DEPENDS ${CMAKE_SOURCE_DIR}/data/gen-error-list.pl ${CMAKE_SOURCE_DIR}/qmi-errors.h
61 ADD_CUSTOM_TARGET(gen-errors DEPENDS qmi-errors.c)
62 ADD_CUSTOM_TARGET(gen-headers DEPENDS ${service_headers})
64 ADD_EXECUTABLE(uqmi ${SOURCES} ${service_sources})
65 ADD_DEPENDENCIES(uqmi gen-headers gen-errors)
67 TARGET_LINK_LIBRARIES(uqmi ${LIBS})
70 RUNTIME DESTINATION sbin