Hi all, 

I think the interface of find_package_handle_standard_args() is a bit
counter-intuitive. Why should it matter to the (ignorant) user that
list-variables are treated different from "ordinary" values. That
doesn't make sense IMHO (see my thread "How to use
FindPackageHandleStandardArgs" on the mailing list).

I've taken the time to rewrite find_package_handle_standard_args() in
such a way that you can now supply any variable as argument to be
checked. If the argument is a list, each member in the list will be
tested. It makes the function even shorter, because there's no need to
do a separate test on _VAR1 anymore. I think this change won't break any
existing code. Any comments are appreciated.

I've attached a patch against the current version of
FindPackageHandleStandardArgs.cmake. Should I open an issue in the bug
tracker for this?

Best regards,
Marcel Loose.



--- /usr/share/cmake/Modules/FindPackageHandleStandardArgs.cmake        
2008-09-24 20:34:34.000000000 +0200
+++ CMake/FindPackageHandleStandardArgs.cmake   2009-05-15 12:26:40.000000000 
+0200
@@ -20,6 +20,11 @@
 INCLUDE(FindPackageMessage)
 FUNCTION(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FAIL_MSG _VAR1 )
 
+  SET(ARGS)
+  FOREACH(_ARG ${_VAR1} ${ARGN})
+    LIST(APPEND ARGS ${${_ARG}})
+  ENDFOREACH(_ARG)
+
   IF("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
     SET(_FAIL_MESSAGE "Could NOT find ${_NAME}")
   ELSE("${_FAIL_MSG}" STREQUAL "DEFAULT_MSG")
@@ -28,30 +33,23 @@
 
   STRING(TOUPPER ${_NAME} _NAME_UPPER)
 
-  # collect all variables which were not found, so they can be printed, so the 
+  # Check if all passed variables are valid. 
+  # Collect all variables which were not found, so they can be printed, so the 
   # user knows better what went wrong (#6375)
   SET(MISSING_VARS "")
   SET(DETAILS "")
   SET(${_NAME_UPPER}_FOUND TRUE)
-  IF(NOT ${_VAR1})
-    SET(${_NAME_UPPER}_FOUND FALSE)
-    SET(MISSING_VARS " ${_VAR1}")
-  ELSE(NOT ${_VAR1})
-    SET(DETAILS "${DETAILS}[${${_VAR1}}]")
-  ENDIF(NOT ${_VAR1})
-
-  # check if all passed variables are valid
-  FOREACH(_CURRENT_VAR ${ARGN})
-    IF(NOT ${_CURRENT_VAR})
+  FOREACH(_CURRENT_VAR ${ARGS})
+    IF(NOT _CURRENT_VAR)
       SET(${_NAME_UPPER}_FOUND FALSE)
       SET(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}")
-    ELSE(NOT ${_CURRENT_VAR})
-      SET(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]")
-    ENDIF(NOT ${_CURRENT_VAR})
+    ELSE(NOT _CURRENT_VAR)
+      SET(DETAILS "${DETAILS}[${_CURRENT_VAR}]")
+    ENDIF(NOT _CURRENT_VAR)
   ENDFOREACH(_CURRENT_VAR)
 
   IF (${_NAME_UPPER}_FOUND)
-    FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_VAR1}}" "${DETAILS}")
+    FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${ARGS}" "${DETAILS}")
   ELSE (${_NAME_UPPER}_FOUND)
     IF (${_NAME}_FIND_REQUIRED)
         MESSAGE(FATAL_ERROR "${_FAIL_MESSAGE} (missing: ${MISSING_VARS})")
_______________________________________________
Powered by www.kitware.com

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Follow this link to subscribe/unsubscribe:
http://www.cmake.org/mailman/listinfo/cmake

Reply via email to