From 113162263d9956385dbadcee7a16a100c01c76fd Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Sun, 15 Dec 2013 17:56:37 +0100 Subject: [PATCH] OpmFind.cmake: prevent multiple calls to the same module in the same run this prevents to check for the same module more than once in the same cmake run and should thus speed things up a bit as well as make the output a bit cleaner. For this I assumed that the ${name}_FOUND cmake variable does not get cached, which it seems like it does not... --- cmake/Modules/OpmFind.cmake | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index 2d9eceada..f7f1e186a 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -137,16 +137,19 @@ 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 (NOT (${name}_FOUND OR ${NAME}_FOUND)) + if (NOT DEFINED ${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) + else () message (STATUS "Finding package ${name} using module mode") find_package (${name} ${ARGN}) - endif (${name}_DIR) - endif (NOT (${name}_FOUND OR ${NAME}_FOUND)) - endif (CMAKE_DISABLE_FIND_PACKAGE_${name}) + endif () + endif () + if (NOT ${name}_FOUND) + set (${name}_FOUND "0") + endif () + endif () # the variable "NAME" may be replaced during find_package (as this is # now a macro, and not a function anymore), so we must reinitialize