Merge remote-tracking branch 'rocka/patch/lua-libraires-cmake-config' into landing/pr-18-correct-lua-libraries

This commit is contained in:
Walter Schell 2023-06-24 21:49:38 -04:00
commit a7bfd709da
2 changed files with 22 additions and 6 deletions

View File

@ -35,6 +35,8 @@ set(LUA_LIB_SRCS
set(TARGETS_TO_INSTALL lua_internal lua_include)
set(LUA_LINKED_LIBRARIES)
if(LUA_BUILD_AS_CXX)
set_source_files_properties(${LUA_LIB_SRCS} "src/lua.c" "src/luac.c" PROPERTIES LANGUAGE CXX )
endif()
@ -87,14 +89,17 @@ if(UNIX)
if(NOT LIBM)
message(FATAL_ERROR "libm not found and is required by lua")
endif()
target_compile_definitions(lua_internal INTERFACE "LUA_USE_POSIX")
target_link_libraries(lua_internal INTERFACE m)
target_compile_definitions(lua_internal
INTERFACE LUA_USE_POSIX
)
list(APPEND LUA_LINKED_LIBRARIES m)
if(LUA_SUPPORT_DL)
find_library(LIBDL "${CMAKE_DL_LIBS}")
if(NOT LIBDL)
message(FATAL_ERROR "libdl not found and is required by lua")
endif()
target_compile_definitions(lua_internal INTERFACE "LUA_USE_DLOPEN")
target_link_libraries(lua_internal INTERFACE dl)
target_link_libraries(lua_internal INTERFACE "${CMAKE_DL_LIBS}")
list(APPEND LUA_LINKED_LIBRARIES "${CMAKE_DL_LIBS}")
endif()
endif()

View File

@ -4,6 +4,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/LuaTargets.cmake")
set_and_check(LUA_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
add_library(Lua::Library ALIAS "Lua::@LUA_EXPORT_LIBRARY@")
set(LUA_LIBRARIES "Lua::Library")
get_target_property(LUA_CONFIG "Lua::@LUA_EXPORT_LIBRARY@" IMPORTED_CONFIGURATIONS)
get_target_property(LUA_LIBRARY "Lua::@LUA_EXPORT_LIBRARY@" "IMPORTED_LOCATION_${LUA_CONFIG}")
set(LUA_LIBRARIES "${LUA_LIBRARY}")
foreach(LIB_NAME @LUA_LINKED_LIBRARIES@)
find_library(LIB_LOCATION "${LIB_NAME}")
if(NOT LIB_LOCATION)
message(FATAL_ERROR "lib${LIB_NAME} not found and is required by lua")
else()
list(APPEND LUA_LIBRARIES "${LIB_LOCATION}")
endif()
endforeach()
check_required_components(Lua)