From ef06e88c438e342582e8eace8fb678f83364c6ff Mon Sep 17 00:00:00 2001 From: Markus Raab Date: Thu, 15 Dec 2016 17:23:00 +0100 Subject: [PATCH] augeas: fix prefix for non-default installations as discussed in #1187 --- cmake/Modules/FindAugeas.cmake | 10 +++++++++- src/plugins/augeas/CMakeLists.txt | 4 ++++ src/plugins/augeas/augeas.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindAugeas.cmake b/cmake/Modules/FindAugeas.cmake index 129c17feb68..3175ed24148 100644 --- a/cmake/Modules/FindAugeas.cmake +++ b/cmake/Modules/FindAugeas.cmake @@ -7,6 +7,8 @@ # # Distributed under the BSD license. See COPYING-CMAKE-SCRIPTS for details. +include (LibFindMacros) + if (LIBAUGEAS_INCLUDE_DIR) # in cache already set (LIBAUGEAS_FOUND TRUE) @@ -25,6 +27,12 @@ else (LIBAUGEAS_INCLUDE_DIR) /usr/local/include ) + pkg_get_variable(_LIBAUGEAS_PREFIX augeas prefix) + if (NOT _LIBAUGEAS_PREFIX) + set (_LIBAUGEAS_PREFIX "/usr") + endif () + set(LIBAUGEAS_PREFIX "${_LIBAUGEAS_PREFIX}" CACHE INTERNAL "prefix path of libaugeas" FORCE) + find_library (LIBAUGEAS_LIBRARIES NAMES augeas PATHS ${_LIBAUGEAS_PC_LIBDIR} @@ -44,6 +52,6 @@ else (LIBAUGEAS_INCLUDE_DIR) endif (LIBAUGEAS_FIND_REQUIRED) endif (LIBAUGEAS_FOUND) - mark_as_advanced(LIBAUGEAS_INCLUDE_DIR LIBAUGEAS_LIBRARIES) + mark_as_advanced(LIBAUGEAS_INCLUDE_DIR LIBAUGEAS_LIBRARIES _LIBAUGEAS_PREFIX) endif (LIBAUGEAS_INCLUDE_DIR) diff --git a/src/plugins/augeas/CMakeLists.txt b/src/plugins/augeas/CMakeLists.txt index da53765d8e8..106d901e65a 100644 --- a/src/plugins/augeas/CMakeLists.txt +++ b/src/plugins/augeas/CMakeLists.txt @@ -2,6 +2,8 @@ if (DEPENDENCY_PHASE) find_package (Augeas) find_package (LibXml2) + set (LIBAUGEAS_COMPILE_DEFINITIONS LIBAUGEAS_PREFIX="${LIBAUGEAS_PREFIX}") + if (LIBAUGEAS_FOUND AND LIBXML2_FOUND) try_compile (HAS_LIBAUGEAS16 "${CMAKE_BINARY_DIR}" @@ -28,6 +30,8 @@ add_plugin(augeas INCLUDE_DIRECTORIES ${LIBAUGEAS_INCLUDE_DIR} ${LIBXML2_INCLUDE_DIR} + COMPILE_DEFINITIONS + "${LIBAUGEAS_COMPILE_DEFINITIONS}" LINK_ELEKTRA elektra-meta elektra-proposal diff --git a/src/plugins/augeas/augeas.c b/src/plugins/augeas/augeas.c index 11a6dfd3a7b..a2e235d7db8 100644 --- a/src/plugins/augeas/augeas.c +++ b/src/plugins/augeas/augeas.c @@ -76,7 +76,7 @@ int elektraAugeasGenConf (KeySet * ks, Key * errorKey ELEKTRA_UNUSED) { glob_t pglob; int retval = 1; - const char * f = "/usr/share/augeas/lenses/dist/*.aug"; + const char * f = LIBAUGEAS_PREFIX "/share/augeas/lenses/dist/*.aug"; if (glob (f, GLOB_NOSORT, NULL, &pglob) == 0) { ELEKTRA_LOG ("has glob %zd", pglob.gl_pathc);