Blob Blame History Raw
From 06b6c44a0236bd499e71c2f56d0f5907e0a642c5 Mon Sep 17 00:00:00 2001
From: Igor Gnatenko <ignatenko@redhat.com>
Date: Thu, 19 Jan 2017 16:44:53 +0100
Subject: [PATCH] use bundled libpeas in case proper one not found

Signed-off-by: Igor Gnatenko <ignatenko@redhat.com>
---
 CMakeLists.txt | 27 ++++++++++++++++++++++++++-
 1 file changed, 26 insertions(+), 1 deletion(-)

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 04ca35a..e1ab4e3 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -16,9 +16,34 @@ set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} --std=gnu11")
 find_package (PkgConfig REQUIRED)
 pkg_check_modules (GLIB REQUIRED glib-2.0>=2.44.0)
 pkg_check_modules (GOBJECT REQUIRED gobject-2.0>=2.44.0)
-pkg_check_modules (PEAS REQUIRED libpeas-1.0>=1.20.0)
+pkg_check_modules (PEAS QUIET libpeas-1.0>=1.20.0)
 pkg_check_modules (LIBDNF REQUIRED libdnf>=0.7.0)
 
+if (NOT PEAS_FOUND)
+  include (ExternalProject)
+  set (PEAS_ARCHIVE ${CMAKE_CURRENT_LIST_DIR}/libpeas-1.20.0.tar.xz)
+  set (PEAS_INSTALL_PREFIX ${CMAKE_BINARY_DIR}/libpeas)
+  pkg_check_modules (PEAS_INTERNALS REQUIRED glib-2.0>=2.38.0 gobject-2.0>=2.38.0 gmodule-2.0>=2.38.0 gio-2.0>=2.32.0 gobject-introspection-1.0>=1.39.0)
+  ExternalProject_Add (
+    libpeas_external
+    URL https://download.gnome.org/sources/libpeas/1.20/libpeas-1.20.0.tar.xz
+    URL_HASH SHA256=f392fffe2dc00072a51bb2a1b274224a06bdc5f9c3b3c0ac4816909e9933d354
+    CONFIGURE_COMMAND
+      COMMAND ./configure --prefix=${PEAS_INSTALL_PREFIX} --enable-static --disable-shared --disable-lua5.1 --disable-luajit --disable-python2 --disable-python3 --disable-gtk --disable-glade-catalog
+    BUILD_COMMAND
+      COMMAND make
+    INSTALL_COMMAND
+      COMMAND make install
+    BUILD_IN_SOURCE 1
+  )
+
+  add_library (libpeas STATIC IMPORTED)
+  add_dependencies (libpeas libpeas_external)
+  set_target_properties (libpeas PROPERTIES IMPORTED_LOCATION ${PEAS_INSTALL_PREFIX}/lib/libpeas-1.0.a)
+  set (PEAS_INCLUDE_DIRS ${PEAS_INSTALL_PREFIX}/include/libpeas-1.0;${PEAS_INTERNALS_STATIC_INCLUDE_DIRS})
+  set (PEAS_LIBRARIES libpeas;${PEAS_INTERNALS_STATIC_LIBRARIES})
+endif ()
+
 set (PKG_LIBDIR ${CMAKE_INSTALL_FULL_LIBDIR}/dnf)
 set (PKG_DATADIR ${CMAKE_INSTALL_FULL_DATADIR}/dnf)
 add_definitions (-DPACKAGE_LIBDIR="${PKG_LIBDIR}")
-- 
2.7.4