view Resources/CMake/LuaConfiguration.cmake @ 382:b45bc565d82a lua-scripting

cmake for lua
author Sebastien Jodogne <s.jodogne@gmail.com>
date Mon, 29 Apr 2013 13:31:10 +0200
parents
children 18fe778eeb95
line wrap: on
line source

if (STATIC_BUILD OR NOT USE_DYNAMIC_LUA)
  SET(LUA_SOURCES_DIR ${CMAKE_BINARY_DIR}/lua-5.1.5)
  DownloadPackage("http://www.montefiore.ulg.ac.be/~jodogne/Orthanc/ThirdPartyDownloads/lua-5.1.5.tar.gz" "${LUA_SOURCES_DIR}" "" "")

  add_definitions(
    -DLUA_COMPAT_ALL=1  # Compile a generic version of Lua
    )

  include_directories(
    ${LUA_SOURCES_DIR}/src
    )

  set(LUA_SOURCES
    # Core Lua
    ${LUA_SOURCES_DIR}/src/lapi.c
    ${LUA_SOURCES_DIR}/src/lcode.c 
    ${LUA_SOURCES_DIR}/src/ldebug.c 
    ${LUA_SOURCES_DIR}/src/ldo.c 
    ${LUA_SOURCES_DIR}/src/ldump.c 
    ${LUA_SOURCES_DIR}/src/lfunc.c 
    ${LUA_SOURCES_DIR}/src/lgc.c
    ${LUA_SOURCES_DIR}/src/llex.c
    ${LUA_SOURCES_DIR}/src/lmem.c 
    ${LUA_SOURCES_DIR}/src/lobject.c 
    ${LUA_SOURCES_DIR}/src/lopcodes.c 
    ${LUA_SOURCES_DIR}/src/lparser.c
    ${LUA_SOURCES_DIR}/src/lstate.c 
    ${LUA_SOURCES_DIR}/src/lstring.c
    ${LUA_SOURCES_DIR}/src/ltable.c
    ${LUA_SOURCES_DIR}/src/ltm.c
    ${LUA_SOURCES_DIR}/src/lundump.c 
    ${LUA_SOURCES_DIR}/src/lvm.c 
    ${LUA_SOURCES_DIR}/src/lzio.c

    # Additional modules
    ${LUA_SOURCES_DIR}/src/lstrlib.c
    )

  add_library(Lua STATIC ${LUA_SOURCES})
  link_libraries(Lua)

  source_group(ThirdParty\\Lua REGULAR_EXPRESSION ${LUA_SOURCES_DIR}/.*)

else()
  CHECK_INCLUDE_FILE_CXX(lua.h HAVE_LUA_H)
  if (NOT HAVE_LUA_H)
    message(FATAL_ERROR "Please install the liblua-dev package")
  endif()

  CHECK_LIBRARY_EXISTS(lua "lua_pcall" HAVE_LUA_LIB)
  if (NOT HAVE_LUA_LIB)
    message(FATAL_ERROR "Please install the liblua-dev package")
  endif()

  link_libraries(lua)
endif()