ubus: use network order in ubus message header fields
[project/ubus.git] / lua / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(ubus C)
4
5 SET(CMAKE_INSTALL_PREFIX /)
6
7 IF(NOT LUA_CFLAGS)
8         FIND_PROGRAM(PKG_CONFIG pkg-config)
9         IF(PKG_CONFIG)
10                 EXECUTE_PROCESS(
11                         COMMAND pkg-config --silence-errors --cflags lua5.1
12                         OUTPUT_VARIABLE LUA_CFLAGS
13                         OUTPUT_STRIP_TRAILING_WHITESPACE
14                 )
15         ENDIF()
16 ENDIF()
17
18 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3 -I.. ${LUA_CFLAGS})
19 INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
20 LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
21
22 IF(APPLE)
23         SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
24 ENDIF(APPLE)
25
26 IF(NOT LUAPATH)
27         EXECUTE_PROCESS(
28                 COMMAND  lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
29                 OUTPUT_VARIABLE LUAPATH
30                 RESULT_VARIABLE LUA_CHECK_RES
31                 OUTPUT_STRIP_TRAILING_WHITESPACE
32         )
33
34         IF(BUILD_LUA)
35                 IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR "${LUAPATH}" EQUAL "")
36                         MESSAGE(SEND_ERROR "Lua was not found on your system")
37                 ENDIF()
38         ENDIF()
39 ENDIF()
40
41 IF(BUILD_LUA)
42         ADD_LIBRARY(ubus_lua MODULE ubus.c)
43         SET_TARGET_PROPERTIES(ubus_lua PROPERTIES
44                 OUTPUT_NAME ubus
45                 PREFIX ""
46         )
47         TARGET_LINK_LIBRARIES(ubus_lua ubus)
48
49         INSTALL(TARGETS ubus_lua
50                 LIBRARY DESTINATION ${LUAPATH}
51         )
52 ENDIF()