cmake: Allow building without Luajit

By default Neovim searched a Luajit instalation and linked against
the luajit library.

In practice Neovim only requires luajit to run the unit tests. All other
targets only require lua and the correct lua modules. This commit:

1. Remove the strict dependency on Luajit
2. Makes the unittest target depend on the lua 'ffi' module.
   If the module is not available the target is not enabled
   and a message is displayed.
This commit is contained in:
Rui Abreu Ferreira
2016-05-08 03:06:46 +01:00
parent 509089d053
commit d5c89b1896
3 changed files with 20 additions and 18 deletions

View File

@@ -300,9 +300,6 @@ include_directories(SYSTEM ${LIBUV_INCLUDE_DIRS})
find_package(Msgpack 1.0.0 REQUIRED) find_package(Msgpack 1.0.0 REQUIRED)
include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS}) include_directories(SYSTEM ${MSGPACK_INCLUDE_DIRS})
find_package(LuaJit REQUIRED)
include_directories(SYSTEM ${LUAJIT_INCLUDE_DIRS})
find_package(Unibilium REQUIRED) find_package(Unibilium REQUIRED)
include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS}) include_directories(SYSTEM ${UNIBILIUM_INCLUDE_DIRS})
@@ -477,18 +474,24 @@ if(BUSTED_PRG)
add_custom_target(benchmark-prereqs add_custom_target(benchmark-prereqs
DEPENDS ${BENCHMARK_PREREQS}) DEPENDS ${BENCHMARK_PREREQS})
add_custom_target(unittest check_lua_module(${LUA_PRG} "ffi" LUA_HAS_FFI)
COMMAND ${CMAKE_COMMAND} if(LUA_HAS_FFI)
-DBUSTED_PRG=${BUSTED_PRG} add_custom_target(unittest
-DLUA_PRG=${LUA_PRG} COMMAND ${CMAKE_COMMAND}
-DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR} -DBUSTED_PRG=${BUSTED_PRG}
-DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE} -DLUA_PRG=${LUA_PRG}
-DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test -DWORKING_DIR=${CMAKE_CURRENT_SOURCE_DIR}
-DBUILD_DIR=${CMAKE_BINARY_DIR} -DBUSTED_OUTPUT_TYPE=${BUSTED_OUTPUT_TYPE}
-DTEST_TYPE=unit -DTEST_DIR=${CMAKE_CURRENT_SOURCE_DIR}/test
-P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake -DBUILD_DIR=${CMAKE_BINARY_DIR}
DEPENDS ${UNITTEST_PREREQS} -DTEST_TYPE=unit
${TEST_TARGET_ARGS}) -P ${PROJECT_SOURCE_DIR}/cmake/RunTests.cmake
DEPENDS ${UNITTEST_PREREQS}
${TEST_TARGET_ARGS})
else()
message(WARNING "The Luajit ffi is not available in ${LUA_PRG}"
", disabling unit tests")
endif()
add_custom_target(functionaltest add_custom_target(functionaltest
COMMAND ${CMAKE_COMMAND} COMMAND ${CMAKE_COMMAND}

View File

@@ -8,8 +8,6 @@ function(check_lua_module LUA_PRG_PATH MODULE RESULT_VAR)
RESULT_VARIABLE module_missing RESULT_VARIABLE module_missing
ERROR_QUIET) ERROR_QUIET)
if(module_missing) if(module_missing)
message(STATUS
"[${LUA_PRG_PATH}] The '${MODULE}' lua package is required for building Neovim")
set(${RESULT_VAR} False PARENT_SCOPE) set(${RESULT_VAR} False PARENT_SCOPE)
else() else()
set(${RESULT_VAR} True PARENT_SCOPE) set(${RESULT_VAR} True PARENT_SCOPE)
@@ -29,6 +27,8 @@ function(check_lua_deps LUA_PRG_PATH MODULES RESULT_VAR)
foreach(module ${MODULES}) foreach(module ${MODULES})
check_lua_module(${LUA_PRG_PATH} ${module} has_module) check_lua_module(${LUA_PRG_PATH} ${module} has_module)
if(NOT has_module) if(NOT has_module)
message(STATUS
"[${LUA_PRG_PATH}] The '${module}' lua package is required for building Neovim")
set(${RESULT_VAR} False PARENT_SCOPE) set(${RESULT_VAR} False PARENT_SCOPE)
return() return()
endif() endif()

View File

@@ -231,7 +231,6 @@ endif()
list(APPEND NVIM_LINK_LIBRARIES list(APPEND NVIM_LINK_LIBRARIES
${LIBUV_LIBRARIES} ${LIBUV_LIBRARIES}
${MSGPACK_LIBRARIES} ${MSGPACK_LIBRARIES}
${LUAJIT_LIBRARIES}
${LIBVTERM_LIBRARIES} ${LIBVTERM_LIBRARIES}
${LIBTERMKEY_LIBRARIES} ${LIBTERMKEY_LIBRARIES}
${UNIBILIUM_LIBRARIES} ${UNIBILIUM_LIBRARIES}