[Groonga-commit] groonga/groonga at 6e2d4b3 [master] Support detecting MessagePack by pkg-config

Back to archive index

Kouhei Sutou null+****@clear*****
Mon Mar 30 20:52:17 JST 2015


Kouhei Sutou	2015-03-30 20:52:17 +0900 (Mon, 30 Mar 2015)

  New Revision: 6e2d4b38ec6760e8ed3eb6ed82dd97b51f1d05e0
  https://github.com/groonga/groonga/commit/6e2d4b38ec6760e8ed3eb6ed82dd97b51f1d05e0

  Message:
    Support detecting MessagePack by pkg-config

  Modified files:
    CMakeLists.txt
    configure.ac

  Modified: CMakeLists.txt (+21 -16)
===================================================================
--- CMakeLists.txt    2015-03-30 18:54:12 +0900 (1710da4)
+++ CMakeLists.txt    2015-03-30 20:52:17 +0900 (a108c1c)
@@ -505,25 +505,30 @@ endif()
 set(GRN_WITH_MESSAGE_PACK "auto"
   CACHE STRING "use MessagePack for suggestion")
 if(NOT ${GRN_WITH_MESSAGE_PACK} STREQUAL "no")
-  if("${GRN_WITH_MESSAGE_PACK}" STREQUAL "yes" OR
-      "${GRN_WITH_MESSAGE_PACK}" STREQUAL "auto")
-    set(MESSAGE_PACK_INCLUDE_DIRS "")
-    set(MESSAGE_PACK_LIBRARY_DIRS "")
-  else()
-    set(MESSAGE_PACK_INCLUDE_DIRS "${GRN_WITH_MESSAGE_PACK}/include")
-    set(MESSAGE_PACK_LIBRARY_DIRS "${GRN_WITH_MESSAGE_PACK}/lib")
-  endif()
-  set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
-  ac_check_lib(msgpack msgpack_version "${MESSAGE_PACK_LIBRARY_DIRS}")
-  set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
-  if(HAVE_LIBMSGPACK)
-    set(MESSAGE_PACK_LIBRARIES "msgpack")
+  pkg_check_modules(MESSAGE_PACK msgpack)
+  if(MESSAGE_PACK_FOUND)
     set(GRN_WITH_MESSAGE_PACK TRUE)
   else()
-    if(${GRN_WITH_MESSAGE_PACK} STREQUAL "yes")
-      message(FATAL_ERROR "No MessagePack found")
+    if("${GRN_WITH_MESSAGE_PACK}" STREQUAL "yes" OR
+	"${GRN_WITH_MESSAGE_PACK}" STREQUAL "auto")
+      set(MESSAGE_PACK_INCLUDE_DIRS "")
+      set(MESSAGE_PACK_LIBRARY_DIRS "")
+    else()
+      set(MESSAGE_PACK_INCLUDE_DIRS "${GRN_WITH_MESSAGE_PACK}/include")
+      set(MESSAGE_PACK_LIBRARY_DIRS "${GRN_WITH_MESSAGE_PACK}/lib")
+    endif()
+    set(CMAKE_REQUIRED_INCLUDES_SAVE ${CMAKE_REQUIRED_INCLUDES})
+    ac_check_lib(msgpack msgpack_version "${MESSAGE_PACK_LIBRARY_DIRS}")
+    set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES_SAVE})
+    if(HAVE_LIBMSGPACK)
+      set(MESSAGE_PACK_LIBRARIES "msgpack")
+      set(GRN_WITH_MESSAGE_PACK TRUE)
+    else()
+      if(${GRN_WITH_MESSAGE_PACK} STREQUAL "yes")
+	message(FATAL_ERROR "No MessagePack found")
+      endif()
+      set(GRN_WITH_MESSAGE_PACK FALSE)
     endif()
-    set(GRN_WITH_MESSAGE_PACK FALSE)
   endif()
 else()
   set(GRN_WITH_MESSAGE_PACK FALSE)

  Modified: configure.ac (+38 -20)
