Compile and link Algebraic Multigrid, if available
If the path to Notay's AGMG library is provided through the cache variable AGMG_ROOT, then include this in the build and enable the test. It would have been desirable to use the variable name AGMG_DIR for consistency with the other modules, but unfortunately this name will alter the functionality of CMake's find_package.
This commit is contained in:
@@ -71,17 +71,26 @@ set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
|
||||
file (GLOB_RECURSE opmcore_SOURCES "opm/core/*.c" "opm/core/*.cpp")
|
||||
file (GLOB_RECURSE opmcore_HEADERS "opm/core/*.h" "opm/core/*.hpp")
|
||||
|
||||
# Algebraic Multigrid must be compiled together with our program;
|
||||
# if it is not available, then remove our corresponding component
|
||||
find_package (AGMG)
|
||||
if (AGMG_FOUND)
|
||||
list (APPEND opmcore_SOURCES ${AGMG_SOURCES})
|
||||
else (AGMG_FOUND)
|
||||
list (REMOVE_ITEM opmcore_SOURCES
|
||||
${PROJECT_SOURCE_DIR}/opm/core/linalg/LinearSolverAGMG.cpp
|
||||
)
|
||||
endif (AGMG_FOUND)
|
||||
|
||||
# these files are provided in source control, but can only compile with Matlab
|
||||
# available
|
||||
list (REMOVE_ITEM opmcore_SOURCES
|
||||
${PROJECT_SOURCE_DIR}/opm/core/grid/cpgpreprocess/mxgrdecl.c
|
||||
${PROJECT_SOURCE_DIR}/opm/core/grid/cpgpreprocess/processgrid.c
|
||||
${PROJECT_SOURCE_DIR}/opm/core/utility/parameters/tinyxml/xmltest.cpp
|
||||
${PROJECT_SOURCE_DIR}/opm/core/linalg/LinearSolverAGMG.cpp
|
||||
)
|
||||
|
||||
# we don't try to find any of these
|
||||
set (HAVE_AGMG 0)
|
||||
set (HAVE_ERT)
|
||||
|
||||
# create configuration header which describes available features
|
||||
@@ -103,6 +112,10 @@ configure_vars (
|
||||
FILE CXX "${PROJECT_BINARY_DIR}/config.h"
|
||||
WRITE ${opm-core_CONFIG_VARS}
|
||||
)
|
||||
include (UseFortranWrappers)
|
||||
define_fc_func (
|
||||
APPEND "${PROJECT_BINARY_DIR}/config.h"
|
||||
)
|
||||
|
||||
# some CMake properties do not do list expansion
|
||||
string (REPLACE ";" " " opm-core_LINKER_FLAGS_STR "${opm-core_LINKER_FLAGS}")
|
||||
|
||||
44
cmake/Modules/FindAGMG.cmake
Normal file
44
cmake/Modules/FindAGMG.cmake
Normal file
@@ -0,0 +1,44 @@
|
||||
# - Find Notay's Algebraic Multigrid Solver
|
||||
#
|
||||
# Set the path to the source directory of AGMG in the cache variable
|
||||
# AGMG_ROOT.
|
||||
#
|
||||
# Note the difference between AGMG_DIR and AGMG_ROOT. The former will
|
||||
# cause find_package to switch to config mode and search for a file
|
||||
# named agmg-config.cmake, thereby bypassing this module altogether,
|
||||
# whereas the latter communicates the location of the library to this
|
||||
# module.
|
||||
#
|
||||
# When found, add the contents of AGMG_SOURCES to your own list of
|
||||
# sources to compile and link for the target.
|
||||
#
|
||||
# Use define_fc_func from UseFortranWrappers to write FC_FUNC to your
|
||||
# own config.h, and declare the function dagmg using this macro.
|
||||
|
||||
find_file (AGMG_SOURCES
|
||||
dagmg.f90
|
||||
PATHS ${AGMG_ROOT}
|
||||
PATH_SUFFIXES SRC
|
||||
DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
||||
# make sure that we can compile Fortran code
|
||||
if (AGMG_SOURCES)
|
||||
enable_language (Fortran)
|
||||
endif (AGMG_SOURCES)
|
||||
|
||||
# set value for config.h
|
||||
if (AGMG_SOURCES)
|
||||
set (HAVE_AGMG 1)
|
||||
else (AGMG_SOURCES)
|
||||
set (HAVE_AGMG 0)
|
||||
endif (AGMG_SOURCES)
|
||||
|
||||
# handle REQUIRED and QUIET standard options
|
||||
include (FindPackageHandleStandardArgs)
|
||||
find_package_handle_standard_args (AGMG
|
||||
DEFAULT_MSG
|
||||
AGMG_SOURCES
|
||||
CMAKE_Fortran_COMPILER_SUPPORTS_F90
|
||||
)
|
||||
Reference in New Issue
Block a user