summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichal Domonkos <mdomonko@redhat.com>2023-04-05 15:15:29 +0200
committerPanu Matilainen <pmatilai@redhat.com>2023-04-11 13:23:21 +0300
commitb75ae820beb53633e4ef8b476f7cf0aad2d617bc (patch)
tree4a6d0ab0a65376fcc776fee8946ad51c1309b972
parentd648cb305cd6d49ca453b3b80941d9fc0cdad1f7 (diff)
downloadrpm-b75ae820beb53633e4ef8b476f7cf0aad2d617bc.tar.gz
Don't rely on pkg-config for libmagic just yet
This fixes a regression from automake where we also didn't use pkg-config for libmagic. Fixes: #2246
-rw-r--r--CMakeLists.txt9
-rw-r--r--build/CMakeLists.txt2
2 files changed, 9 insertions, 2 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
index f7b167b3c..4db2bb824 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -136,13 +136,20 @@ find_package(Iconv)
pkg_check_modules(LUA REQUIRED IMPORTED_TARGET lua>=5.2)
pkg_check_modules(POPT REQUIRED IMPORTED_TARGET popt)
-pkg_check_modules(MAGIC REQUIRED IMPORTED_TARGET libmagic)
pkg_check_modules(READLINE IMPORTED_TARGET readline)
pkg_check_modules(ZSTD IMPORTED_TARGET libzstd>=1.3.8)
pkg_check_modules(LIBELF IMPORTED_TARGET libelf)
pkg_check_modules(LIBDW IMPORTED_TARGET libdw)
pkg_check_modules(LIBLZMA IMPORTED_TARGET liblzma>=5.2.0)
+# 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)
+find_path(MAGIC_INCLUDE_DIR NAMES magic.h REQUIRED)
+set_target_properties(MAGIC::MAGIC PROPERTIES
+ IMPORTED_LOCATION "${MAGIC_LIBRARY}")
+target_include_directories(MAGIC::MAGIC INTERFACE "${MAGIC_INCLUDE_DIR}")
+
if (ENABLE_OPENMP)
find_package(OpenMP 4.5 REQUIRED)
endif()
diff --git a/build/CMakeLists.txt b/build/CMakeLists.txt
index c63ed5cc7..440e06f08 100644
--- a/build/CMakeLists.txt
+++ b/build/CMakeLists.txt
@@ -18,9 +18,9 @@ target_link_libraries(librpmbuild PRIVATE
libmisc
PkgConfig::LUA
PkgConfig::POPT
- PkgConfig::MAGIC
PkgConfig::LIBELF
PkgConfig::LIBDW
+ MAGIC::MAGIC
)
if(WITH_CAP)