===================================================================
--- configure.ac    2015-03-30 18:54:12 +0900 (dd906b6)
+++ configure.ac    2015-03-30 20:52:17 +0900 (ac8bd3f)
@@ -1164,30 +1164,48 @@ AC_SUBST(LIBEVENT_CFLAGS)
 AC_SUBST(LIBEVENT_LIBS)
 
 # MessagePack
-AC_ARG_WITH(message-pack,
-  [AS_HELP_STRING([--without-message-pack],
-    [Disable MessagePack used for suggestion. [default=/usr]])],
-  [with_message_pack="$withval"],
-  [with_message_pack="/usr"])
-if test "x$with_message_pack" != "xno"; then
-  _SAVE_CFLAGS="$CFLAGS"
-  _SAVE_LDFLAGS="$LDFLAGS"
-  _SAVE_LIBS="$LIBS"
-  CFLAGS="$CFLAGS -I$with_message_pack/include"
-  LDFLAGS="$LDFLAGS -L$with_message_pack/lib"
-  AC_SEARCH_LIBS(msgpack_version, msgpack,
-                 [message_pack_available=yes],
-                 [message_pack_available=no])
-  CFLAGS="$_SAVE_CFLAGS"
-  LDFLAGS="$_SAVE_LDFLAGS"
-  LIBS="$_SAVE_LIBS"
+AC_ARG_ENABLE(message-pack,
+  [AS_HELP_STRING([--disable-message-pack],
+    [Disable MessagePack support. [default=auto-detect]])],
+  [enable_message_pack="$enableval"],
+  [enable_message_pack"auto"])
+if test "x$enable_message_pack" != "xno"; then
+  m4_ifdef([PKG_CHECK_MODULES], [
+    PKG_CHECK_MODULES([MESSAGE_PACK], [msgpack],
+      [message_pack_available=yes],
+      [message_pack_available=no])
+    ],
+    [message_pack_vailable=no])
+
+  if test "$message_pack_available" = "no"; then
+    AC_ARG_WITH(message-pack,
+      [AS_HELP_STRING([--with-message-pack],
+        [Specify prefix where MessagePack is installed. [default=/usr]])],
+      [with_message_pack="$withval"],
+      [with_message_pack="/usr"])
+    _SAVE_CFLAGS="$CFLAGS"
+    _SAVE_LDFLAGS="$LDFLAGS"
+    _SAVE_LIBS="$LIBS"
+    CFLAGS="$CFLAGS -I$with_message_pack/include"
+    LDFLAGS="$LDFLAGS -L$with_message_pack/lib"
+    AC_SEARCH_LIBS(msgpack_version, msgpack,
+                   [message_pack_available=yes],
+                   [message_pack_available=no])
+    CFLAGS="$_SAVE_CFLAGS"
+    LDFLAGS="$_SAVE_LDFLAGS"
+    LIBS="$_SAVE_LIBS"
+
+    if test "x$message_pack_available" = "xyes"; then
+      MESSAGE_PACK_CFLAGS="-I$with_message_pack/include"
+      MESSAGE_PACK_LIBS="-L$with_message_pack/lib -lmsgpack"
+    fi
+  fi
+
   if test "x$message_pack_available" = "xyes"; then
     AC_DEFINE(GRN_WITH_MESSAGE_PACK, [1],
               [Define to 1 if MessagePack is available.])
-    MESSAGE_PACK_CFLAGS="-I$with_message_pack/include"
-    MESSAGE_PACK_LIBS="-L$with_message_pack/lib -lmsgpack"
   else
-    if test "x$with_message_pack" = "xyes"; then
+    if test "x$enable_message_pack" = "xyes"; then
       AC_MSG_ERROR("No MessagePack found")
     fi
   fi
-------------- next part --------------
HTML����������������������������...
下载 



More information about the Groonga-commit mailing list
Back to archive index