Merge pull request #161 from rolk/161_findmods

Provide extra find modules for all OPM modules
This commit is contained in:
Atgeirr Flø Rasmussen 2013-03-04 01:17:26 -08:00
commit 7fe7ead8d0
14 changed files with 376 additions and 25 deletions

View File

@ -203,12 +203,11 @@ configure_vars (
WRITE ${${project}_CONFIG_VARS}
)
### --- begin AGMG specific --- ###
include (UseFortranWrappers)
define_fc_func (
APPEND ${CONFIG_H}
IF HAVE_AGMG # HAVE_BLAS HAVE_LAPACK
)
### --- end AGMG specific --- ###
# compile main library; pull in all required includes and libraries
include (OpmCompile)

View File

@ -0,0 +1,42 @@
# - Find OPM corner-point grid library
#
# Defines the following variables:
# dune-cornerpoint_INCLUDE_DIRS Directory of header files
# dune-cornerpoint_LIBRARIES Directory of shared object files
# dune-cornerpoint_DEFINITIONS Defines that must be set to compile
# dune-cornerpoint_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_CORNERPOINT Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
opm-core REQUIRED
"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
""
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"")
#debug_find_vars ("dune-cornerpoint")

View File

@ -0,0 +1,47 @@
# - Find DUNE geometry library
#
# Defines the following variables:
# dune-geometry_INCLUDE_DIRS Directory of header files
# dune-geometry_LIBRARIES Directory of shared object files
# dune-geometry_DEFINITIONS Defines that must be set to compile
# dune-geometry_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_GEOMETRY Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-geometry"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-common REQUIRED
"
# header to search for
"dune/geometry/quadraturerules.hh"
# library to search for
"dunegeometry"
# defines to be added to compilations
""
# test program
"#include <dune/geometry/quadraturerules.hh>
int main (void) {
Dune::GeometryType gt;
gt.makeQuadrilateral();
Dune::QuadratureRules<double, 2>::rule(gt, 2).size();
return 0;
}
"
# config variables
"HAVE_ALGLIB
")
#debug_find_vars ("dune-geometry")

View File

@ -0,0 +1,58 @@
# - Find DUNE grid library
#
# Defines the following variables:
# dune-grid_INCLUDE_DIRS Directory of header files
# dune-grid_LIBRARIES Directory of shared object files
# dune-grid_DEFINITIONS Defines that must be set to compile
# dune-grid_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_GRID Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-grid"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-common REQUIRED;
dune-geometry REQUIRED
"
# header to search for
"dune/grid/onedgrid.hh"
# library to search for
"dunegrid"
# defines to be added to compilations
""
# test program
"#include <dune/grid/onedgrid.hh>
#include <vector>
int main (void) {
std::vector<Dune::OneDGrid::ctype> coords;
Dune::OneDGrid grid(coords);
return grid.lbegin<0>(0) == grid.lend<0>(0);
return 0;
}
"
# config variables
"HAVE_MPI;
HAVE_UG;
HAVE_DUNE_FEM;
HAVE_ALUGRID;
HAVE_GRIDTYPE;
HAVE_GRAPE;
HAVE_PSURFACE;
HAVE_AMIRAMESH;
HAVE_ALBERTA;
HAVE_STDINT_H
")
#debug_find_vars ("dune-grid")

View File

@ -17,14 +17,16 @@ find_opm_package (
"opm-core"
# dependencies
"CXX11Features REQUIRED;
"C99;
CXX11Features;
Boost 1.39.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED;
BLAS REQUIRED;
LAPACK REQUIRED;
SuiteSparse COMPONENTS umfpack;
SUPERLU;
LibXml2 REQUIRED;
Boost 1.39.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED;
TinyXML;
ERT;
dune-istl
"
# header to search for

View File

@ -0,0 +1,41 @@
# - Find OPM polymer library
#
# Defines the following variables:
# opm-polymer_INCLUDE_DIRS Directory of header files
# opm-polymer_LIBRARIES Directory of shared object files
# opm-polymer_DEFINITIONS Defines that must be set to compile
# opm-polymer_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_POLYMER Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-polymer"
# dependencies
"ERT;
opm-core REQUIRED
"
# header to search for
"opm/polymer/PolymerState.hpp"
# library to search for
"opmpolymer"
# defines to be added to compilations
""
# test program
"#include <opm/polymer/PolymerState.hpp>
int main (void) {
Opm::PolymerState s;
return 0;
}
"
# config variables
"HAVE_ERT")
#debug_find_vars ("opm-polymer")

View File

