cmake_minimum_required (VERSION 2.6)

project (lua)

if(WIN32)
    add_definitions( -D_CRT_SECURE_NO_WARNINGS )
endif()

# 1. src/lua static src/library
# how to rename src/library name?

set(coresrc
    src/lapi.c
    src/lcode.c
    src/lctype.c
    src/ldebug.c
    src/ldo.c
    src/ldump.c
    src/lfunc.c
    src/lgc.c
    src/llex.c
    src/lmem.c
    src/lobject.c
    src/lopcodes.c
    src/lparser.c
    src/lstate.c
    src/lstring.c
    src/ltable.c
    src/ltm.c
    src/lundump.c
    src/lvm.c
    src/lzio.c
    )

set(libsrc
    src/lauxlib.c
    src/lbaselib.c
    src/lbitlib.c
    src/lcorolib.c
    src/ldblib.c
    src/liolib.c
    src/lmathlib.c
    src/loslib.c
    src/lstrlib.c
    src/ltablib.c
    src/lutf8lib.c
    src/loadlib.c
    src/linit.c
    )

add_library (lualib STATIC
    ${coresrc}
    ${libsrc}
    )

target_compile_definitions(lualib PRIVATE LUA_USE_POSIX)

if(UNIX)
    target_link_libraries( lualib m )
endif()

#set_target_properties(lualib PROPERTIES
#	    OUTPUT_NAME "lua") # rename the src/library output name

# 2. src/lua interpreter
#link_directories (${LUA_BINARY_DIR})
#add_executable (lua src/lua.c)
#target_link_libraries (lua src/lualib)
#if(UNIX)
#	    target_link_libraries( src/lua m )
#endif()

# 3. src/lua compiler
#link_directories (${LUA_BINARY_DIR})
#add_executable (luac src/luac.c)
#target_link_libraries (luac src/lualib)
#if(UNIX)
#
#endif()
