From 2363a70d467d2b76b9ccb975b449c06d9e857fe3 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 16 Aug 2013 21:56:08 +0200 Subject: [PATCH] Only search for a package again if not found If it is already found, most packages sets a flag that makes it exit immediately anyway. We usually cannot rerun find_package to get another combinations of modules. Here we check the flag before we start looking for the package to avoid the endless stream of messages. --- cmake/Modules/OpmFind.cmake | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index f77c6d31..a54e86d5 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -132,13 +132,15 @@ macro (find_and_append_package_to prefix name) # using config mode is better than using module (aka. find) mode # because then the package has already done all its probes and # stored them in the config file for us - if (${name}_DIR) - message (STATUS "Finding package ${name} using config mode") - find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH) - else (${name}_DIR) - message (STATUS "Finding package ${name} using module mode") - find_package (${name} ${ARGN}) - endif (${name}_DIR) + if (NOT ${NAME}_FOUND) + if (${name}_DIR) + message (STATUS "Finding package ${name} using config mode") + find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH) + else (${name}_DIR) + message (STATUS "Finding package ${name} using module mode") + find_package (${name} ${ARGN}) + endif (${name}_DIR) + endif (NOT ${NAME}_FOUND) # the variable "NAME" may be replaced during find_package (as this is # now a macro, and not a function anymore), so we must reinitialize