lua: emit a proper deletion when setting an existing list to a new list with only...
[project/uci.git] / lua / CMakeLists.txt
1 cmake_minimum_required(VERSION 2.6)
2
3 PROJECT(uci 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 LINK_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/..)
20
21 IF(APPLE)
22   INCLUDE_DIRECTORIES(/opt/local/include)
23   LINK_DIRECTORIES(/opt/local/lib)
24 ENDIF()
25
26 IF(APPLE)
27         SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
28 ENDIF(APPLE)
29
30 IF(NOT LUAPATH)
31         EXECUTE_PROCESS(
32                 COMMAND  lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
33                 OUTPUT_VARIABLE LUAPATH
34                 RESULT_VARIABLE LUA_CHECK_RES
35                 OUTPUT_STRIP_TRAILING_WHITESPACE
36         )
37
38         IF(BUILD_LUA)
39                 IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR ${LUAPATH} EQUAL "")
40                         MESSAGE(SEND_ERROR "Lua was not found on your system")
41                 ENDIF()
42         ENDIF()
43 ENDIF()
44
45 IF(BUILD_LUA)
46         ADD_LIBRARY(uci_lua MODULE uci.c)
47         SET_TARGET_PROPERTIES(uci_lua PROPERTIES
48                 OUTPUT_NAME uci
49                 PREFIX ""
50         )
51         TARGET_LINK_LIBRARIES(uci_lua uci dl)
52
53         INSTALL(TARGETS uci_lua
54                 LIBRARY DESTINATION ${LUAPATH}
55         )
56 ENDIF()
57