2012-11-14 12:45:48 +01: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-02-11 10:56:46 +01:00
|
|
|
|
|
|
|
|
# key information about the library
|
2013-02-22 10:53:10 +01:00
|
|
|
set (project "opm-core")
|
|
|
|
|
set (${project}_NAME "${project}")
|
|
|
|
|
set (${project}_DESCRIPTION "Open Porous Media Initiative Core Library")
|
|
|
|
|
set (${project}_DIR "opm")
|
|
|
|
|
set (${project}_VERSION_MAJOR 1)
|
|
|
|
|
set (${project}_VERSION_MINOR 0)
|
2013-02-22 10:08:50 +01:00
|
|
|
set (doxy_dir "Documentation")
|
|
|
|
|
|
|
|
|
|
# defines that must be present in config.h for our headers
|
2013-02-22 10:53:10 +01:00
|
|
|
set (${project}_CONFIG_VAR
|
2013-02-22 10:08:50 +01:00
|
|
|
HAVE_AGMG
|
|
|
|
|
HAVE_DUNE_ISTL
|
|
|
|
|
HAVE_DYNAMIC_BOOST_TEST
|
|
|
|
|
HAVE_ERT
|
|
|
|
|
HAVE_SUITESPARSE_UMFPACK_H
|
|
|
|
|
HAVE_NULLPTR
|
|
|
|
|
HAVE_STATIC_ASSERT
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
# dependencies
|
2013-02-22 10:53:10 +01:00
|
|
|
set (${project}_DEPS
|
2013-02-22 10:08:50 +01:00
|
|
|
# compile with C99 support if available
|
|
|
|
|
"C99"
|
|
|
|
|
# compile with C++0x/11 support if available
|
|
|
|
|
"CXX11Features"
|
|
|
|
|
# matrix library
|
|
|
|
|
"BLAS REQUIRED"
|
|
|
|
|
"LAPACK REQUIRED"
|
|
|
|
|
# Tim Davis' SuiteSparse archive
|
|
|
|
|
"SuiteSparse COMPONENTS umfpack"
|
|
|
|
|
# solver
|
|
|
|
|
"SUPERLU"
|
|
|
|
|
# xml processing (for config parsing)
|
|
|
|
|
"TinyXML"
|
|
|
|
|
# various runtime library enhancements
|
|
|
|
|
"Boost 1.39.0
|
|
|
|
|
COMPONENTS date_time filesystem system unit_test_framework REQUIRED"
|
|
|
|
|
# DUNE dependency
|
|
|
|
|
"dune-istl"
|
|
|
|
|
# Ensembles-based Reservoir Tools (ERT)
|
|
|
|
|
"ERT"
|
|
|
|
|
)
|
2013-02-11 10:56:46 +01:00
|
|
|
|
|
|
|
|
# C++ project
|
|
|
|
|
cmake_minimum_required (VERSION 2.8)
|
2013-02-22 10:53:10 +01:00
|
|
|
project (${${project}_NAME})
|
2012-12-10 12:25:40 +01:00
|
|
|
enable_language (C)
|
2012-11-14 12:45:48 +01:00
|
|
|
enable_language (CXX)
|
2013-02-07 22:50:38 +01:00
|
|
|
|
2012-11-14 12:46:35 +01:00
|
|
|
# additional search modules
|
2013-02-22 10:53:10 +01:00
|
|
|
set (${project}_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/Modules")
|
|
|
|
|
list (APPEND CMAKE_MODULE_PATH ${${project}_MODULE_DIR})
|
2012-11-14 12:46:35 +01:00
|
|
|
|
2013-02-15 10:13:14 +01:00
|
|
|
# print system information to better pinpoint issues from log alone
|
|
|
|
|
include (UseSystemInfo)
|
|
|
|
|
system_info ()
|
|
|
|
|
|
2013-02-06 14:21:08 +01:00
|
|
|
# very early try to print repo id (to pinpoint version if something goes wrong)
|
|
|
|
|
include (UseVCSInfo)
|
|
|
|
|
vcs_info ()
|
|
|
|
|
|
2013-01-22 14:12:16 +01:00
|
|
|
# include special
|
|
|
|
|
if (CMAKE_VERSION VERSION_LESS "2.8.7")
|
|
|
|
|
message (STATUS "Enabling backward compatibility modules for CMake ${CMAKE_VERSION}")
|
2013-02-22 10:53:10 +01:00
|
|
|
list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.7")
|
2013-01-22 14:12:16 +01:00
|
|
|
endif (CMAKE_VERSION VERSION_LESS "2.8.7")
|
|
|
|
|
|
2013-02-11 10:52:00 +01:00
|
|
|
# default settings: build static debug library
|
|
|
|
|
include (OpmDefaults)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_defaults (${project})
|
2013-02-11 10:52:00 +01:00
|
|
|
message (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
|
|
|
|
|
|
2012-12-07 10:14:10 +01:00
|
|
|
# use tricks to do faster builds
|
|
|
|
|
include (UseFastBuilds)
|
|
|
|
|
|
2013-01-23 14:35:50 +01:00
|
|
|
# precompiled headers
|
|
|
|
|
include (UsePrecompHeaders)
|
|
|
|
|
|
2012-11-28 10:44:54 +01:00
|
|
|
# macro to set standard variables (INCLUDE_DIRS, LIBRARIES etc.)
|
2012-12-05 09:34:38 +01:00
|
|
|
include (OpmFind)
|
2013-02-22 10:53:10 +01:00
|
|
|
find_and_append_package_list_to (${project} ${${project}_DEPS})
|
2012-11-16 14:40:54 +01:00
|
|
|
|
2013-02-15 09:39:53 +01:00
|
|
|
# remove the dependency on the testing framework from the main library;
|
|
|
|
|
# it is not possible to query for Boost twice with different components.
|
2013-02-22 10:53:10 +01:00
|
|
|
list (REMOVE_ITEM ${project}_LIBRARIES ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
|
2013-02-15 09:39:53 +01:00
|
|
|
|
2013-02-18 22:38:41 +01:00
|
|
|
# don't import more libraries than we need to
|
|
|
|
|
include (UseOnlyNeeded)
|
|
|
|
|
|
2012-11-29 12:36:29 +01:00
|
|
|
# put debug information into every executable
|
|
|
|
|
include (UseDebugSymbols)
|
|
|
|
|
|
2012-11-29 13:09:56 +01:00
|
|
|
# optimize full if we're not doing a debug build
|
|
|
|
|
include (UseOptimization)
|
|
|
|
|
|
2012-11-29 13:12:13 +01:00
|
|
|
# turn on all warnings
|
|
|
|
|
include (UseWarnings)
|
|
|
|
|
|
2012-12-05 09:59:38 +01:00
|
|
|
# detect if Boost is in a shared library
|
2012-11-23 13:44:32 +01:00
|
|
|
include (UseDynamicBoost)
|
2012-11-17 00:36:54 +01:00
|
|
|
|
2013-01-16 23:36:16 +01:00
|
|
|
# needed for Debian installation scheme
|
|
|
|
|
include (UseMultiArch)
|
|
|
|
|
|
2013-02-11 10:48:13 +01:00
|
|
|
# this module contains code to figure out which files is where
|
|
|
|
|
include (OpmFiles)
|
2013-02-21 09:55:03 +01:00
|
|
|
opm_auto_dirs ()
|
2013-02-11 10:48:13 +01:00
|
|
|
|
|
|
|
|
# put libraries in lib/
|
|
|
|
|
opm_out_dirs ()
|
2013-01-23 14:35:50 +01:00
|
|
|
|
2013-02-11 10:48:13 +01:00
|
|
|
# identify the compilation units in the library
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_sources (${project})
|
2012-11-14 12:45:48 +01:00
|
|
|
|
2013-02-11 12:45:58 +01:00
|
|
|
# enumerate all testing programs in test/ directory
|
|
|
|
|
opm_find_tests ()
|
|
|
|
|
|
|
|
|
|
# tutorial programs are found in the tutorials/ directory
|
|
|
|
|
opm_find_tutorials ()
|
|
|
|
|
|
2013-02-11 12:52:52 +01:00
|
|
|
# example programs are found in the examples/ directory
|
|
|
|
|
opm_find_examples ()
|
|
|
|
|
|
2013-02-22 10:08:50 +01:00
|
|
|
### --- begin opm-core specific --- ###
|
2012-12-13 00:28:32 +01:00
|
|
|
# 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)
|
2013-02-07 23:56:28 +01:00
|
|
|
list (APPEND opm-core_SOURCES ${AGMG_SOURCES})
|
2013-01-22 15:23:24 +01:00
|
|
|
endif (AGMG_FOUND)
|
|
|
|
|
|
|
|
|
|
# these solvers are only compiled in if their dependency is found
|
|
|
|
|
if (NOT AGMG_FOUND)
|
2013-02-07 23:56:28 +01:00
|
|
|
list (REMOVE_ITEM opm-core_SOURCES
|
2013-02-22 09:49:49 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverAGMG.cpp
|
2012-12-13 00:28:32 +01:00
|
|
|
)
|
2013-01-22 15:23:24 +01:00
|
|
|
endif (NOT AGMG_FOUND)
|
|
|
|
|
if (NOT dune-istl_FOUND)
|
2013-02-07 23:56:28 +01:00
|
|
|
list (REMOVE_ITEM opm-core_SOURCES
|
2013-02-22 09:49:49 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverIstl.cpp
|
2013-01-22 15:23:24 +01:00
|
|
|
)
|
|
|
|
|
endif (NOT dune-istl_FOUND)
|
|
|
|
|
if (NOT SuiteSparse_FOUND)
|
2013-02-07 23:56:28 +01:00
|
|
|
list (REMOVE_ITEM opm-core_SOURCES
|
2013-02-22 09:49:49 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_umfpack.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverUmfpack.cpp
|
2013-01-22 15:23:24 +01:00
|
|
|
)
|
2013-02-11 12:48:31 +01:00
|
|
|
list (REMOVE_ITEM tutorial_SOURCES
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial2.cpp
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial3.cpp
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial4.cpp
|
|
|
|
|
)
|
2013-02-11 12:52:52 +01:00
|
|
|
list (REMOVE_ITEM examples_SOURCES
|
2013-02-13 21:24:54 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/${examples_DIR}/spu_2p.cpp
|
2013-02-11 12:52:52 +01:00
|
|
|
)
|
2013-01-22 15:23:24 +01:00
|
|
|
endif (NOT SuiteSparse_FOUND)
|
2012-12-13 00:28:32 +01:00
|
|
|
|
2012-11-14 12:51:19 +01:00
|
|
|
# these files are provided in source control, but can only compile with Matlab
|
2013-01-22 15:03:07 +01:00
|
|
|
# available; we are not supposed to include the TinyXML test prog. regardless
|
2013-02-07 23:56:28 +01:00
|
|
|
list (REMOVE_ITEM opm-core_SOURCES
|
2013-02-22 09:49:49 +01:00
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/grid/cpgpreprocess/mxgrdecl.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/grid/cpgpreprocess/processgrid.c
|
|
|
|
|
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/utility/parameters/tinyxml/xmltest.cpp
|
2012-11-14 12:51:19 +01:00
|
|
|
)
|
|
|
|
|
|
2013-01-22 15:03:07 +01:00
|
|
|
# remove inline TinyXML if a system version was found
|
|
|
|
|
if (TinyXML_FOUND)
|
2013-02-22 09:49:49 +01:00
|
|
|
file (GLOB_RECURSE _inline_tinyxml "${opm-core_DIR}/core/utility/parameters/tinyxml/*")
|
2013-01-22 15:03:07 +01:00
|
|
|
foreach (_file IN LISTS _inline_tinyxml)
|
2013-02-07 23:56:28 +01:00
|
|
|
list (REMOVE_ITEM opm-core_SOURCES ${_file})
|
2013-01-22 15:03:07 +01:00
|
|
|
endforeach (_file)
|
|
|
|
|
endif (TinyXML_FOUND)
|
|
|
|
|
|
2013-01-23 09:08:42 +01:00
|
|
|
# anyhow remove it from the header list (so it doesn't get installed)
|
2013-02-22 09:49:49 +01:00
|
|
|
list (REMOVE_ITEM opm-core_HEADERS "${opm-core_DIR}/core/utility/parameters/tinyxml/tinystr.h")
|
|
|
|
|
list (REMOVE_ITEM opm-core_HEADERS "${opm-core_DIR}/core/utility/parameters/tinyxml/tinyxml.h")
|
2013-01-23 09:08:42 +01:00
|
|
|
|
2012-12-19 10:58:39 +01:00
|
|
|
# HAVE_ERT is used as an #ifdef, not as an #if in the source code, if it
|
|
|
|
|
# is not true, then it should be unset altogether
|
|
|
|
|
if (NOT HAVE_ERT)
|
|
|
|
|
set (HAVE_ERT)
|
2013-02-11 12:52:52 +01:00
|
|
|
list (REMOVE_ITEM examples_SOURCES
|
|
|
|
|
${PROJECT_SOURCE_DIR}/examples/import_rewrite.cpp
|
|
|
|
|
)
|
2012-12-19 10:58:39 +01:00
|
|
|
endif (NOT HAVE_ERT)
|
2013-02-22 10:08:50 +01:00
|
|
|
### --- end opm-core specific --- ###
|
2012-11-14 12:46:35 +01:00
|
|
|
|
|
|
|
|
# create configuration header which describes available features
|
2012-12-05 11:01:18 +01:00
|
|
|
# necessary to compile this library. singular version is the names that
|
|
|
|
|
# is required by this project alone, plural version transitively
|
|
|
|
|
# includes the necessary defines by the dependencies
|
2012-12-05 09:34:38 +01:00
|
|
|
include (ConfigVars)
|
2013-02-22 10:53:10 +01:00
|
|
|
list (APPEND ${project}_CONFIG_VARS ${${project}_CONFIG_VAR})
|
2013-02-22 10:08:50 +01:00
|
|
|
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h")
|
2012-11-14 12:46:35 +01:00
|
|
|
configure_vars (
|
2013-02-22 10:08:50 +01:00
|
|
|
FILE CXX ${CONFIG_H}
|
2013-02-22 10:53:10 +01:00
|
|
|
WRITE ${${project}_CONFIG_VARS}
|
2012-11-14 12:46:35 +01:00
|
|
|
)
|
2012-12-13 00:28:32 +01:00
|
|
|
include (UseFortranWrappers)
|
|
|
|
|
define_fc_func (
|
2013-02-22 10:08:50 +01:00
|
|
|
APPEND ${CONFIG_H}
|
2012-12-13 00:28:32 +01:00
|
|
|
)
|
2012-11-14 12:46:35 +01:00
|
|
|
|
2013-02-11 10:41:08 +01:00
|
|
|
# compile main library; pull in all required includes and libraries
|
|
|
|
|
include (OpmCompile)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_compile (${project})
|
2013-01-23 14:35:50 +01:00
|
|
|
|
2013-02-11 10:36:00 +01:00
|
|
|
# installation target: copy the library together with debug and
|
|
|
|
|
# configuration files to system directories
|
|
|
|
|
include (OpmInstall)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_install (${project})
|
2012-12-07 08:58:18 +01:00
|
|
|
message (STATUS "This build defaults to installing in ${CMAKE_INSTALL_PREFIX}")
|
|
|
|
|
|
2012-12-07 12:18:49 +01:00
|
|
|
# installation of CMake modules to help user programs locate the library
|
|
|
|
|
include (OpmProject)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_cmake_config (${project})
|
2012-12-07 12:18:49 +01:00
|
|
|
|
2013-02-11 12:35:04 +01:00
|
|
|
# routines to build satellites such as tests, tutorials and samples
|
|
|
|
|
include (OpmSatellites)
|
2013-01-24 23:54:47 +01:00
|
|
|
|
2013-02-11 10:48:13 +01:00
|
|
|
# tutorial programs are found in the tutorials/ directory
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_compile_satellites (${project} tutorial "" "")
|
|
|
|
|
opm_compile_satellites (${project} examples "" "")
|
2013-01-24 23:54:47 +01:00
|
|
|
|
2013-02-11 12:35:04 +01:00
|
|
|
# infrastructure for testing
|
2013-01-24 15:07:23 +01:00
|
|
|
enable_testing ()
|
|
|
|
|
include (CTest)
|
2012-11-25 23:05:57 +01:00
|
|
|
|
2013-02-22 10:08:50 +01:00
|
|
|
### --- begin opm-core specific --- ###
|
2012-11-25 23:06:39 +01:00
|
|
|
# conditionally disable tests when features aren't available
|
|
|
|
|
macro (cond_disable_test name)
|
2012-12-12 22:10:32 +01:00
|
|
|
if ((NOT DEFINED HAVE_${name}) OR (NOT HAVE_${name}))
|
2012-11-25 23:06:39 +01:00
|
|
|
message (STATUS "${name} test disabled, since ${name} is not found.")
|
|
|
|
|
string (TOLOWER "${name}" name_lower)
|
|
|
|
|
get_filename_component (test_${name}_FILE "tests/test_${name_lower}.cpp" ABSOLUTE)
|
|
|
|
|
list (REMOVE_ITEM tests_SOURCES "${test_${name}_FILE}")
|
2012-12-12 22:10:32 +01:00
|
|
|
endif ((NOT DEFINED HAVE_${name}) OR (NOT HAVE_${name}))
|
2012-11-25 23:06:39 +01:00
|
|
|
endmacro (cond_disable_test name)
|
|
|
|
|
cond_disable_test ("AGMG")
|
|
|
|
|
cond_disable_test ("ERT")
|
2013-02-22 10:08:50 +01:00
|
|
|
### --- end opm-core specific --- ###
|
2012-11-25 23:06:39 +01:00
|
|
|
|
2013-02-11 11:17:21 +01:00
|
|
|
# make datafiles necessary for tests available in output directory
|
2013-02-21 10:54:15 +01:00
|
|
|
opm_data (tests datafiles "${tests_DIR}" "*.xml")
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
|
2012-12-20 14:41:18 +01:00
|
|
|
|
2013-02-11 12:35:04 +01:00
|
|
|
# use this target to run all tests
|
2013-01-18 09:14:53 +01:00
|
|
|
add_custom_target (check
|
2013-01-24 19:44:09 +01:00
|
|
|
COMMAND ${CMAKE_CTEST_COMMAND}
|
2013-01-18 09:14:53 +01:00
|
|
|
DEPENDS tests
|
2013-02-19 22:58:35 +01:00
|
|
|
COMMENT "Checking if library is functional"
|
2013-01-18 09:14:53 +01:00
|
|
|
VERBATIM
|
|
|
|
|
)
|
|
|
|
|
|
2013-02-11 10:31:48 +01:00
|
|
|
# generate documentation from source code with Doxygen;
|
|
|
|
|
# setup install target for this documentation
|
|
|
|
|
include (OpmDoc)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_doc (${project} ${doxy_dir})
|
2013-02-05 13:37:55 +01:00
|
|
|
|
2013-02-07 13:17:12 +01:00
|
|
|
# provide compatibility with using this build in dunecontrol
|
|
|
|
|
include (DuneCompat)
|
|
|
|
|
include (LibtoolArchives)
|
2013-02-22 10:53:10 +01:00
|
|
|
configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
|
2013-02-07 13:17:12 +01:00
|
|
|
|
2013-01-09 09:37:57 +01:00
|
|
|
### clean in-source builds ###
|
2013-02-11 10:18:11 +01:00
|
|
|
include (OpmDistClean)
|
2013-02-22 10:53:10 +01:00
|
|
|
opm_dist_clean (${project})
|
2013-01-17 14:52:35 +01:00
|
|
|
|
|
|
|
|
# smart wrapper that auto-parallelizes builds
|
|
|
|
|
file (COPY
|
|
|
|
|
GNUmakefile
|
|
|
|
|
DESTINATION ${PROJECT_BINARY_DIR}
|
|
|
|
|
)
|