Hi!

Review the attached version of FindMsgfmt, please.
-- 
Yury G. Kudryashov,
mailto: [email protected]
# - Try to find msgfmt 
# Once done this will define
#
#  MSGFMT_FOUND - system has msgfmt
#  MSGFMT_EXECUTABLE - full path of msgfmt
#  MSGFMT_VERSION - the version as reported by msgfmt --version

# Copyright (c) 2007, Montel Laurent <[email protected]>
# Copyright (c) 2011, Yury G. Kudryashov <[email protected]> (version check)
#
# Redistribution and use is allowed according to the terms of the BSD license.
# For details see the accompanying COPYING-CMAKE-SCRIPTS file.

find_program(MSGFMT_EXECUTABLE NAMES msgfmt)

if(MSGFMT_EXECUTABLE)
  exec_program(${MSGFMT_EXECUTABLE} ARGS --version OUTPUT_VARIABLE _tmp)
  if(${_tmp} MATCHES "msgfmt \\(GNU gettext-tools\\) ([0-9]+\\.[0-9]+\\.[0-9]+)\n")
    set(MSGFMT_VERSION ${CMAKE_MATCH_1})
  else()
    message(WARNING "Failed to determine version of msgfmt")
  endif()
endif()

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Msgfmt REQUIRED_VARS MSGFMT_EXECUTABLE
  VERSION_VAR MSGFMT_VERSION)

mark_as_advanced(MSGFMT_EXECUTABLE)


diff --git a/attic/modules/FindMsgfmt.cmake b/attic/modules/FindMsgfmt.cmake
index 47c6121..863f894 100644
--- a/attic/modules/FindMsgfmt.cmake
+++ b/attic/modules/FindMsgfmt.cmake
@@ -2,27 +2,29 @@
 # Once done this will define
 #
 #  MSGFMT_FOUND - system has msgfmt
+#  MSGFMT_EXECUTABLE - full path of msgfmt
+#  MSGFMT_VERSION - the version as reported by msgfmt --version
 
 # Copyright (c) 2007, Montel Laurent <[email protected]>
+# Copyright (c) 2011, Yury G. Kudryashov <[email protected]> (version check)
 #
 # Redistribution and use is allowed according to the terms of the BSD license.
 # For details see the accompanying COPYING-CMAKE-SCRIPTS file.
 
-### TODO: KDE4 needs msgfmt of version 0.15 or greater (cf. msgfmt --version )
+find_program(MSGFMT_EXECUTABLE NAMES msgfmt)
 
 if(MSGFMT_EXECUTABLE)
-  set(MSGFMT_FOUND TRUE)
-else(MSGFMT_EXECUTABLE)
+  exec_program(${MSGFMT_EXECUTABLE} ARGS --version OUTPUT_VARIABLE _tmp)
+  if(${_tmp} MATCHES "msgfmt \\(GNU gettext-tools\\) ([0-9]+\\.[0-9]+\\.[0-9]+)\n")
+    set(MSGFMT_VERSION ${CMAKE_MATCH_1})
+  else()
+    message(WARNING "Failed to determine version of msgfmt")
+  endif()
+endif()
 
-  FIND_PROGRAM(MSGFMT_EXECUTABLE NAMES msgfmt)
-  if (MSGFMT_EXECUTABLE)
-    set(MSGFMT_FOUND TRUE)
-  else (MSGFMT_EXECUTABLE)
-    if (Msgfmt_FIND_REQUIRED)
-      message(SEND_ERROR "Could NOT find msgfmt program")
-    endif (Msgfmt_FIND_REQUIRED)
-  endif (MSGFMT_EXECUTABLE)
-  MARK_AS_ADVANCED(MSGFMT_EXECUTABLE)
+include(FindPackageHandleStandardArgs)
+find_package_handle_standard_args(Msgfmt REQUIRED_VARS MSGFMT_EXECUTABLE
+  VERSION_VAR MSGFMT_VERSION)
 
-endif (MSGFMT_EXECUTABLE)
+mark_as_advanced(MSGFMT_EXECUTABLE)
 

_______________________________________________
Kde-buildsystem mailing list
[email protected]
https://mail.kde.org/mailman/listinfo/kde-buildsystem

Reply via email to