Bug#645674: cmake and pkgconfig files

2011-10-21 Thread Black Jack
I hope you didn't just put FindHiredis.cmake into
/usr/share/cmake/hiredis/hiredis-config.cmake because it will not
work.
I wrote a simple working config for hiredis.
These files have some variables that shall differ from build to build
(for example, package version), maybe some generator should be
written?
SET(prefix /usr)
SET(exec_prefix ${prefix})
SET(HIREDIS_LIBRARIES ${exec_prefix}/lib/libhiredis.so CACHE FILEPATH Hiredis library)
SET(HIREDIS_INCLUDE_DIR ${prefix}/include CACHE PATH Include path for Hiredis)
SET(HIREDIS_FOUND TRUE)
SET(PACKAGE_VERSION 0.10.1-2)
IF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
  SET(PACKAGE_VERSION_EXACT true)
ENDIF (PACKAGE_FIND_VERSION VERSION_EQUAL PACKAGE_VERSION)
IF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
  SET(PACKAGE_VERSION_COMPATIBLE true)
ELSE (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
  SET(PACKAGE_VERSION_UNSUITABLE true)
ENDIF (NOT PACKAGE_FIND_VERSION VERSION_GREATER PACKAGE_VERSION)
IF (PACKAGE_VERSION_UNSUITABLE)
  MESSAGE(VERSION CHECK FAILED FOR ${PACKAGE_FIND_NAME}. WANTED ${PACKAGE_FIND_VERSION}, HAVE ${PACKAGE_VERSION})
ENDIF(PACKAGE_VERSION_UNSUITABLE)


Bug#645674: cmake and pkgconfig files

2011-10-17 Thread Black Jack
Package: libhiredis-dev
Version: 0.10.1-2

There are no cmake module for this package, so I decided to write one.
Also, I think that placing pkgconfig .pc file with prefix lib is
incorrect - there are no packages doing that except libxml2.
Additionally every pkgconfig module has header containing something like

prefix=/usr
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
includedir=${prefix}/include

but libhiredis.pc has every variable hardcoded - /usr/lib, /usr/include etc.

So I also attach a fixed hiredis.pc.
p.s. As far as I know, cmake-modules are placed in
/usr/share/cmake-{cmake-version}/Modules, and cmake-version is
different from release to release. Now it's 2.8


hiredis.pc
Description: Binary data
# FindHiredis.cmake - Try to find the Hiredis library
# Once done this will define
#
#  HIREDIS_FOUND - System has Hiredis
#  HIREDIS_INCLUDE_DIR - The Hiredis include directory
#  HIREDIS_LIBRARIES - The libraries needed to use Hiredis
#  HIREDIS_DEFINITIONS - Compiler switches required for using Hiredis


# use pkg-config to get the directories and then use these values
# in the FIND_PATH() and FIND_RARY() calls
FIND_PACKAGE(PkgConfig)
PKG_SEARCH_MODULE(PC_HIREDIS REQUIRED hiredis)

SET(HIREDIS_DEFINITIONS ${PC_HIREDIS_CFLAGS_OTHER})

FIND_PATH(HIREDIS_INCLUDE_DIR NAMES hiredis/hiredis.h
   HINTS
   ${PC_HIREDIS_INCLUDEDIR}
   ${PC_HIREDIS_INCLUDE_DIRS}
   PATH_SUFFIXES hiredis
   )

FIND_LIBRARY(HIREDIS_LIBRARIES NAMES hiredis
   HINTS
   ${PC_HIREDIS_DIR}
   ${PC_HIREDIS_LIBRARY_DIRS}
   )


INCLUDE(FindPackageHandleStandardArgs)
FIND_PACKAGE_HANDLE_STANDARD_ARGS(Hiredis DEFAULT_MSG HIREDIS_LIBRARIES HIREDIS_INCLUDE_DIR)

MARK_AS_ADVANCED(HIREDIS_INCLUDE_DIR HIREDIS_LIBRARIES)