Merge pull request #27 from walterschell/landing/pr-18-correct-lua-libraries

Landing/pr 18 correct lua libraries
This commit is contained in:
Walter Schell 2023-07-11 06:58:11 -04:00 committed by GitHub
commit ec129b7b0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 190 additions and 15 deletions

View File

@ -35,3 +35,18 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
## Test of installing as CXX doesn't really make sense
# - name: Configure Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
# - name: Build Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake --build build-pkg-test

View File

@ -35,3 +35,17 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
# - name: Configure Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: emcmake cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
# - name: Build Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake --build build-pkg-test

View File

@ -43,7 +43,24 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V
run: ctest -V
## Test of installing as CXX doesn't really make sense
# - name: Configure Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
# - name: Build Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake --build build-pkg-test

View File

@ -43,7 +43,22 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V
run: ctest -V
- name: Configure Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
- name: Build Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake --build build-pkg-test

View File

@ -43,7 +43,23 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V
run: ctest -V
## Test of installing as CXX doesn't really make sense
# - name: Configure Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
# - name: Build Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake --build build-pkg-test

View File

@ -43,7 +43,23 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V
run: ctest -V
- name: Configure Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
- name: Build Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake --build build-pkg-test

View File

@ -43,7 +43,23 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V -C $BUILD_TYPE
run: ctest -V -C $BUILD_TYPE
## Test of installing as CXX doesn't really make sense
# - name: Configure Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
# - name: Build Test of CMake Package
# working-directory: ${{github.workspace}}
# shell: bash
# run: cmake --build build-pkg-test

View File

@ -43,7 +43,22 @@ jobs:
# Execute the build. You can specify a specific target with "--target <NAME>"
run: cmake --build . --config $BUILD_TYPE
- name: Install
working-directory: ${{github.workspace}}/build
shell: bash
run: cmake --install . --prefix $GITHUB_WORKSPACE/sysroot
- name: Test
working-directory: ${{github.workspace}}/build
shell: bash
run: ctest -V -C $BUILD_TYPE
run: ctest -V -C $BUILD_TYPE
- name: Configure Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake -S $GITHUB_WORKSPACE/lua-config-package-tests -B build-pkg-test -DCMAKE_PREFIX_PATH=$GITHUB_WORKSPACE/sysroot
- name: Build Test of CMake Package
working-directory: ${{github.workspace}}
shell: bash
run: cmake --build build-pkg-test

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()
@ -150,17 +155,17 @@ write_basic_package_version_file(
install(EXPORT LuaTargets
FILE LuaTargets.cmake
DESTINATION "lib/cmake"
DESTINATION "share/cmake/Lua"
NAMESPACE Lua::
)
configure_package_config_file(
LuaConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/LuaConfig.cmake"
INSTALL_DESTINATION "lib/cmake"
INSTALL_DESTINATION "share/cmake/Lua"
)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/LuaConfig.cmake"
"${CMAKE_CURRENT_BINARY_DIR}/LuaConfigVersion.cmake"
DESTINATION "lib/cmake"
DESTINATION "share/cmake/Lua"
)

View File

@ -4,6 +4,20 @@ 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}")
add_library(LUA_INCLUDE_LIB INTERFACE)
target_include_directories(LUA_INCLUDE_LIB INTERFACE "${LUA_INCLUDE_DIR}")
list(APPEND LUA_LIBRARIES LUA_INCLUDE_LIB)
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)

View File

@ -0,0 +1,22 @@
cmake_minimum_required(VERSION 3.1)
project(lua-config-package-test C)
find_package(Lua REQUIRED CONFIG)
add_executable(lua-config-package-build-test-using-static-target "./lua-config-package-build-test.c")
target_link_libraries(lua-config-package-build-test-using-static-target Lua::lua_static)
add_executable(lua-config-package-build-test-using-shared-target "./lua-config-package-build-test.c")
target_link_libraries(lua-config-package-build-test-using-shared-target Lua::lua_shared)
add_executable(lua-config-package-build-test-using-variables "./lua-config-package-build-test.c")
target_link_libraries(lua-config-package-build-test-using-variables "${LUA_LIBRARIES}")
add_library(lua-lib-module-compatible-mode UNKNOWN IMPORTED "${LUA_LIBRARY}")
set_target_properties(lua-lib-module-compatible-mode PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}"
IMPORTED_LOCATION "${LUA_LIBRARY}")
target_link_libraries(lua-lib-module-compatible-mode INTERFACE "${LUA_LIBRARIES}")
add_executable(lua-config-package-build-test-using-module-compatible-mode "./lua-config-package-build-test.c")
target_link_libraries(lua-config-package-build-test-using-module-compatible-mode lua-lib-module-compatible-mode)

View File

@ -0,0 +1,10 @@
#include <lua.h>
#include <lauxlib.h>
#include <stdio.h>
int main()
{
lua_State *l = luaL_newstate();
double lversion = lua_version(l);
printf("Lua version is %f\n", lversion);
}