Use cmake to find a lua executable

A lua executable is now required for the build process since a lpeg-based script
is used for generating a dispatch function and metadata for the msgpack API
frontend. This removes the need for setting the LUA_BINARY environment variable.
Fixes #518.
This commit is contained in:
Thiago de Arruda 2014-04-12 17:34:56 -03:00
parent a1dd6a6dd8
commit 3ee5683a78
2 changed files with 14 additions and 8 deletions

View File

@ -68,12 +68,24 @@ endif(NOT CMAKE_USE_PTHREADS_INIT)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
find_program(LUA_PRG luajit)
# Need a lua interpreter for running the msgapck metadata/dispatch generator
if(NOT EXISTS ${LUA_PRG})
find_program(LUA_PRG lua)
endif()
if(EXISTS ${LUA_PRG})
message(STATUS "Using the lua interpreter ${LUA_PRG}")
else()
message(FATAL_ERROR "A lua interpreter is required for building the Neovim")
endif()
add_subdirectory(config) add_subdirectory(config)
add_subdirectory(src) add_subdirectory(src)
add_subdirectory(test/includes) add_subdirectory(test/includes)
find_program(BUSTED_PRG busted) find_program(BUSTED_PRG busted)
find_program(LUAJIT_PRG luajit)
find_program(MAKE_PRG NAMES gmake make) find_program(MAKE_PRG NAMES gmake make)
if(MAKE_PRG) if(MAKE_PRG)

View File

@ -1,11 +1,5 @@
include(CheckLibraryExists) include(CheckLibraryExists)
if(DEFINED ENV{LUA_BINARY})
set(LUA_BIN $ENV{LUA_BINARY})
else()
set(LUA_BIN ${DEPS_BIN_DIR}/luajit)
endif()
set(GENERATED_DIR ${PROJECT_BINARY_DIR}/src/auto) set(GENERATED_DIR ${PROJECT_BINARY_DIR}/src/auto)
set(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/msgpack-gen.lua) set(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/msgpack-gen.lua)
set(API_HEADER ${PROJECT_SOURCE_DIR}/src/api.h) set(API_HEADER ${PROJECT_SOURCE_DIR}/src/api.h)
@ -15,7 +9,7 @@ set(MSGPACK_DISPATCH ${GENERATED_DIR}/msgpack_dispatch.c)
file(MAKE_DIRECTORY ${GENERATED_DIR}) file(MAKE_DIRECTORY ${GENERATED_DIR})
add_custom_command(OUTPUT ${MSGPACK_DISPATCH} add_custom_command(OUTPUT ${MSGPACK_DISPATCH}
COMMAND ${LUA_BIN} ${DISPATCH_GENERATOR} ${API_HEADER} ${MSGPACK_DISPATCH} COMMAND ${LUA_PRG} ${DISPATCH_GENERATOR} ${API_HEADER} ${MSGPACK_DISPATCH}
DEPENDS DEPENDS
${API_HEADER} ${API_HEADER}
${MSGPACK_RPC_HEADER} ${MSGPACK_RPC_HEADER}