4 set(LUA_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lua/src)
6 # the following two variables are defined for the use of packages
7 # that wish to link or compile against lua
8 set (LUA_INCLUDE_DIRS "${LUA_SRC_DIR}")
9 set (LUA_LIBRARIES lua)
12 macro(add_prefix _list _prefix)
14 foreach(_current ${${_list}})
15 set(_tmp ${_tmp} ${_prefix}/${_current})
16 #message( ${_prefix}/${_current})
22 # define the lua core source files
23 set (LUA_CORE_SRCS lapi.c lcode.c ldebug.c ldo.c ldump.c
24 lfunc.c lgc.c llex.c lmem.c lobject.c lopcodes.c
25 lparser.c lstate.c lstring.c ltable.c ltm.c lundump.c
27 add_prefix(LUA_CORE_SRCS ${LUA_SRC_DIR}/)
29 # define the lua lib source files
30 set (LUA_LIB_SRCS lauxlib.c lbaselib.c ldblib.c liolib.c
31 lmathlib.c loslib.c ltablib.c lstrlib.c loadlib.c linit.c)
32 add_prefix(LUA_LIB_SRCS ${LUA_SRC_DIR}/)
36 add_definitions(-DLUA_BUILD_AS_DLL)
38 add_definitions(-D_CRT_SECURE_NO_DEPRECATE)
41 add_definitions(-DLUA_USE_LINUX)
43 set(LIBRARY_TYPE SHARED)
45 add_library (lua ${LIBRARY_TYPE} ${LUA_LIB_SRCS} ${LUA_CORE_SRCS})
48 target_link_libraries (lua m dl readline history ncurses)
51 # create the lue executable and link it to the lib
52 add_executable (luaexec ${LUA_SRC_DIR}/lua.c)
53 target_link_libraries (luaexec lua)
55 # name the executable lua just like the library
56 set_target_properties(luaexec PROPERTIES OUTPUT_NAME lua)
58 # create the luac thing (I have no clue) and link it
59 #add_executable (luac ${LUA_SRC_DIR}/luac.c ${LUA_SRC_DIR}/print.c)
60 #target_link_libraries (luac lua)