2013-05-15 03:40:00 -05:00
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
2013-08-02 07:07:33 -05:00
###########################################################################
# #
# Note: The bulk of the build system is located in the cmake/ directory. #
# This file only contains the specializations for this particular #
# project. Most likely you are interested in editing one of these #
# files instead: #
# #
# dune.module Name and version number #
# CMakeLists_files.cmake Path of source files #
# cmake/Modules/${project}-prereqs.cmake Dependencies #
# #
###########################################################################
2013-05-15 03:40:00 -05:00
cmake_minimum_required ( VERSION 2.8 )
2015-09-08 04:56:28 -05:00
set ( OPM_COMMON_ROOT "" CACHE PATH "Root directory containing OPM related cmake modules" )
2015-05-27 04:51:28 -05:00
option ( SIBLING_SEARCH "Search for other modules in sibling directories?" ON )
2015-10-19 08:21:08 -05:00
set ( USE_OPENMP_DEFAULT OFF ) # Use of OpenMP is considered experimental
2015-03-18 08:26:29 -05:00
2015-09-08 04:56:28 -05:00
if ( NOT OPM_COMMON_ROOT )
2015-09-08 03:47:05 -05:00
find_package ( opm-common QUIET )
2015-05-27 03:48:30 -05:00
endif ( )
2015-03-18 08:26:29 -05:00
2015-09-08 03:47:05 -05:00
if ( opm-common_FOUND )
2015-05-27 03:48:30 -05:00
include ( OpmInit )
2015-03-18 08:26:29 -05:00
else ( )
2015-09-16 07:22:24 -05:00
unset ( opm-common_FOUND )
2015-09-08 04:56:28 -05:00
if ( NOT OPM_COMMON_ROOT AND SIBLING_SEARCH )
set ( OPM_COMMON_ROOT ${ PROJECT_SOURCE_DIR } /../opm-common )
2015-05-27 04:51:28 -05:00
endif ( )
2015-09-08 04:56:28 -05:00
if ( OPM_COMMON_ROOT )
list ( APPEND CMAKE_MODULE_PATH "${OPM_COMMON_ROOT}/cmake/Modules" )
2015-03-18 08:26:29 -05:00
include ( OpmInit OPTIONAL RESULT_VARIABLE OPM_INIT )
2015-09-08 04:56:28 -05:00
set ( OPM_MACROS_ROOT ${ OPM_COMMON_ROOT } )
2015-03-18 08:26:29 -05:00
endif ( )
if ( NOT OPM_INIT )
2015-05-27 03:48:30 -05:00
message ( "" )
2015-09-08 04:56:28 -05:00
message ( " /---------------------------------------------------------------------------------\\" )
message ( " | Could not locate the opm build macros. The opm build macros |" )
message ( " | are in a separate repository - instructions to proceed: |" )
message ( " | |" )
message ( " | 1. Clone the repository: git clone git@github.com:OPM/opm-common.git |" )
message ( " | |" )
message ( " | 2. Run cmake in the current project with -DOPM_COMMON_ROOT=<path>/opm-common |" )
message ( " | |" )
message ( " \\---------------------------------------------------------------------------------/" )
2015-05-27 03:48:30 -05:00
message ( "" )
2015-03-18 08:26:29 -05:00
message ( FATAL_ERROR "Could not find OPM Macros" )
endif ( )
endif ( )
2013-05-15 03:40:00 -05:00
2015-10-21 10:35:44 -05:00
2013-08-02 07:07:33 -05:00
# not the same location as most of the other projects? this hook overrides
macro ( dir_hook )
endmacro ( dir_hook )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
# project information is in dune.module. Read this file and set variables.
# we cannot generate dune.module since it is read by dunecontrol before
# the build starts, so it makes sense to keep the data there then.
include ( OpmInit )
2013-05-15 03:40:00 -05:00
2015-10-21 10:35:44 -05:00
# Look for the opm-data repository; if found the variable
# HAVE_OPM_DATA will be set to true.
include ( Findopm-data )
2013-08-02 07:07:33 -05:00
# list of prerequisites for this particular project; this is in a
# separate file (in cmake/Modules sub-directory) because it is shared
# with the find module
2015-05-15 08:43:03 -05:00
include ( "${project}-prereqs" )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
# read the list of components from this file (in the project directory);
# it should set various lists with the names of the files to include
include ( CMakeLists_files.cmake )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
macro ( config_hook )
2014-04-09 17:59:31 -05:00
opm_need_version_of ( "dune-common" )
2014-09-30 06:46:01 -05:00
opm_need_version_of ( "dune-istl" )
2013-08-02 07:07:33 -05:00
endmacro ( config_hook )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
macro ( prereqs_hook )
endmacro ( prereqs_hook )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
macro ( sources_hook )
2016-04-05 08:17:17 -05:00
if ( OPM_GRID_FOUND OR opm-grid_FOUND )
2014-02-20 06:17:18 -06:00
list ( APPEND examples_SOURCES
2015-10-12 03:59:01 -05:00
$ { P R O J E C T _ S O U R C E _ D I R } / e x a m p l e s / f l o w _ m p i . c p p
2015-11-25 06:15:06 -06:00
$ { P R O J E C T _ S O U R C E _ D I R } / e x a m p l e s / f l o w _ m u l t i s e g m e n t _ m p i . c p p
2014-04-09 17:56:09 -05:00
)
2014-02-20 06:17:18 -06:00
endif ( )
2013-08-02 07:07:33 -05:00
endmacro ( sources_hook )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
macro ( fortran_hook )
endmacro ( fortran_hook )
2013-05-15 03:40:00 -05:00
2014-06-16 07:40:52 -05:00
macro ( files_hook )
endmacro ( files_hook )
2013-08-02 07:07:33 -05:00
macro ( tests_hook )
endmacro ( tests_hook )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
# all setup common to the OPM library modules is done here
include ( OpmLibMain )
2013-05-15 03:40:00 -05:00
2013-08-02 07:07:33 -05:00
# download Eigen if user doesn't have the correct version
2013-07-09 04:37:56 -05:00
if ( NOT EIGEN3_FOUND )
2013-08-02 07:07:33 -05:00
message ( STATUS "Downloading Eigen3" )
include ( ExternalProject )
externalProject_Add ( Eigen3
G I T _ R E P O S I T O R Y g i t : / / g i t h u b . c o m / O P M / e i g e n 3
2014-05-21 06:57:16 -05:00
U P D A T E _ C O M M A N D g i t c h e c k o u t 9 e 7 8 8 d b 9 9 d 7 3 f 3 1 9 9 a d e 7 4 b f d a 8 d 9 f 7 3 f d f b b e 4 c
2013-08-02 07:07:33 -05:00
C M A K E _ A R G S - D E I G E N _ T E S T _ N O _ O P E N G L = 1 - D E I G E N _ B U I L D _ P K G C O N F I G = 0 - D C M A K E _ I N S T A L L _ P R E F I X = $ { C M A K E _ B I N A R Y _ D I R } / e i g e n 3 - i n s t a l l e d
)
include_directories ( ${ CMAKE_BINARY_DIR } /eigen3-installed/include/eigen3 )
2016-04-08 13:33:18 -05:00
add_dependencies ( opmsimulators Eigen3 )
2013-07-09 04:37:56 -05:00
endif ( NOT EIGEN3_FOUND )
2015-10-21 10:35:44 -05:00
if ( HAVE_OPM_DATA )
2016-02-04 01:58:15 -06:00
add_test ( NAME flow_SPE1 COMMAND flow ${ OPM_DATA_ROOT } /spe1/SPE1CASE1.DATA )
add_test ( NAME flow_SPE1CASE2 COMMAND flow ${ OPM_DATA_ROOT } /spe1/SPE1CASE2.DATA )
add_test ( NAME flow_SPE1CASE2_restart COMMAND flow ${ OPM_DATA_ROOT } /spe1/SPE1CASE2_RESTART.DATA )
set_tests_properties ( flow_SPE1CASE2_restart PROPERTIES DEPENDS flow_SPE1CASE2 ) # Dependes on the restart file from test flow_SPE1CASE2
add_executable ( test_restart tests/test_restart.cpp )
2016-04-08 13:33:18 -05:00
target_link_libraries ( test_restart opmsimulators ${ Boost_LIBRARIES } )
2016-02-04 01:58:15 -06:00
add_test ( compare_restart_files
$ { C M A K E _ B I N A R Y _ D I R } / b i n / t e s t _ r e s t a r t
S P E 1 C A S E 2 . U N R S T
S P E 1 C A S E 2 _ R E S T A R T . U N R S T # Restart from step 60
1 2 0
)
set_tests_properties ( compare_restart_files PROPERTIES DEPENDS flow_SPE1CASE2_restart ) # Compares the restart files from tests flow_SPE1CASE2_restart and flow_SPE1CASE2
2015-10-21 10:35:44 -05:00
endif ( )