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