533317aa08d18510d245da03c2e0ad122de0e907
[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 ADD_DEFINITIONS(-Os -Wall -Werror --std=gnu99 -g3)
8
9 IF(APPLE)
10 SET(CMAKE_SHARED_MODULE_CREATE_C_FLAGS "${CMAKE_SHARED_MODULE_CREATE_C_FLAGS} -undefined dynamic_lookup")
11 ENDIF(APPLE)
12
13 IF(NOT LUAPATH)
14 EXECUTE_PROCESS(
15 COMMAND lua -e "for k in string.gmatch(package.cpath .. \";\", \"([^;]+)/..so;\") do if k:sub(1,1) == \"/\" then print(k) break end end"
16 OUTPUT_VARIABLE LUAPATH
17 RESULT_VARIABLE LUA_CHECK_RES
18 OUTPUT_STRIP_TRAILING_WHITESPACE
19 )
20
21 IF(NOT ${LUA_CHECK_RES} EQUAL 0 OR ${LUAPATH} EQUAL "")
22 MESSAGE(SEND_ERROR "Lua was not found on your system")
23 ENDIF()
24 ENDIF()
25
26 ADD_LIBRARY(uci_lua MODULE uci.c)
27 SET_TARGET_PROPERTIES(uci_lua PROPERTIES
28 OUTPUT_NAME uci
29 PREFIX ""
30 )
31 TARGET_LINK_LIBRARIES(uci_lua uci dl)
32
33 INSTALL(TARGETS uci_lua
34 LIBRARY DESTINATION ${LUAPATH}
35 )