From 3ee5683a78f8a667c2be68d8bc3b46ffc63e4646 Mon Sep 17 00:00:00 2001 From: Thiago de Arruda Date: Sat, 12 Apr 2014 17:34:56 -0300 Subject: [PATCH] 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. --- CMakeLists.txt | 14 +++++++++++++- src/CMakeLists.txt | 8 +------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 918687f9d4..b3ed0f8640 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -68,12 +68,24 @@ endif(NOT CMAKE_USE_PTHREADS_INIT) 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(src) add_subdirectory(test/includes) find_program(BUSTED_PRG busted) -find_program(LUAJIT_PRG luajit) find_program(MAKE_PRG NAMES gmake make) if(MAKE_PRG) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 8e38839e24..30d50bb8bc 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,11 +1,5 @@ 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(DISPATCH_GENERATOR ${PROJECT_SOURCE_DIR}/scripts/msgpack-gen.lua) 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}) 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 ${API_HEADER} ${MSGPACK_RPC_HEADER}