mirror of
https://github.com/walterschell/Lua.git
synced 2024-11-22 05:04:35 +00:00
Merge pull request #14 from rocka/feat/install-cmake-config
Add CMake package config files
This commit is contained in:
commit
72f4dbf7ce
@ -38,8 +38,14 @@ if(LUA_BUILD_AS_CXX)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_library(lua_static STATIC ${LUA_LIB_SRCS})
|
add_library(lua_static STATIC ${LUA_LIB_SRCS})
|
||||||
set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua")
|
set_target_properties(lua_static PROPERTIES
|
||||||
target_include_directories(lua_static PUBLIC "include")
|
OUTPUT_NAME "lua"
|
||||||
|
VERSION "${PACKAGE_VERSION}"
|
||||||
|
)
|
||||||
|
target_include_directories(lua_static PUBLIC
|
||||||
|
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
|
||||||
|
$<INSTALL_INTERFACE:include>
|
||||||
|
)
|
||||||
if(UNIX)
|
if(UNIX)
|
||||||
set(LUA_DEFINITIONS)
|
set(LUA_DEFINITIONS)
|
||||||
|
|
||||||
@ -49,7 +55,7 @@ if(UNIX)
|
|||||||
if(NOT LIBM)
|
if(NOT LIBM)
|
||||||
message(FATAL_ERROR "libm not found and is required by lua")
|
message(FATAL_ERROR "libm not found and is required by lua")
|
||||||
endif()
|
endif()
|
||||||
target_link_libraries(lua_static INTERFACE ${LIBM})
|
target_link_libraries(lua_static INTERFACE m)
|
||||||
|
|
||||||
list(APPEND LUA_DEFINITIONS LUA_USE_POSIX)
|
list(APPEND LUA_DEFINITIONS LUA_USE_POSIX)
|
||||||
if(LUA_SUPPORT_DL)
|
if(LUA_SUPPORT_DL)
|
||||||
@ -81,6 +87,7 @@ if(LUA_BUILD_BINARY)
|
|||||||
target_link_libraries(lua PUBLIC readline)
|
target_link_libraries(lua PUBLIC readline)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
if(LUA_BUILD_COMPILER)
|
if(LUA_BUILD_COMPILER)
|
||||||
add_executable(luac "src/luac.c")
|
add_executable(luac "src/luac.c")
|
||||||
target_link_libraries(luac PUBLIC lua_static)
|
target_link_libraries(luac PUBLIC lua_static)
|
||||||
@ -88,3 +95,35 @@ if(LUA_BUILD_COMPILER)
|
|||||||
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
|
RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}
|
||||||
)
|
)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
install(TARGETS lua_static
|
||||||
|
EXPORT LuaTargets
|
||||||
|
ARCHIVE DESTINATION lib
|
||||||
|
PUBLIC_HEADER DESTINATION include
|
||||||
|
)
|
||||||
|
|
||||||
|
install(DIRECTORY include/ TYPE INCLUDE)
|
||||||
|
|
||||||
|
include(CMakePackageConfigHelpers)
|
||||||
|
|
||||||
|
write_basic_package_version_file(
|
||||||
|
LuaConfigVersion.cmake
|
||||||
|
VERSION ${PACKAGE_VERSION}
|
||||||
|
COMPATIBILITY SameMajorVersion
|
||||||
|
)
|
||||||
|
|
||||||
|
install(EXPORT LuaTargets
|
||||||
|
FILE LuaTargets.cmake
|
||||||
|
DESTINATION "lib/cmake"
|
||||||
|
)
|
||||||
|
|
||||||
|
configure_package_config_file(
|
||||||
|
LuaConfig.cmake.in
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LuaConfig.cmake"
|
||||||
|
INSTALL_DESTINATION "lib/cmake"
|
||||||
|
)
|
||||||
|
|
||||||
|
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LuaConfig.cmake"
|
||||||
|
"${CMAKE_CURRENT_BINARY_DIR}/LuaConfigVersion.cmake"
|
||||||
|
DESTINATION "lib/cmake"
|
||||||
|
)
|
||||||
|
10
lua-5.4.4/LuaConfig.cmake.in
Normal file
10
lua-5.4.4/LuaConfig.cmake.in
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
@PACKAGE_INIT@
|
||||||
|
|
||||||
|
include("${CMAKE_CURRENT_LIST_DIR}/LuaTargets.cmake")
|
||||||
|
|
||||||
|
set_and_check(LUA_INCLUDE_DIR "${PACKAGE_PREFIX_DIR}/include")
|
||||||
|
set_and_check(LUA_LIBRARY "${PACKAGE_PREFIX_DIR}/lib/liblua.a")
|
||||||
|
set(LUA_LIBRARIES "${LUA_LIBRARY}")
|
||||||
|
add_library(Lua::Library ALIAS lua_static)
|
||||||
|
|
||||||
|
check_required_components(Lua)
|
Loading…
Reference in New Issue
Block a user