modified check for readline and tinfo

- switched from CHECK_INCLUDE_FILE to CHECK_LIBRARY_EXISTS
	fixes detection issue of readline on archlinux due to
	missing imports (unknown type FILE)
- discovering tinfo using CHECK_LIBRARY_EXISTS
	the result is used in the discovery of readline as the same
	error as discussed in walterschell/Lua#32 prevented the
	detection of readline
This commit is contained in:
Clemens Jonischkeit 2024-04-27 12:21:48 +02:00
parent 81f47ed7e8
commit 8658373dd9

View File

@ -113,8 +113,12 @@ elseif(Win32)
endif() endif()
if(LUA_BUILD_BINARY) if(LUA_BUILD_BINARY)
include(CheckIncludeFile) include(CheckLibraryExists)
CHECK_INCLUDE_FILE("readline/readline.h" HAVE_READLINE_READLINE_H) CHECK_LIBRARY_EXISTS(tinfo tputs "" HAVE_LIBRARY_TINFO)
if (HAVE_LIBRARY_TINFO)
SET(CMAKE_REQUIRED_LIBRARIES tinfo)
endif()
CHECK_LIBRARY_EXISTS(readline readline "" HAVE_LIBRARY_READLINE)
add_executable(lua "src/lua.c") add_executable(lua "src/lua.c")
# Can not use lua_shared because some symbols are not exported # Can not use lua_shared because some symbols are not exported
@ -122,10 +126,12 @@ if(LUA_BUILD_BINARY)
set_target_properties(lua PROPERTIES set_target_properties(lua PROPERTIES
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
) )
if (HAVE_READLINE_READLINE_H) if (HAVE_LIBRARY_READLINE)
target_compile_definitions(lua PRIVATE "LUA_USE_READLINE") target_compile_definitions(lua PRIVATE "LUA_USE_READLINE")
target_link_libraries(lua PUBLIC readline) target_link_libraries(lua PUBLIC readline)
target_link_libraries(lua PUBLIC tinfo) if (HAVE_LIBRARY_TINFO)
target_link_libraries(lua PUBLIC tinfo)
endif()
endif() endif()
list(APPEND TARGETS_TO_INSTALL lua) list(APPEND TARGETS_TO_INSTALL lua)
endif() endif()