diff --git a/.github/workflows/build-emscripten-cxx.yml b/.github/workflows/build-emscripten-cxx.yml index 28bc761..5970ed2 100644 --- a/.github/workflows/build-emscripten-cxx.yml +++ b/.github/workflows/build-emscripten-cxx.yml @@ -35,3 +35,18 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file diff --git a/.github/workflows/build-emscripten.yml b/.github/workflows/build-emscripten.yml index aeade19..2f11154 100644 --- a/.github/workflows/build-emscripten.yml +++ b/.github/workflows/build-emscripten.yml @@ -35,3 +35,17 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file diff --git a/.github/workflows/build-linux-cxx.yml b/.github/workflows/build-linux-cxx.yml index 36d6e22..9dcd67d 100644 --- a/.github/workflows/build-linux-cxx.yml +++ b/.github/workflows/build-linux-cxx.yml @@ -43,7 +43,24 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/build-linux.yml b/.github/workflows/build-linux.yml index abe5748..a386fae 100644 --- a/.github/workflows/build-linux.yml +++ b/.github/workflows/build-linux.yml @@ -43,7 +43,22 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/build-osx-cxx.yml b/.github/workflows/build-osx-cxx.yml index f6869e6..89346fe 100644 --- a/.github/workflows/build-osx-cxx.yml +++ b/.github/workflows/build-osx-cxx.yml @@ -43,7 +43,23 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/build-osx.yml b/.github/workflows/build-osx.yml index 85d5a92..8afa097 100644 --- a/.github/workflows/build-osx.yml +++ b/.github/workflows/build-osx.yml @@ -43,7 +43,23 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/build-windows-cxx.yml b/.github/workflows/build-windows-cxx.yml index 34eb4b2..5c4e370 100644 --- a/.github/workflows/build-windows-cxx.yml +++ b/.github/workflows/build-windows-cxx.yml @@ -43,7 +43,23 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/.github/workflows/build-windows.yml b/.github/workflows/build-windows.yml index c16da98..5616ed2 100644 --- a/.github/workflows/build-windows.yml +++ b/.github/workflows/build-windows.yml @@ -43,7 +43,22 @@ jobs: # Execute the build. You can specify a specific target with "--target " 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 \ No newline at end of file + 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 \ No newline at end of file diff --git a/lua-5.4.5/CMakeLists.txt b/lua-5.4.5/CMakeLists.txt index dd36dbe..58cf579 100644 --- a/lua-5.4.5/CMakeLists.txt +++ b/lua-5.4.5/CMakeLists.txt @@ -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" ) diff --git a/lua-5.4.5/LuaConfig.cmake.in b/lua-5.4.5/LuaConfig.cmake.in index 8f32b2c..2361f38 100644 --- a/lua-5.4.5/LuaConfig.cmake.in +++ b/lua-5.4.5/LuaConfig.cmake.in @@ -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) diff --git a/lua-config-package-tests/CMakeLists.txt b/lua-config-package-tests/CMakeLists.txt new file mode 100644 index 0000000..e810d8b --- /dev/null +++ b/lua-config-package-tests/CMakeLists.txt @@ -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) diff --git a/lua-config-package-tests/lua-config-package-build-test.c b/lua-config-package-tests/lua-config-package-build-test.c new file mode 100644 index 0000000..c4109a2 --- /dev/null +++ b/lua-config-package-tests/lua-config-package-build-test.c @@ -0,0 +1,10 @@ +#include +#include +#include + +int main() +{ + lua_State *l = luaL_newstate(); + double lversion = lua_version(l); + printf("Lua version is %f\n", lversion); +} \ No newline at end of file