From 3d252ae8f40522036df628ef56bef7a4eeffe4f7 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 01:37:04 +0100 Subject: [PATCH] Allow variables from indirect dependencies to bubble up The previous implementation was a function, which although OK from an implementation standpoint -- the local variables doesn't pollute the global namespace -- would not allow variables that were set in indirect dependencies to bubble up to the main module. This is a problem for modules which are dependent on configuration variables to be present. --- cmake/Modules/OpmPackage.cmake | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 79ab4634..398af64c 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -47,7 +47,7 @@ macro (append_found src dst) endforeach (_item) endmacro (append_found src dst) -function (find_opm_package module deps header lib defs prog conf) +macro (find_opm_package module deps header lib defs prog conf) # variables to pass on to other packages if (FIND_QUIETLY) set (${module}_QUIET "QUIET") @@ -63,7 +63,7 @@ function (find_opm_package module deps header lib defs prog conf) # dependencies on other packages; underscore version only contains the # name of the other package set (_deps) - foreach (_dep IN LISTS deps) + foreach (_dep IN ITEMS ${deps}) separate_arguments (_args UNIX_COMMAND ${_dep}) find_package (${_args} QUIET) list (GET _args 0 _name_only) @@ -132,7 +132,7 @@ function (find_opm_package module deps header lib defs prog conf) # list of necessities to build with the software set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIR}") set (${module}_LIBRARIES "${${module}_LIBRARY}") - foreach (_dep IN LISTS _deps) + foreach (_dep IN ITEMS ${_deps}) # only add those packages we actually found (find_package will show # an error if it was marked as REQUIRED) if (${_dep}_FOUND) @@ -146,7 +146,7 @@ function (find_opm_package module deps header lib defs prog conf) # compile with this option to avoid avalanche of warnings set (${module}_DEFINITIONS "${${module}_DEFINITIONS}") - foreach (_def IN LISTS defs) + foreach (_def IN ITEMS ${defs}) list (APPEND ${module}_DEFINITIONS "-D${_def}") endforeach (_def) @@ -157,7 +157,7 @@ function (find_opm_package module deps header lib defs prog conf) # these defines are used in dune/${module} headers, and should be put # in config.h when we include those - foreach (_var IN LISTS conf) + foreach (_var IN ITEMS ${conf}) # massage the name to remove source code formatting string (REGEX REPLACE "^[\n\t\ ]+" "" _var "${_var}") string (REGEX REPLACE "[\n\t\ ]+$" "" _var "${_var}") @@ -209,22 +209,13 @@ function (find_opm_package module deps header lib defs prog conf) # some genius that coded the FindPackageHandleStandardArgs figured out # that the module name should be in uppercase (?!) - set (${module}_FOUND "${${MODULE_UPPER}_FOUND}" PARENT_SCOPE) - - # return these variables to the caller - set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIRS}" PARENT_SCOPE) - set (${module}_LIBRARIES "${${module}_LIBRARIES}" PARENT_SCOPE) - set (${module}_DEFINITIONS "${${module}_DEFINITIONS}" PARENT_SCOPE) - set (${module}_CONFIG_VARS "${${module}_CONFIG_VARS}" PARENT_SCOPE) - set (${module}_LINKER_FLAGS "${${module}_LINKER_FLAGS}" PARENT_SCOPE) - set (${module}_QUIET "${${module}_QUIET}" PARENT_SCOPE) - set (HAVE_${MODULE} "${HAVE_${MODULE}}" PARENT_SCOPE) + set (${module}_FOUND "${${MODULE_UPPER}_FOUND}") # print everything out if we're asked to if (${module}_DEBUG) debug_find_vars (${module}) endif (${module}_DEBUG) -endfunction (find_opm_package module deps header lib defs prog conf) +endmacro (find_opm_package module deps header lib defs prog conf) # print all variables defined by the above macro function (debug_find_vars module)