From 33a2d23a028741c7e71a8d1528786541d6440c57 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 27 Mar 2014 11:45:34 +0100 Subject: [PATCH 1/9] Export HAVE_DUNE_ISTL for other modules. This is e.g. needed in the parallel version of autodiff to test whether ISTL is there. --- cmake/Modules/opm-core-prereqs.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/opm-core-prereqs.cmake b/cmake/Modules/opm-core-prereqs.cmake index 8b3d45de1..b7cf3bf3e 100644 --- a/cmake/Modules/opm-core-prereqs.cmake +++ b/cmake/Modules/opm-core-prereqs.cmake @@ -5,6 +5,7 @@ set (opm-core_CONFIG_VAR HAVE_ERT HAVE_SUITESPARSE_UMFPACK_H + HAVE_DUNE_ISTL ) # dependencies From 81394512b4e71b033131d9e57dff4aecd6b87314 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Mon, 7 Apr 2014 19:32:18 +0200 Subject: [PATCH 2/9] Search for MPI support The build system depends on knowing if MPI is available. Explicitly search for MPI to honour that requirement. Don't rely on ISTL's transitive searching for the same. --- cmake/Modules/opm-core-prereqs.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/Modules/opm-core-prereqs.cmake b/cmake/Modules/opm-core-prereqs.cmake index b7cf3bf3e..8249a64b8 100644 --- a/cmake/Modules/opm-core-prereqs.cmake +++ b/cmake/Modules/opm-core-prereqs.cmake @@ -6,6 +6,7 @@ set (opm-core_CONFIG_VAR HAVE_ERT HAVE_SUITESPARSE_UMFPACK_H HAVE_DUNE_ISTL + HAVE_MPI ) # dependencies @@ -28,6 +29,8 @@ set (opm-core_DEPS "TinyXML" # Ensembles-based Reservoir Tools (ERT) "ERT" + # Look for MPI support + "MPI" # DUNE dependency "dune-common" "dune-istl" From cd95b9da9d07e7cc1e4cb804316d01777d975da4 Mon Sep 17 00:00:00 2001 From: Arne Morten Kvarving Date: Wed, 5 Mar 2014 09:12:35 +0100 Subject: [PATCH 3/9] add option to quell dune(-istl) warnings --- cmake/Modules/UseWarnings.cmake | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index 8e42423d6..399cd066f 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -12,3 +12,17 @@ if (CXX_COMPAT_GCC) add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}") endif (_warn_flag) endif () + +option(SILENCE_DUNE_WARNINGS "Disable warnings from DUNE?" OFF) +if(SILENCE_DUNE_WARNINGS AND CXX_COMPAT_GCC) + file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h " +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored \"-Wshadow\" +#pragma GCC diagnostic ignored \"-Wunused-parameter\" +#pragma GCC diagnostic ignored \"-Wignored-qualifiers\" +#pragma GCC diagnostic ignored \"-Wmismatched-tags\"") + file(WRITE ${CMAKE_BINARY_DIR}/dune_reenable_pragmas.h "#pragma GCC diagnostic pop") +else() + file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h "") + file(WRITE ${CMAKE_BINARY_DIR}/dune_reenable_pragmas.h "") +endif() From 682d8c394edd0152bcff9655f726b8a3c0b1cac0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 Apr 2014 19:46:16 +0200 Subject: [PATCH 4/9] Added more warnings to suppression list, sorted list. --- cmake/Modules/UseWarnings.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index 399cd066f..bb92657b4 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -17,10 +17,13 @@ option(SILENCE_DUNE_WARNINGS "Disable warnings from DUNE?" OFF) if(SILENCE_DUNE_WARNINGS AND CXX_COMPAT_GCC) file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h " #pragma GCC diagnostic push -#pragma GCC diagnostic ignored \"-Wshadow\" -#pragma GCC diagnostic ignored \"-Wunused-parameter\" +#pragma GCC diagnostic ignored \"-Wdeprecated-declarations\" +#pragma GCC diagnostic ignored \"-Wdeprecated-register\" #pragma GCC diagnostic ignored \"-Wignored-qualifiers\" -#pragma GCC diagnostic ignored \"-Wmismatched-tags\"") +#pragma GCC diagnostic ignored \"-Wmismatched-tags\" +#pragma GCC diagnostic ignored \"-Wshadow\" +#pragma GCC diagnostic ignored \"-Wsign-compare\" +#pragma GCC diagnostic ignored \"-Wunused-parameter\"") file(WRITE ${CMAKE_BINARY_DIR}/dune_reenable_pragmas.h "#pragma GCC diagnostic pop") else() file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h "") From 5b79c0247f5fa3eb22c1e8e95c6aadbd3792960e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 15 Apr 2014 20:21:10 +0200 Subject: [PATCH 5/9] Change option name and generated header names. --- cmake/Modules/UseWarnings.cmake | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index bb92657b4..c4cab18d8 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -14,8 +14,8 @@ if (CXX_COMPAT_GCC) endif () option(SILENCE_DUNE_WARNINGS "Disable warnings from DUNE?" OFF) -if(SILENCE_DUNE_WARNINGS AND CXX_COMPAT_GCC) - file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h " +if(SILENCE_EXTERNAL_WARNINGS AND CXX_COMPAT_GCC) + file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h " #pragma GCC diagnostic push #pragma GCC diagnostic ignored \"-Wdeprecated-declarations\" #pragma GCC diagnostic ignored \"-Wdeprecated-register\" @@ -24,8 +24,8 @@ if(SILENCE_DUNE_WARNINGS AND CXX_COMPAT_GCC) #pragma GCC diagnostic ignored \"-Wshadow\" #pragma GCC diagnostic ignored \"-Wsign-compare\" #pragma GCC diagnostic ignored \"-Wunused-parameter\"") - file(WRITE ${CMAKE_BINARY_DIR}/dune_reenable_pragmas.h "#pragma GCC diagnostic pop") + file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "#pragma GCC diagnostic pop") else() - file(WRITE ${CMAKE_BINARY_DIR}/dune_disable_pragmas.h "") - file(WRITE ${CMAKE_BINARY_DIR}/dune_reenable_pragmas.h "") + file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "") + file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "") endif() From 73db2c388c76313286298b12cbbb1042369eda55 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Tue, 1 Apr 2014 16:22:46 +0200 Subject: [PATCH 6/9] add support for the UG grid library recently UG has become free software (yay!), so we can now support it with a good conscience. The CMake module is based on the "UseUG.cmake" module of dune-grid but it is quite a bit simpler and actually works. (I cannot see how UseUG.cmake can work without ever including the ug-config*.cmake files...) the UG source code is available here: https://github.com/ugfem/ug --- cmake/Modules/FindUG.cmake | 112 ++++++++++++++++++++++++++++++ cmake/Modules/Finddune-grid.cmake | 3 +- cmake/Scripts/configure | 2 + 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 cmake/Modules/FindUG.cmake diff --git a/cmake/Modules/FindUG.cmake b/cmake/Modules/FindUG.cmake new file mode 100644 index 000000000..b1f8ea6ae --- /dev/null +++ b/cmake/Modules/FindUG.cmake @@ -0,0 +1,112 @@ +# +# This module first tests for UG and then sets the necessary flags +# and config.h defines. If UG is found UG_FOUND will be true. +# + +# this function is required in order not to pollute the global +# namespace with the macros defined in ug-config*.cmake +function(opmFindUg) + if(NOT UG_ROOT) + # check whether UG is in /usr/local + if(EXISTS "/usr/local/include/ug") + set(UG_ROOT "/usr/local") + + # check whether UG is in /usr + elseif(EXISTS "/usr/include/ug") + set(UG_ROOT "/usr") + + # oops + else() + message(STATUS "Could not find UG. It seems to be not installed.") + return() + endif() + endif() + + if(UG_ROOT AND NOT UG_DIR) + # define the directory where the config file resides + if(EXISTS "${UG_ROOT}/lib/cmake/ug/ug-config.cmake") + set(UG_DIR ${UG_ROOT}/lib/cmake/ug) + elseif(EXISTS "${UG_ROOT}/lib64/cmake/ug/ug-config.cmake") + set(UG_DIR ${UG_ROOT}/lib64/cmake/ug) + else() + message(WARNING "Could not find file ug-config.cmake relative to given UG_ROOT") + return() + endif() + endif() + + # include the config mode files kindly provided by UG... + include(${UG_DIR}/ug-config-version.cmake) + include(${UG_DIR}/ug-config.cmake) + + set(UG_FOUND "1") + if(NOT UG_FOR_DUNE STREQUAL "yes") + set(UG_FOUND "0") + message(WARNING "UG was not configured for DUNE. Did pass --enable-dune to its configure?") + return() + endif() + + set(HAVE_UG ${UG_FOUND}) + + # parse version + string(REGEX REPLACE "([0-9]*)\\.[0-9]*\\..*" "\\1" UG_VERSION_MAJOR "${PACKAGE_VERSION}") + string(REGEX REPLACE "[0-9]*\\.([0-9]*)\\..*" "\\1" UG_VERSION_MINOR "${PACKAGE_VERSION}") + string(REGEX REPLACE "[0-9]*\\.[0-9]*\\.([0-9]*).*" "\\1" UG_VERSION_REVISION "${PACKAGE_VERSION}") + + string(REGEX REPLACE ".*-patch([0-9]*)" "\\1" TMP "${PACKAGE_VERSION}") + if(TMP STREQUAL "${PACKAGE_VERSION}") + set(UG_VERSION_PATCHLEVEL "") + else() + set(UG_VERSION_PATCHLEVEL "${TMP}") + endif() + + # Adjust compiler/linker arguments + set(UG_LIBRARY_DIR "${libdir}") + + foreach (UG_RAW_LIB "-lugS2" "-lugS3" "-ldevS") + string(REGEX REPLACE "-l(.*)" "\\1" UG_LIB "${UG_RAW_LIB}") + set(UG_LIB_FILE "${UG_LIBRARY_DIR}/lib${UG_LIB}.a") + if (EXISTS "${UG_LIB_FILE}") + set(UG_LIBS "${UG_LIBS}" ${UG_LIB_FILE}) + else() + set(UG_LIBS "${UG_LIBS}" ${UG_LIB}) + endif() + endforeach() + + set(UG_LIBRARIES "${UG_LIBS}") + + # export all variables which need to be seen globally + set(UG_FOUND "${UG_FOUND}" PARENT_SCOPE) + set(HAVE_UG "${HAVE_UG}" PARENT_SCOPE) + set(UG_INCLUDE_DIRS "${UG_INCLUDES}" PARENT_SCOPE) + set(UG_LIBRARIES "${UG_LIBRARIES}" PARENT_SCOPE) + set(UG_VERSION_MAJOR "${UG_VERSION_MAJOR}" PARENT_SCOPE) + set(UG_VERSION_MINOR "${UG_VERSION_MINOR}" PARENT_SCOPE) + set(UG_VERSION_REVISION "${UG_VERSION_REVISION}" PARENT_SCOPE) + set(UG_VERSION_PATCHLEVEL "${UG_VERSION_PATCHLEVEL}" PARENT_SCOPE) + + set(UG_DEFINITIONS "${UG_COMPILE_FLAGS}" PARENT_SCOPE) +endfunction() + +if (NOT HAVE_UG) + opmFindUg() + + set(HAVE_UG "${HAVE_UG}" CACHE BOOL "UG library is available") + set(UG_INCLUDE_DIRS "${UG_INCLUDE_DIRS}" CACHE STRING "Directory containing the headers of the UG library") + set(UG_LIBRARIES "${UG_LIBRARIES}" CACHE STRING "The libraries which need to be linked to be able to use the UG library") + set(UG_DEFINITIONS "${UG_DEFINITIONS}" CACHE STRING "The compiler flags for the UG library") + set(UG_VERSION_MAJOR "${UG_VERSION_MAJOR}" CACHE INT "Major version of the UG release") + set(UG_VERSION_MINOR "${UG_VERSION_MINOR}" CACHE INT "Minor version of the UG release") + set(UG_VERSION_REVISION "${UG_VERSION_REVISION}" CACHE INT "Revision of the UG release") + set(UG_VERSION_PATCHLEVEL "${UG_VERSION_PATCHLEVEL}" CACHE INT "Patchlevel of the UG release") + + mark_as_advanced(HAVE_UG) + mark_as_advanced(UG_INCLUDE_DIRS) + mark_as_advanced(UG_LIBRARIES) + mark_as_advanced(UG_DEFINITIONS) + mark_as_advanced(UG_VERSION_MAJOR) + mark_as_advanced(UG_VERSION_MINOR) + mark_as_advanced(UG_VERSION_REVISION) + mark_as_advanced(UG_VERSION_PATCHLEVEL) +else() + set(UG_FOUND "0") +endif() diff --git a/cmake/Modules/Finddune-grid.cmake b/cmake/Modules/Finddune-grid.cmake index dd04e0de6..4fa53ae8b 100644 --- a/cmake/Modules/Finddune-grid.cmake +++ b/cmake/Modules/Finddune-grid.cmake @@ -23,7 +23,8 @@ find_opm_package ( dune-common REQUIRED; dune-geometry REQUIRED; MPI; - ALUGrid + ALUGrid; + UG " # header to search for "dune/grid/onedgrid.hh" diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 69ba2ce45..c87eecf18 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -36,6 +36,7 @@ Optional Features: --config-cache Reuse build configuration cache from a previous run Optional Packages: + --with-ug=PATH use the UG libraries from a specified location --with-alugrid=PATH use the ALUGrid library from a specified location --with-metis=PATH use the METIS graph partitioning library from a specified location --with-boost=PATH use Boost library from a specified location @@ -256,6 +257,7 @@ for OPT in "$@"; do superlu |\ SuiteSparse |\ TinyXML |\ + ug |\ opm |\ opm-* |\ dune |\ From d3ec9f63ff02e2fcc0260ebbcfbc95d16057f5e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Atgeirr=20Fl=C3=B8=20Rasmussen?= Date: Tue, 22 Apr 2014 09:50:29 +0200 Subject: [PATCH 7/9] Fix option name to match name in use in conditional. Also add a useful doc string. --- cmake/Modules/UseWarnings.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index c4cab18d8..82bf81913 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -13,7 +13,7 @@ if (CXX_COMPAT_GCC) endif (_warn_flag) endif () -option(SILENCE_DUNE_WARNINGS "Disable warnings from DUNE?" OFF) +option(SILENCE_EXTERNAL_WARNINGS "Disable some warnings from external packages (requires GCC 4.6 or newer)" OFF) if(SILENCE_EXTERNAL_WARNINGS AND CXX_COMPAT_GCC) file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h " #pragma GCC diagnostic push From 4fd75a4433a3521da4cd5f08fbb0aabb6a5e4d90 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 16 Apr 2014 11:54:07 +0200 Subject: [PATCH 8/9] do not add the "-Wl,--as-needed" linker flag in FindSuiteSparse.cmake because if umfpack is fully linked but some other library is underlinked, it causes the build to fail. This flag is better dealt with in the "UseOnlyNeeded.cmake" module... --- cmake/Modules/FindSuiteSparse.cmake | 8 -------- 1 file changed, 8 deletions(-) diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index b23303c1c..0b77b836c 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -232,14 +232,6 @@ if (UMFPACK_LIBRARY) set (UMFPACK_EXTRA_LIBS "-NOTFOUND") endif (CHOLMOD_LIBRARIES) endif (HAVE_UMFPACK_WITHOUT_CHOLMOD) - # test if umfpack is underlinked (CentOS 5.9), i.e. doesn't specify - # that it depends on amd. in that case, force amd to be linked - if (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC) - try_compile_umfpack (HAVE_UMFPACK_NOT_UNDERLINKED "-Wl,--as-needed" ${UMFPACK_EXTRA_LIBS}) - if (NOT HAVE_UMFPACK_NOT_UNDERLINKED) - list (APPEND UMFPACK_LINKER_FLAGS "-Wl,--no-as-needed") - endif (NOT HAVE_UMFPACK_NOT_UNDERLINKED) - endif (UMFPACK_EXTRA_LIBS AND (CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC) list (APPEND UMFPACK_LIBRARIES ${UMFPACK_EXTRA_LIBS}) list (REVERSE UMFPACK_LIBRARIES) list (REMOVE_DUPLICATES UMFPACK_LIBRARIES) From d9920e34eb3fb6e89d5d8b4c607f20ee90a979ff Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 16 Apr 2014 11:57:25 +0200 Subject: [PATCH 9/9] make the "-Wl,--as-needed" flag optional as there is not much harm done if it is not used but it may cause the build to fail if it is present (read: it causes _my_ build to fail), it defaults to OFF. --- cmake/Modules/UseOnlyNeeded.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/UseOnlyNeeded.cmake b/cmake/Modules/UseOnlyNeeded.cmake index 16f3d078a..8a195bf48 100644 --- a/cmake/Modules/UseOnlyNeeded.cmake +++ b/cmake/Modules/UseOnlyNeeded.cmake @@ -23,9 +23,11 @@ function (prepend var_name value) endif (NOT ("${_var_pre}" STREQUAL "${value}")) endfunction (prepend var_name value) +option (ONLY_NEEDED_LIBRARIES "Instruct the linker to not use libraries which are unused" OFF) + # only ELF shared objects can be underlinked, and only GNU will accept # these parameters; otherwise just leave it to the defaults -if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC) +if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES) # these are the modules whose probes will turn up incompatible # flags on some systems set (_maybe_underlinked @@ -45,4 +47,4 @@ if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC) prepend (CMAKE_MODULE_LINKER_FLAGS "-Wl,--as-needed") prepend (CMAKE_SHARED_LINKER_FLAGS "-Wl,--as-needed") endif (NOT _underlinked) -endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC) +endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC AND ONLY_NEEDED_LIBRARIES)