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) 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/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) diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index 8e42423d6..82bf81913 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -12,3 +12,20 @@ if (CXX_COMPAT_GCC) add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}") endif (_warn_flag) endif () + +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 +#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 \"-Wshadow\" +#pragma GCC diagnostic ignored \"-Wsign-compare\" +#pragma GCC diagnostic ignored \"-Wunused-parameter\"") + file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "#pragma GCC diagnostic pop") +else() + file(WRITE ${CMAKE_BINARY_DIR}/disable_warning_pragmas.h "") + file(WRITE ${CMAKE_BINARY_DIR}/reenable_warning_pragmas.h "") +endif() diff --git a/cmake/Modules/opm-core-prereqs.cmake b/cmake/Modules/opm-core-prereqs.cmake index 8b3d45de1..8249a64b8 100644 --- a/cmake/Modules/opm-core-prereqs.cmake +++ b/cmake/Modules/opm-core-prereqs.cmake @@ -5,6 +5,8 @@ set (opm-core_CONFIG_VAR HAVE_ERT HAVE_SUITESPARSE_UMFPACK_H + HAVE_DUNE_ISTL + HAVE_MPI ) # dependencies @@ -27,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" 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 |\