@ -0,0 +1,43 @@
# - Find OPM porous media solver library
#
# Defines the following variables:
# opm-porsol_INCLUDE_DIRS Directory of header files
# opm-porsol_LIBRARIES Directory of shared object files
# opm-porsol_DEFINITIONS Defines that must be set to compile
# opm-porsol_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_PORSOL Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-porsol"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-istl REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED
"
# header to search for
"opm/porsol/mimetic/IncompFlowSolverHybrid.hpp"
# library to search for
"opmporsol"
# defines to be added to compilations
""
# test program
"#include <opm/porsol/mimetic/IncompFlowSolverHybrid.hpp>
int main (void) {
return 0;
}
"
# config variables
"HAVE_VALGRIND")
#debug_find_vars ("opm-porsol")

View File

@ -0,0 +1,44 @@
# - Find OPM upscaling grid library
#
# Defines the following variables:
# opm-upscaling_INCLUDE_DIRS Directory of header files
# opm-upscaling_LIBRARIES Directory of shared object files
# opm-upscaling_DEFINITIONS Defines that must be set to compile
# opm-upscaling_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_UPSCALING Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"opm-upscaling"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-istl REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED;
opm-porsol REQUIRED;
"
# header to search for
"opm/upscaling/SinglePhaseUpscaler.hpp"
# library to search for
"opmupscaling"
# defines to be added to compilations
""
# test program
"#include <opm/upscaling/SinglePhaseUpscaler.hpp>
int main (void) {
return 0;
}
"
# config variables
"HAVE_SUPERLU")
#debug_find_vars ("opm-upscaling")

View File

@ -40,6 +40,27 @@ macro (opm_sources opm)
set (${opm}_HEADERS ${${opm}_C_HEADERS} ${${opm}_CXX_HEADERS})
endmacro (opm_sources opm)
# disable an entire directory from sources
macro (opm_disable_source opm)
foreach (_exp IN ITEMS ${ARGN})
# regexp or directory?
if (IS_ABSOLUTE "${_exp}")
set (_prefix "")
else (IS_ABSOLUTE "${_exp}")
set (_prefix "${PROJECT_SOURCE_DIR}/")
endif (IS_ABSOLUTE "${_exp}")
if (IS_DIRECTORY "${_prefix}${_exp}")
set (_glob "/*")
else (IS_DIRECTORY "${_prefix}${_exp}")
set (_glob "")
endif (IS_DIRECTORY "${_prefix}${_exp}")
file (GLOB_RECURSE _disabled RELATIVE ${PROJECT_SOURCE_DIR} "${_prefix}${_exp}${_glob}")
foreach (_file IN ITEMS ${_disabled})
list (REMOVE_ITEM ${opm}_SOURCES "${PROJECT_SOURCE_DIR}/${_file}")
endforeach (_file)
endforeach (_exp)
endmacro (opm_disable_source opm reldir)
macro (opm_find_tests)
# every C++ program prefixed with test_ under tests/ directory should
# be automatically set up as a test

View File

@ -80,6 +80,11 @@ macro (find_and_append_package_to prefix name)
endif ("${var}" STREQUAL "LIBRARIES")
endif (DEFINED ${name}_${var})
endforeach (var)
# some libraries only define xxx_FOUND and not a corresponding HAVE_xxx
string (TOUPPER "${name}" NAME)
if (NOT DEFINED HAVE_${NAME})
set (HAVE_${NAME} 1)
endif (NOT DEFINED HAVE_${NAME})
endif (${name}_FOUND)
endmacro (find_and_append_package_to prefix name)

View File

@ -87,9 +87,16 @@ function (find_opm_package module deps header lib defs prog conf)
# but with a -build suffix
if (NOT (${module}_DIR OR ${module}_ROOT))
string (TOLOWER "${module}" _module_lower)
set (_guess "../${module}" "../${module}-build"
"../${_module_lower}" "../${_module_lower}-build"
set (_guess
"../${module}"
"../${module}-build"
"../${_module_lower}"
"../${_module_lower}-build"
)
set (_guess_bin)
foreach (_item IN ITEMS ${_guess})
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item)
endif (NOT (${module}_DIR OR ${module}_ROOT))
# search for this include and library file to get the installation
@ -106,7 +113,7 @@ function (find_opm_package module deps header lib defs prog conf)
if (NOT "${lib}" STREQUAL "")
find_library (${module}_LIBRARY
NAMES "${lib}"
PATHS ${_guess}
PATHS ${_guess_bin}
HINTS ${${module}_DIR} ${${module}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
)
@ -119,11 +126,15 @@ function (find_opm_package module deps header lib defs prog conf)
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIR}")
set (${module}_LIBRARIES "${${module}_LIBRARY}")
foreach (_dep IN LISTS _deps)
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})
# 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)
endforeach (_dep)
# compile with this option to avoid avalanche of warnings
@ -164,7 +175,7 @@ function (find_opm_package module deps header lib defs prog conf)
include (CheckCXXSourceCompiles)
# only add these if they are actually found; otherwise it won't
# compile and the variable won't be set
append_found (${module}_INCLUDE_DIR CMAKE_REQUIRED_INCLUDES)
append_found (${module}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
# since we don't have any config.h yet
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})

