summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Domonkos <mdomonko@redhat.com>2023-04-05 16:33:34 +0200
committerPanu Matilainen <pmatilai@redhat.com>2023-04-25 15:04:06 +0300
commit49befbc12381e95c2dacab50284ff32328a4ef99 (patch)
treeff6ccef92ec815887f845467a357414f49d59e19
parent87b9e0c28c3df3937f6676ee1b4164d6154dd9d3 (diff)
downloadrpm-49befbc12381e95c2dacab50284ff32328a4ef99.tar.gz
Use CMake Lua module
While many distros ship a pkg-config file for Lua, the upstream source tree does not provide one and so we shouldn't rely on it. Turns out, CMake provides a native Lua module so just use that. Unfortunately, the package doesn't define any IMPORTED target so add our own, similarly to how we did this recently with libmagic and libimaevm. Of particular note is that this adds an implicit dependency between CMake and Lua (e.g. Lua 5.4 support was only added in CMake 3.18), but that hopefully won't have much impact on most OS installations out there. Fixes: #2247
-rw-r--r--CMakeLists.txt10
-rw-r--r--build/CMakeLists.txt2
-rw-r--r--lib/CMakeLists.txt2
-rw-r--r--rpmio/CMakeLists.txt2
4 files changed, 11 insertions, 5 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f052271c5..230d18d1f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -135,11 +135,11 @@ set(REQFUNCS
)
find_package(PkgConfig REQUIRED)
+find_package(Lua 5.2 REQUIRED)
find_package(ZLIB REQUIRED)
find_package(BZip2)
find_package(Iconv)
-pkg_check_modules(LUA REQUIRED IMPORTED_TARGET lua>=5.2)
pkg_check_modules(POPT REQUIRED IMPORTED_TARGET popt)
pkg_check_modules(READLINE IMPORTED_TARGET readline)
pkg_check_modules(ZSTD IMPORTED_TARGET libzstd>=1.3.8)
@@ -147,6 +147,12 @@ pkg_check_modules(LIBELF IMPORTED_TARGET libelf)
pkg_check_modules(LIBDW IMPORTED_TARGET libdw)
pkg_check_modules(LIBLZMA IMPORTED_TARGET liblzma>=5.2.0)
+# Lua module does not ship an IMPORTED target, define our own
+add_library(LUA::LUA INTERFACE IMPORTED)
+set_target_properties(LUA::LUA PROPERTIES
+ INTERFACE_LINK_LIBRARIES "${LUA_LIBRARIES}"
+ INTERFACE_INCLUDE_DIRECTORIES "${LUA_INCLUDE_DIR}")
+
# file >= 5.39 ships a pkg-config, may move to that later
add_library(MAGIC::MAGIC UNKNOWN IMPORTED)
find_library(MAGIC_LIBRARY NAMES magic REQUIRED)
@@ -349,7 +355,7 @@ add_executable(rpmuncompress tools/rpmuncompress.c)
add_executable(elfdeps tools/elfdeps.c)
target_link_libraries(rpmsign PRIVATE librpmsign)
-target_link_libraries(rpmlua PRIVATE PkgConfig::LUA)
+target_link_libraries(rpmlua PRIVATE LUA::LUA)
target_link_libraries(elfdeps PRIVATE PkgConfig::LIBELF)
target_link_libraries(rpmbuild PRIVATE librpmbuild)
target_link_libraries(rpmspec PRIVATE librpmbuild)
diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt
index 440e06f08..898d42170 100644
--- a/build/CMakeLists.txt
+++ b/build/CMakeLists.txt
@@ -16,10 +16,10 @@ target_sources(librpmbuild PRIVATE
target_link_libraries(librpmbuild PUBLIC librpmio librpm)
target_link_libraries(librpmbuild PRIVATE
libmisc
- PkgConfig::LUA
PkgConfig::POPT
PkgConfig::LIBELF
PkgConfig::LIBDW
+ LUA::LUA
MAGIC::MAGIC
)
diff --git a/lib/CMakeLists.txt b/lib/CMakeLists.txt
index ac58e6978..ed60af078 100644
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -66,6 +66,6 @@ add_custom_command(OUTPUT tagtbl.C
)
target_link_libraries(librpm PUBLIC librpmio)
-target_link_libraries(librpm PRIVATE PkgConfig::POPT PkgConfig::LUA)
+target_link_libraries(librpm PRIVATE PkgConfig::POPT LUA::LUA)
install(TARGETS librpm)
diff --git a/rpmio/CMakeLists.txt b/rpmio/CMakeLists.txt
index 6aa9ab1f1..775263e0f 100644
--- a/rpmio/CMakeLists.txt
+++ b/rpmio/CMakeLists.txt
@@ -32,7 +32,7 @@ set_target_properties(librpmio PROPERTIES
)
target_link_libraries(librpmio PRIVATE
PkgConfig::POPT
- PkgConfig::LUA
+ LUA::LUA
ZLIB::ZLIB)
if (ZSTD_FOUND)