From 50c100526b4b8316a801dab3d556796a31db1ec8 Mon Sep 17 00:00:00 2001 From: Rocka Date: Fri, 11 Feb 2022 16:26:19 +0800 Subject: [PATCH] Add CMake package config files --- lua-5.4.4/CMakeLists.txt | 47 +++++++++++++++++++++++++++++++++--- lua-5.4.4/LuaConfig.cmake.in | 10 ++++++++ 2 files changed, 53 insertions(+), 4 deletions(-) create mode 100644 lua-5.4.4/LuaConfig.cmake.in diff --git a/lua-5.4.4/CMakeLists.txt b/lua-5.4.4/CMakeLists.txt index c9a2477..2170be0 100644 --- a/lua-5.4.4/CMakeLists.txt +++ b/lua-5.4.4/CMakeLists.txt @@ -38,8 +38,14 @@ if(LUA_BUILD_AS_CXX) endif() add_library(lua_static STATIC ${LUA_LIB_SRCS}) -set_target_properties(lua_static PROPERTIES OUTPUT_NAME "lua") -target_include_directories(lua_static PUBLIC "include") +set_target_properties(lua_static PROPERTIES + OUTPUT_NAME "lua" + VERSION "${PACKAGE_VERSION}" +) +target_include_directories(lua_static PUBLIC + $ + $ +) if(UNIX) set(LUA_DEFINITIONS) @@ -49,7 +55,7 @@ if(UNIX) if(NOT LIBM) message(FATAL_ERROR "libm not found and is required by lua") endif() - target_link_libraries(lua_static INTERFACE ${LIBM}) + target_link_libraries(lua_static INTERFACE m) list(APPEND LUA_DEFINITIONS LUA_USE_POSIX) if(LUA_SUPPORT_DL) @@ -81,10 +87,43 @@ if(LUA_BUILD_BINARY) target_link_libraries(lua PUBLIC readline) endif() endif() + if(LUA_BUILD_COMPILER) add_executable(luac "src/luac.c") target_link_libraries(luac PUBLIC lua_static) set_target_properties(luac PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR} ) -endif() \ No newline at end of file +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" +) diff --git a/lua-5.4.4/LuaConfig.cmake.in b/lua-5.4.4/LuaConfig.cmake.in new file mode 100644 index 0000000..d5f7ce5 --- /dev/null +++ b/lua-5.4.4/LuaConfig.cmake.in @@ -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)