View File

@ -1,7 +1,7 @@
# - Provide C wrappers for Fortran code
#
# Synopsis:
# define_fc_func (APPEND config.h)
# define_fc_func (APPEND config.h IF HAVE_BLAS)
function (define_fc_func verb file)
# check that we are being called correctly
@ -13,10 +13,40 @@ function (define_fc_func verb file)
endif (NOT (("${verb}" STREQUAL "APPEND") OR
("${verb}" STREQUAL "WRITE")))
# check under which conditions we should do our work
if (NOT "${ARGN}" STREQUAL "")
set (args ${ARGN})
list (GET args 0 keyword)
if (NOT "${keyword}" STREQUAL "IF")
message (FATAL_ERROR
"Unknown conditional \"${keyword}\" passed as third argument."
)
endif (NOT "${keyword}" STREQUAL "IF")
list (REMOVE_AT args 0)
set (needed FALSE)
foreach (condition IN LISTS args)
if (${${condition}})
set (needed TRUE)
break ()
endif (${${condition}})
endforeach (condition)
else (NOT "${ARGN}" STREQUAL "")
# if called unconditionally, then always include the wrapper
set (needed TRUE)
endif (NOT "${ARGN}" STREQUAL "")
# only do something if we actually have some components which requires
# the interaction -- don't load the Fortran compiler just to write
# this macro (which apparently nobody uses then)
if (CMAKE_C_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_LOADED)
if (needed)
# enable languages needed
if (NOT CMAKE_C_COMPILER_LOADED)
enable_language (C)
endif (NOT CMAKE_C_COMPILER_LOADED)
if (NOT CMAKE_Fortran_COMPILER_LOADED)
enable_language (Fortran)
endif (NOT CMAKE_Fortran_COMPILER_LOADED)
# get a temporary file
set (_tmp_hdr ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp/config_f.h)
@ -42,7 +72,7 @@ function (define_fc_func verb file)
${_str}
"\n"
)
else (CMAKE_C_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_LOADED)
else (needed)
message (STATUS "Fortran/C interface not activated")
endif (CMAKE_C_COMPILER_LOADED AND CMAKE_Fortran_COMPILER_LOADED)
endif (needed)
endfunction (define_fc_func)

View File

@ -97,6 +97,11 @@ function (precompile_header
else (language STREQUAL "CXX")
message (FATAL "Only C or C++ can have precompiled headers")
endif (language STREQUAL "CXX")
# if no precompiled header was found, then we shouldn't do anything here
if (NOT header)
return ()
endif (NOT header)
# only support precompiled headers if the compiler is gcc >= 3.4
get_gcc_version (${language} GCC_VERSION)

15
configure vendored
View File

@ -1,7 +1,10 @@
#!/bin/bash
# where is the source tree located
srcdir=$(dirname "$0")
# name of the project
project=opm-core
project=$(sed -n "s,^Module:[\ \t]*\([^\ \t]*\),\1,p" "${srcdir}/dune.module")
# display help text
usage () {
@ -26,8 +29,8 @@ Optional Features:
Optional Packages:
--with-boost=PATH use Boost library from a specified location
--with-dune-common=PATH use DUNE-common library from a specified location
--with-dune-istl=PATH use DUNE-ISTL library from a specified location
--with-dune-MODULE=PATH use given DUNE module from a specified location
--with-opm-MODULE=PATH use given OPM module from a specified location
--with-superlu=PATH user defined path to SuperLU library
--with-agmg=PATH Include DOUBLE PRECISION version Notay's of AGMG
Algebraic Multigrid solver from specified source
@ -159,8 +162,8 @@ while getopts -- ":-:" optchar; do
;;
SuiteSparse |\
TinyXML |\
dune-istl |\
dune-common)
opm-* |\
dune-*)
rootvar="${pkgname}_ROOT"
;;
*)
@ -280,7 +283,7 @@ shift $((OPTIND-1))
ENVVARS=${@/ACLOCAL_*=*/}
# pass everything on to CMake
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}"
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}"
echo --- calling CMake for ${project} ---
echo ${CMDLINE}
eval exec ${CMDLINE}