From 1781d1fb655d3414c8b3ea9c91cdce11415f2569 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 14 Mar 2013 16:15:28 +0100 Subject: [PATCH 01/18] Added integer flag to ecl_file_open: To allign with ert commit: bd542a45c5e72 --- opm/core/io/eclipse/EclipseGridParser.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opm/core/io/eclipse/EclipseGridParser.cpp b/opm/core/io/eclipse/EclipseGridParser.cpp index faed259d..ca928d9f 100644 --- a/opm/core/io/eclipse/EclipseGridParser.cpp +++ b/opm/core/io/eclipse/EclipseGridParser.cpp @@ -1090,7 +1090,7 @@ void EclipseGridParser::getNumericErtFields(const string& filename) { #ifdef HAVE_ERT // Read file - ecl_file_type * ecl_file = ecl_file_open(filename.c_str()); + ecl_file_type * ecl_file = ecl_file_open(filename.c_str() , 0); if (ecl_file == NULL) { THROW("Could not open IMPORTed file " << filename); } From 97c2fabe8e478af6555c523cfb9383141f3685ac Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Mar 2013 22:51:01 +0100 Subject: [PATCH 02/18] Search for uppercase variants of the package vars as well For compatibility with packages that believes that every variable should be in uppercase, we try this variant when adding relevant variables to the project. --- cmake/Modules/OpmFind.cmake | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index a5e77841..adaf60f7 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -81,23 +81,34 @@ macro (find_and_append_package_to prefix name) message (STATUS "Finding package ${name} using module mode") find_package (${name} ${ARGN}) endif (${name}_DIR) - if (${name}_FOUND) + if (${name}_FOUND OR ${NAME}_FOUND) foreach (var IN LISTS _opm_proj_vars) if (DEFINED ${name}_${var}) list (APPEND ${prefix}_${var} ${${name}_${var}}) - # cleanup lists - if ("${var}" STREQUAL "LIBRARIES") - remove_duplicate_libraries (${prefix}) - else ("${var}" STREQUAL "LIBRARIES") - list (REMOVE_DUPLICATES ${prefix}_${var}) - endif ("${var}" STREQUAL "LIBRARIES") + # some packages define an uppercase version of their own name + elseif (DEFINED ${NAME}_${var}) + list (APPEND ${prefix}_${var} ${${NAME}_${var}}) endif (DEFINED ${name}_${var}) + # some packages define _PATH instead of _DIRS (Hi, MPI!) + if ("${var}" STREQUAL "INCLUDE_DIRS") + if (DEFINED ${name}_INCLUDE_PATH) + list (APPEND ${prefix}_INCLUDE_DIRS ${name}_INCLUDE_PATH) + elseif (DEFINED ${NAME}_INCLUDE_PATH) + list (APPEND ${prefix}_INCLUDE_DIRS ${NAME}_INCLUDE_PATH) + endif (DEFINED ${name}_INCLUDE_PATH) + endif ("${var}" STREQUAL "INCLUDE_DIRS") + # cleanup lists + if ("${var}" STREQUAL "LIBRARIES") + remove_duplicate_libraries (${prefix}) + else ("${var}" STREQUAL "LIBRARIES") + list (REMOVE_DUPLICATES ${prefix}_${var}) + endif ("${var}" STREQUAL "LIBRARIES") endforeach (var) # some libraries only define xxx_FOUND and not a corresponding HAVE_xxx if (NOT DEFINED HAVE_${NAME}) set (HAVE_${NAME} 1) endif (NOT DEFINED HAVE_${NAME}) - endif (${name}_FOUND) + endif (${name}_FOUND OR ${NAME}_FOUND) endmacro (find_and_append_package_to prefix name) # append to the list of variables associated with the project From 8dcca4cf9b2045b4dc175f2b5c9ba334ad1f7ab1 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Mar 2013 22:55:05 +0100 Subject: [PATCH 03/18] Use camel-case in SuperLU's name Originally, I added FindSuperLU with uppercase since the variables it returned had that case. Now the scripts should be patched so that it searched for uppercase amongst the variables as well, so the module name can retain its original case (and for compatibility with DUNE) --- CMakeLists.txt | 2 +- cmake/Modules/{FindSUPERLU.cmake => FindSuperLU.cmake} | 0 cmake/Modules/Finddune-istl.cmake | 2 +- cmake/Modules/Findopm-core.cmake | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename cmake/Modules/{FindSUPERLU.cmake => FindSuperLU.cmake} (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index 131a909a..46d62c62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -36,7 +36,7 @@ set (${project}_DEPS # Tim Davis' SuiteSparse archive "SuiteSparse COMPONENTS umfpack" # solver - "SUPERLU" + "SuperLU" # xml processing (for config parsing) "TinyXML" # Ensembles-based Reservoir Tools (ERT) diff --git a/cmake/Modules/FindSUPERLU.cmake b/cmake/Modules/FindSuperLU.cmake similarity index 100% rename from cmake/Modules/FindSUPERLU.cmake rename to cmake/Modules/FindSuperLU.cmake diff --git a/cmake/Modules/Finddune-istl.cmake b/cmake/Modules/Finddune-istl.cmake index d8d1a04c..14a40104 100644 --- a/cmake/Modules/Finddune-istl.cmake +++ b/cmake/Modules/Finddune-istl.cmake @@ -24,7 +24,7 @@ find_opm_package ( # required dependencies "dune-common ${_require_dune_common}; - SUPERLU + SuperLU " # header to search for "dune/istl/bcrsmatrix.hh" diff --git a/cmake/Modules/Findopm-core.cmake b/cmake/Modules/Findopm-core.cmake index 23a8e6bb..31c9f177 100644 --- a/cmake/Modules/Findopm-core.cmake +++ b/cmake/Modules/Findopm-core.cmake @@ -24,7 +24,7 @@ find_opm_package ( BLAS REQUIRED; LAPACK REQUIRED; SuiteSparse COMPONENTS umfpack; - SUPERLU; + SuperLU; TinyXML; ERT; dune-istl From ccbcb6f364370cf6d666255967cd769edbf56ace Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Mar 2013 23:46:54 +0100 Subject: [PATCH 04/18] Enable debug tracing when finding modules --- cmake/Modules/OpmPackage.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 07efd102..79ab4634 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -219,6 +219,11 @@ function (find_opm_package module deps header lib defs prog conf) set (${module}_LINKER_FLAGS "${${module}_LINKER_FLAGS}" PARENT_SCOPE) set (${module}_QUIET "${${module}_QUIET}" PARENT_SCOPE) set (HAVE_${MODULE} "${HAVE_${MODULE}}" PARENT_SCOPE) + + # 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) # print all variables defined by the above macro From 3d252ae8f40522036df628ef56bef7a4eeffe4f7 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 01:37:04 +0100 Subject: [PATCH 05/18] 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) From ce007fca7d77ac8bbfe3796187408ffc6337e3c6 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 09:39:38 +0100 Subject: [PATCH 06/18] Abstract into common version and parameterize --- cmake/Modules/Duplicates.cmake | 21 +++++++-------------- cmake/Modules/OpmFind.cmake | 2 +- 2 files changed, 8 insertions(+), 15 deletions(-) diff --git a/cmake/Modules/Duplicates.cmake b/cmake/Modules/Duplicates.cmake index d277e322..aee9f62e 100644 --- a/cmake/Modules/Duplicates.cmake +++ b/cmake/Modules/Duplicates.cmake @@ -22,23 +22,16 @@ endmacro (remove_duplicate_libraries module) # headers can be trimmed from the end, since adding a directory to # the list is an idempotent action -macro (remove_duplicate_headers module) - if (DEFINED ${module}_INCLUDE_DIRS) - list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS) - endif (DEFINED ${module}_INCLUDE_DIRS) -endmacro (remove_duplicate_headers module) - -# linker flags may not be specified at all -macro (remove_duplicate_flags module) - if (DEFINED ${module}_LINKER_FLAGS) - list (REMOVE_DUPLICATES ${module}_LINKER_FLAGS) - endif (DEFINED ${module}_LINKER_FLAGS) -endmacro (remove_duplicate_flags module) +macro (remove_duplicate_var module suffix) + if (DEFINED ${module}_${suffix}) + list (REMOVE_DUPLICATES ${module}_${suffix}) + endif (DEFINED ${module}_${suffix}) +endmacro (remove_duplicate_var module suffix) # fix up both headers and libraries, in case two dependencies have # included the same second-level library independently macro (remove_dup_deps module) - remove_duplicate_headers (${module}) + remove_duplicate_var (${module} INCLUDE_DIRS) + remove_duplicate_var (${module} LINKER_FLAGS) remove_duplicate_libraries (${module}) - remove_duplicate_flags (${module}) endmacro (remove_dup_deps module) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index adaf60f7..1f0b1bfb 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -101,7 +101,7 @@ macro (find_and_append_package_to prefix name) if ("${var}" STREQUAL "LIBRARIES") remove_duplicate_libraries (${prefix}) else ("${var}" STREQUAL "LIBRARIES") - list (REMOVE_DUPLICATES ${prefix}_${var}) + remove_duplicate_var (${prefix} ${var}) endif ("${var}" STREQUAL "LIBRARIES") endforeach (var) # some libraries only define xxx_FOUND and not a corresponding HAVE_xxx From f42bf41e152cd14c4efcbbf0a8349d8502003981 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 09:44:59 +0100 Subject: [PATCH 07/18] Use our own find routine recursively Don't use bare find_package in OpmPackage when we have already written OpmFind to take out the worst warts. --- cmake/Modules/Duplicates.cmake | 1 + cmake/Modules/OpmPackage.cmake | 42 ++++++++-------------------------- 2 files changed, 11 insertions(+), 32 deletions(-) diff --git a/cmake/Modules/Duplicates.cmake b/cmake/Modules/Duplicates.cmake index aee9f62e..6b48f357 100644 --- a/cmake/Modules/Duplicates.cmake +++ b/cmake/Modules/Duplicates.cmake @@ -33,5 +33,6 @@ endmacro (remove_duplicate_var module suffix) macro (remove_dup_deps module) remove_duplicate_var (${module} INCLUDE_DIRS) remove_duplicate_var (${module} LINKER_FLAGS) + remove_duplicate_var (${module} CONFIG_VARS) remove_duplicate_libraries (${module}) endmacro (remove_dup_deps module) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 398af64c..549ad9c7 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -37,7 +37,8 @@ # -include (Duplicates) +include (OpmFind) + # append all items from src into dst; both must be *names* of lists macro (append_found src dst) foreach (_item IN LISTS ${src}) @@ -60,16 +61,6 @@ macro (find_opm_package module deps header lib defs prog conf) return () endif (${${module}_FOUND}) - # dependencies on other packages; underscore version only contains the - # name of the other package - set (_deps) - foreach (_dep IN ITEMS ${deps}) - separate_arguments (_args UNIX_COMMAND ${_dep}) - find_package (${_args} QUIET) - list (GET _args 0 _name_only) - list (APPEND _deps ${_name_only}) - endforeach (_dep) - # see if there is a pkg-config entry for this package, and use those # settings as a starting point find_package (PkgConfig) @@ -132,16 +123,13 @@ macro (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 ITEMS ${_deps}) - # only add those packages we actually found (find_package will show - # an error if it was marked as REQUIRED) - if (${_dep}_FOUND) - list (APPEND ${module}_INCLUDE_DIRS ${${_dep}_INCLUDE_DIRS}) - list (APPEND ${module}_LIBRARIES ${${_dep}_LIBRARIES}) - list (APPEND ${module}_DEFINITIONS ${${_dep}_DEFINITIONS}) - list (APPEND ${module}_CONFIG_VARS ${${_dep}_CONFIG_VARS}) - list (APPEND ${module}_LINKER_FLAGS ${${_dep}_LINKER_FLAGS}) - endif (${_dep}_FOUND) + set (_deps) + foreach (_dep IN ITEMS ${deps}) + separate_arguments (_args UNIX_COMMAND ${_dep}) + find_and_append_package_to (${module} ${_args} ${${module}_QUIET}) + find_package (${_args} QUIET) + list (GET _args 0 _name_only) + list (APPEND _deps ${_name_only}) endforeach (_dep) # compile with this option to avoid avalanche of warnings @@ -151,9 +139,7 @@ macro (find_opm_package module deps header lib defs prog conf) endforeach (_def) # tidy the lists before returning them - list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS) - remove_duplicate_libraries (${module}) - list (REMOVE_DUPLICATES ${module}_DEFINITIONS) + remove_dup_deps (${module}) # these defines are used in dune/${module} headers, and should be put # in config.h when we include those @@ -163,14 +149,6 @@ macro (find_opm_package module deps header lib defs prog conf) string (REGEX REPLACE "[\n\t\ ]+$" "" _var "${_var}") list (APPEND ${module}_CONFIG_VARS ${_var}) endforeach (_var) - foreach (_dep in _deps) - if (DEFINED ${_dep}_CONFIG_VARS) - list (APPEND ${module}_CONFIG_VARS ${_dep}_CONFIG_VARS) - endif (DEFINED ${_dep}_CONFIG_VARS) - endforeach (_dep) - if (${module}_CONFIG_VARS) - list (REMOVE_DUPLICATES ${module}_CONFIG_VARS) - endif (${module}_CONFIG_VARS) # these are the defines that should be set when compiling # without config.h From edd6b15497a842a9ac10ee134be7e9b0d9406d1f Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 08:58:07 +0100 Subject: [PATCH 08/18] Add MPI dependency for dune-common mpihelper.hh needs to know HAVE_MPI in the same way as the compiled library in order to generate a consistent interface. --- cmake/Modules/Finddune-common.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/Finddune-common.cmake b/cmake/Modules/Finddune-common.cmake index 5ba9bc56..807cde91 100644 --- a/cmake/Modules/Finddune-common.cmake +++ b/cmake/Modules/Finddune-common.cmake @@ -18,7 +18,8 @@ find_opm_package ( # dependencies "CXX11Features REQUIRED; BLAS REQUIRED; - LAPACK REQUIRED + LAPACK REQUIRED; + MPI " # header to search for "dune/common/fvector.hh" From 4fb05162cb9cd385549e711d2b35d05e0923e708 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 09:47:53 +0100 Subject: [PATCH 09/18] Only use MPI if explicitly enabled Running with MPI on a regular workstation will probably not increase performance, so this should be disabled as default. --- CMakeLists.txt | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 46d62c62..48a8936a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -97,8 +97,13 @@ include (UseOptimization) # dependencies, in case they alter the list of warnings include (UseWarnings) +# parallel computing must be explicitly enabled +option (USE_MPI "Use Message Passing Interface for parallel computing" OFF) +if (NOT USE_MPI) + set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE) +endif (NOT USE_MPI) + ### --- begin opm-core specific --- ### -# parallel programming include (UseOpenMP) find_openmp (${project}) ### --- end opm-core specific --- ### From 3f3ac283e8bb3ae9fd2c8bcbdb5c1612175de5a9 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 11:14:51 +0100 Subject: [PATCH 10/18] Enable MPI support from DUNE with --enable-parallel --- configure | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 150c141b..45ecda87 100755 --- a/configure +++ b/configure @@ -22,6 +22,7 @@ Optional Features: --disable-silent-rules print every compilation statement as executed --enable-system-debug put .debug files in global GDB debug dir [default=yes if prefix=/usr, no otherwise] + --enable-parallel process in parallel using MPI [default=no] --enable-openmp activate experimental support for OpenMP --disable-option-checking ignore unrecognized --enable/--with options @@ -93,6 +94,7 @@ buildtype=Debug pch_use= #use_openmp=" -DUSE_OPENMP=OFF" use_openmp= +use_mpi= #silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF" silent_rules= #debug_loc=" -DSYSTEM_DEBUG=OFF" @@ -226,6 +228,10 @@ for OPT in "$@"; do use_openmp=" -DUSE_OPENMP=OFF" pkgname="" ;; + parallel) + use_mpi=" -DUSE_MPI=OFF" + pkgname="" + ;; agmg |\ ert |\ superlu) @@ -260,6 +266,11 @@ for OPT in "$@"; do # special flag; don't set shared/static shared="" ;; + parallel) + use_openmp=" -DUSE_MPI=ON" + # special flag; don't set shared/static + shared="" + ;; # this flag is just for compatibility with the deprecation # flag in DUNE, so we can build without warnings fieldvector-size-is-method) @@ -308,7 +319,7 @@ for a in "${VARS[@]}"; do done # pass everything on to CMake -CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp} ${FEATURES}" +CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi} ${FEATURES}" echo --- calling CMake --- echo ${CMDLINE} eval exec ${CMDLINE} From 89be4e145a515e6ec551f4972f32ce0478cd190a Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 11:37:17 +0100 Subject: [PATCH 11/18] Bugfix change from macro to function All variables we introduce which is not parameters are in fact global variables that may be overwritten by recursive invocation! --- cmake/Modules/OpmFind.cmake | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index 1f0b1bfb..c4576aab 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -81,6 +81,12 @@ macro (find_and_append_package_to prefix name) message (STATUS "Finding package ${name} using module mode") find_package (${name} ${ARGN}) endif (${name}_DIR) + + # the variable "NAME" may be replaced during find_package (as this is + # now a macro, and not a function anymore), so we must reinitialize + string (TOUPPER "${name}" NAME) + string (REPLACE "-" "_" NAME "${NAME}") + if (${name}_FOUND OR ${NAME}_FOUND) foreach (var IN LISTS _opm_proj_vars) if (DEFINED ${name}_${var}) From 88b0740480a793feb247f39d868763cbbf82be5f Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 12:23:57 +0100 Subject: [PATCH 12/18] Bugfix expand variable definition --- cmake/Modules/OpmFind.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index c4576aab..11f4c2b9 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -98,9 +98,9 @@ macro (find_and_append_package_to prefix name) # some packages define _PATH instead of _DIRS (Hi, MPI!) if ("${var}" STREQUAL "INCLUDE_DIRS") if (DEFINED ${name}_INCLUDE_PATH) - list (APPEND ${prefix}_INCLUDE_DIRS ${name}_INCLUDE_PATH) + list (APPEND ${prefix}_INCLUDE_DIRS ${${name}_INCLUDE_PATH}) elseif (DEFINED ${NAME}_INCLUDE_PATH) - list (APPEND ${prefix}_INCLUDE_DIRS ${NAME}_INCLUDE_PATH) + list (APPEND ${prefix}_INCLUDE_DIRS ${${NAME}_INCLUDE_PATH}) endif (DEFINED ${name}_INCLUDE_PATH) endif ("${var}" STREQUAL "INCLUDE_DIRS") # cleanup lists From bafa781181f1c12a92e424bc066c0567d4e87ec8 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 12:44:24 +0100 Subject: [PATCH 13/18] Search in dunecontrol build directories for other modules --- cmake/Modules/OpmPackage.cmake | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 549ad9c7..f385afa0 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -79,7 +79,8 @@ macro (find_opm_package module deps header lib defs prog conf) # in standard system locations either, then start to wander # about and look for it in proximity to ourself. Qt Creator likes # to put the build-directories as siblings to the source trees, - # but with a -build suffix + # but with a -build suffix, DUNE likes to have the the build tree + # in a "build-cmake" sub-directory of each module if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT)) string (TOLOWER "${module}" _module_lower) set (_guess @@ -87,6 +88,8 @@ macro (find_opm_package module deps header lib defs prog conf) "../${module}-build" "../${_module_lower}" "../${_module_lower}-build" + "../../${module}/build-cmake" + "../../${_module_lower}/build-cmake" ) set (_guess_bin) foreach (_item IN ITEMS ${_guess}) From 9c1da9f5bff046896e20f3015e8e541b2d4dba2a Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 13:48:43 +0100 Subject: [PATCH 14/18] Bugfix don't search for module twice! --- cmake/Modules/OpmPackage.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index f385afa0..efeec037 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -130,7 +130,6 @@ macro (find_opm_package module deps header lib defs prog conf) foreach (_dep IN ITEMS ${deps}) separate_arguments (_args UNIX_COMMAND ${_dep}) find_and_append_package_to (${module} ${_args} ${${module}_QUIET}) - find_package (${_args} QUIET) list (GET _args 0 _name_only) list (APPEND _deps ${_name_only}) endforeach (_dep) From 6cfa13f1365c905fbc14e2f39b3d38eae21ee065 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Mar 2013 14:53:28 +0100 Subject: [PATCH 15/18] Allow precompiled headers to be enabled from command-line --- configure | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configure b/configure index 45ecda87..de1a3091 100755 --- a/configure +++ b/configure @@ -271,6 +271,10 @@ for OPT in "$@"; do # special flag; don't set shared/static shared="" ;; + pch) + pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON" + shared="" + ;; # this flag is just for compatibility with the deprecation # flag in DUNE, so we can build without warnings fieldvector-size-is-method) From 5401df41b573224a8c69a7992747e3586eb63051 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Sat, 16 Mar 2013 21:30:41 +0100 Subject: [PATCH 16/18] Use find modules for libraries with extra processing Some libraries require more information than what is present in the xxx-config.cmake file, e.g. the caller must know whether HAVE_TUPLE is available and probably used when compiling dune-common, and put this in its own config.h file. Code to take care of these variables must therefore be in the client configuration, and this is the same code which is used to handle the autotools version, namely the find module, so a practical solution is to just revert to that in both cases. --- cmake/Modules/OpmFind.cmake | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/cmake/Modules/OpmFind.cmake b/cmake/Modules/OpmFind.cmake index 11f4c2b9..8336ae47 100644 --- a/cmake/Modules/OpmFind.cmake +++ b/cmake/Modules/OpmFind.cmake @@ -51,6 +51,14 @@ foreach (name IN LISTS _opm_proj_vars) endif (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name}) endforeach (name) +# these dependencies must always be handled by the find module +set (_opm_proj_exemptions + dune-common + dune-istl + dune-grid + dune-geometry + ) + # insert this boilerplate whenever we are going to find a new package macro (find_and_append_package_to prefix name) # if we have specified a directory, don't revert to searching the @@ -71,6 +79,28 @@ macro (find_and_append_package_to prefix name) set (${name}_DIR "${${NAME}_ROOT}") endif (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake) endif (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT)) + + # these libraries need special handling which is not provided in + # the -config.cmake file, but which must be provided by this project, + # something which is done in our find module + list (FIND _opm_proj_exemptions "${name}" _${name}_exempted) + if ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR)) + # most often we are given the name to the build directory and this + # is a sub-directory of the source tree + if (${name}_DIR MATCHES "build") + get_filename_component (${name}_ROOT "${${name}_DIR}" PATH) + else (${name}_DIR MATCHES "build") + set (${name}_ROOT "${${name}_DIR}") + endif (${name}_DIR MATCHES "build") + # store this for later, in case we reconfigure + set (${name}_ROOT "${${name}_ROOT}" CACHE LOCATION "Path to ${name}") + # clear this to not use config mode + unset (${name}_DIR) + # variables that are given on the command-line is also put in the cache + # removing the local copy only "unshadows" this one + unset (${name}_DIR CACHE) + endif ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR)) + # 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 From 4d7752b9805b423a16c3f627ae259207ba9552b2 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Sat, 16 Mar 2013 23:40:09 +0100 Subject: [PATCH 17/18] Don't search for source in build directories --- cmake/Modules/OpmPackage.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index efeec037..5d9b5977 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -85,14 +85,16 @@ macro (find_opm_package module deps header lib defs prog conf) string (TOLOWER "${module}" _module_lower) set (_guess "../${module}" - "../${module}-build" "../${_module_lower}" + ) + set (_guess_bin_only + "../${module}-build" "../${_module_lower}-build" "../../${module}/build-cmake" "../../${_module_lower}/build-cmake" ) set (_guess_bin) - foreach (_item IN ITEMS ${_guess}) + foreach (_item IN ITEMS ${_guess} ${_guess_bin_only}) list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}") endforeach (_item) endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT)) From 040b7adb4e14340d15e05a8e8e40133894e4b362 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Sat, 16 Mar 2013 23:47:43 +0100 Subject: [PATCH 18/18] Search for libraries in dunecontrol's default build dir --- cmake/Modules/OpmPackage.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 5d9b5977..b35fa920 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -118,7 +118,7 @@ macro (find_opm_package module deps header lib defs prog conf) NAMES "${lib}" PATHS ${_guess_bin} HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS} - PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" + PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib" ) else (NOT "${lib}" STREQUAL "") set (${module}_LIBRARY "")