Compare commits

..

10 Commits

Author SHA1 Message Date
Arne Morten Kvarving
0aadd9c44e update redhat packaging 2015-04-27 10:16:08 +02:00
Arne Morten Kvarving
648e4f1ccb fix tests
- cannot use BOOST_CHECK_CLOSE around 0 due to a relative test
- slacken a tolerance significantly
2015-04-27 10:15:48 +02:00
Atgeirr Flø Rasmussen
df74688aad Merge pull request #795 from akva2/update_packaging_versions
bump versions for release
2015-04-27 09:45:50 +02:00
Arne Morten Kvarving
c7d547d4f2 bump versions for release 2015-04-24 14:47:50 +02:00
Atgeirr Flø Rasmussen
dedccd9644 Adjust parameters after testing. 2015-04-22 14:53:35 +02:00
Atgeirr Flø Rasmussen
ba467184cc Modify default parameters to be suitable for the Norne case. 2015-04-22 14:53:16 +02:00
Atgeirr Flø Rasmussen
a295108664 New method SimulatorReport::reportFullyImplicit().
It does not make sense to report transport and pressure separately
for fully implicit solvers. It still makes sense to separate solver
from init and output though.
2015-04-22 14:52:54 +02:00
Atgeirr Flø Rasmussen
81bcd2033c Silence PLT complaint spam.
While the warning is correct, it is not a good idea to spam
it for all wells and timesteps.
2015-04-22 14:52:38 +02:00
Atgeirr Flø Rasmussen
7afffb6a38 Merge branch 'master' into release/2015.04 2015-04-15 14:54:50 +02:00
Atgeirr Flø Rasmussen
d933582269 Bump version number. 2015-04-13 13:52:34 +02:00
474 changed files with 74249 additions and 9240 deletions

3
.gitignore vendored
View File

@ -41,6 +41,3 @@ install_manifest.txt
CTestTestfile.cmake
DartConfiguration.tcl
Testing/
.DS_Store
.idea
build

View File

@ -13,54 +13,32 @@
# cmake/Modules/${project}-prereqs.cmake Dependencies #
# #
###########################################################################
# Mandatory call to project
project(opm-core C CXX)
cmake_minimum_required (VERSION 2.8)
# additional search modules
option(SIBLING_SEARCH "Search for other modules in sibling directories?" ON)
if(SIBLING_SEARCH AND NOT opm-common_DIR)
# guess the sibling dir
get_filename_component(_leaf_dir_name ${PROJECT_BINARY_DIR} NAME)
get_filename_component(_parent_full_dir ${PROJECT_BINARY_DIR} DIRECTORY)
get_filename_component(_parent_dir_name ${_parent_full_dir} NAME)
#Try if <module-name>/<build-dir> is used
get_filename_component(_modules_dir ${_parent_full_dir} DIRECTORY)
if(IS_DIRECTORY ${_modules_dir}/opm-common/${_leaf_dir_name})
set(opm-common_DIR ${_modules_dir}/opm-common/${_leaf_dir_name})
else()
string(REPLACE ${PROJECT_NAME} opm-common _opm_common_leaf ${_leaf_dir_name})
if(NOT _leaf_dir_name STREQUAL _opm_common_leaf
AND IS_DIRECTORY ${_parent_full_dir}/${_opm_common_leaf})
# We are using build directories named <prefix><module-name><postfix>
set(opm-common_DIR ${_parent_full_dir}/${_opm_common_leaf})
elseif(IS_DIRECTORY ${_parent_full_dir}/opm-common)
# All modules are in a common build dir
set(opm-common_DIR "${_parent_full_dir}/opm-common}")
endif()
endif()
endif()
if(opm-common_DIR AND NOT IS_DIRECTORY ${opm-common_DIR})
message(WARNING "Value ${opm-common_DIR} passed to variable"
" opm-common_DIR is not a directory")
endif()
find_package(opm-common REQUIRED)
include(OpmInit)
find_path (OPM_MACROS_ROOT cmake/Modules/OpmInit.cmake
PATHS ${opm-macros_ROOT}
${CMAKE_CURRENT_SOURCE_DIR}
DOC "Path to build system macros and scripts"
NO_DEFAULT_PATH
)
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules")
# not the same location as most of the other projects; this hook overrides
macro (dir_hook)
set (doxy_dir "Documentation")
endmacro (dir_hook)
# 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)
# 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
include ( ${project}-prereqs )
include (${project}-prereqs)
# 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
@ -81,7 +59,24 @@ macro (sources_hook)
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverIstl.cpp
)
endif (NOT dune-istl_FOUND)
if (NOT SuiteSparse_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_umfpack.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverUmfpack.cpp
)
list (REMOVE_ITEM examples_SOURCES
${PROJECT_SOURCE_DIR}/tutorials/tutorial2.cpp
${PROJECT_SOURCE_DIR}/tutorials/tutorial3.cpp
${PROJECT_SOURCE_DIR}/tutorials/tutorial4.cpp
)
endif (NOT SuiteSparse_FOUND)
if (NOT PETSC_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/call_petsc.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverPetsc.cpp
)
endif (NOT PETSC_FOUND)
if ((NOT MPI_FOUND) OR (NOT DUNE_ISTL_FOUND))
list (REMOVE_ITEM tests_SOURCES
${PROJECT_SOURCE_DIR}/tests/test_parallel_linearsolver.cpp
@ -136,3 +131,9 @@ endmacro (install_hook)
# all setup common to the OPM library modules is done here
include (OpmLibMain)
add_custom_target(check-commits
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${PROJECT_SOURCE_DIR}/cmake/Scripts/CheckCommits.cmake)

View File

@ -29,92 +29,187 @@
# originally generated with the command:
# find opm -name '*.c*' -printf '\t%p\n' | sort
list (APPEND MAIN_SOURCE_FILES
opm/core/flowdiagnostics/AnisotropicEikonal.cpp
opm/core/flowdiagnostics/DGBasis.cpp
opm/core/flowdiagnostics/FlowDiagnostics.cpp
opm/core/flowdiagnostics/TofDiscGalReorder.cpp
opm/core/flowdiagnostics/TofReorder.cpp
opm/core/linalg/LinearSolverFactory.cpp
opm/core/linalg/LinearSolverInterface.cpp
opm/core/linalg/LinearSolverIstl.cpp
opm/core/linalg/LinearSolverPetsc.cpp
opm/core/linalg/LinearSolverUmfpack.cpp
opm/core/linalg/call_umfpack.c
opm/core/linalg/sparse_sys.c
opm/core/pressure/CompressibleTpfa.cpp
opm/core/pressure/FlowBCManager.cpp
opm/core/pressure/IncompTpfa.cpp
opm/core/pressure/IncompTpfaSinglePhase.cpp
opm/core/pressure/flow_bc.c
opm/core/pressure/mimetic/mimetic.c
opm/core/pressure/msmfem/dfs.c
opm/core/pressure/msmfem/partition.c
opm/core/pressure/tpfa/cfs_tpfa_residual.c
opm/core/pressure/tpfa/ifs_tpfa.c
opm/core/props/BlackoilPropertiesBasic.cpp
opm/core/props/BlackoilPropertiesFromDeck.cpp
opm/core/props/IncompPropertiesBasic.cpp
opm/core/props/IncompPropertiesFromDeck.cpp
opm/core/props/IncompPropertiesSinglePhase.cpp
opm/core/props/pvt/PvtPropertiesBasic.cpp
opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp
opm/core/props/rock/RockBasic.cpp
opm/core/props/rock/RockCompressibility.cpp
opm/core/props/rock/RockFromDeck.cpp
opm/core/props/satfunc/RelpermDiagnostics.cpp
opm/core/props/satfunc/SaturationPropsBasic.cpp
opm/core/props/satfunc/SaturationPropsFromDeck.cpp
opm/core/simulator/BlackoilState.cpp
opm/core/simulator/TwophaseState.cpp
opm/core/simulator/SimulatorReport.cpp
opm/core/transport/TransportSolverTwophaseInterface.cpp
opm/core/transport/reorder/ReorderSolverInterface.cpp
opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp
opm/core/transport/reorder/TransportSolverTwophaseReorder.cpp
opm/core/transport/reorder/reordersequence.cpp
opm/core/transport/reorder/tarjan.c
opm/core/utility/miscUtilities.cpp
opm/core/utility/miscUtilitiesBlackoil.cpp
opm/core/wells/InjectionSpecification.cpp
opm/core/wells/ProductionSpecification.cpp
opm/core/wells/WellCollection.cpp
opm/core/wells/WellsGroup.cpp
opm/core/wells/WellsManager.cpp
opm/core/wells/well_controls.c
opm/core/wells/wells.c
opm/core/grid/GridHelpers.cpp
opm/core/grid/GridManager.cpp
opm/core/grid/GridUtilities.cpp
opm/core/grid/grid.c
opm/core/grid/cart_grid.c
opm/core/grid/cornerpoint_grid.c
opm/core/grid/cpgpreprocess/facetopology.c
opm/core/grid/cpgpreprocess/geometry.c
opm/core/grid/cpgpreprocess/preprocess.c
opm/core/grid/cpgpreprocess/uniquepoints.c
opm/core/io/eclipse/EclipseGridInspector.cpp
opm/core/io/eclipse/EclipseWriter.cpp
opm/core/io/eclipse/EclipseWriteRFTHandler.cpp
opm/core/io/eclipse/writeECLData.cpp
opm/core/io/OutputWriter.cpp
opm/core/io/vag/vag.cpp
opm/core/io/vtk/writeVtkData.cpp
opm/core/linalg/LinearSolverFactory.cpp
opm/core/linalg/LinearSolverInterface.cpp
opm/core/linalg/LinearSolverIstl.cpp
opm/core/linalg/LinearSolverUmfpack.cpp
opm/core/linalg/LinearSolverPetsc.cpp
opm/core/linalg/call_umfpack.c
opm/core/linalg/sparse_sys.c
opm/core/pressure/CompressibleTpfa.cpp
opm/core/pressure/FlowBCManager.cpp
opm/core/pressure/IncompTpfa.cpp
opm/core/pressure/IncompTpfaSinglePhase.cpp
opm/core/pressure/cfsh.c
opm/core/pressure/flow_bc.c
opm/core/pressure/fsh.c
opm/core/pressure/fsh_common_impl.c
opm/core/pressure/ifsh.c
opm/core/pressure/mimetic/hybsys.c
opm/core/pressure/mimetic/hybsys_global.c
opm/core/pressure/mimetic/mimetic.c
opm/core/pressure/msmfem/coarse_conn.c
opm/core/pressure/msmfem/coarse_sys.c
opm/core/pressure/msmfem/dfs.c
opm/core/pressure/msmfem/hash_set.c
opm/core/pressure/msmfem/ifsh_ms.c
opm/core/pressure/msmfem/partition.c
opm/core/pressure/tpfa/cfs_tpfa.c
opm/core/pressure/tpfa/cfs_tpfa_residual.c
opm/core/pressure/tpfa/compr_bc.c
opm/core/pressure/tpfa/compr_quant.c
opm/core/pressure/tpfa/compr_quant_general.c
opm/core/pressure/tpfa/compr_source.c
opm/core/pressure/tpfa/ifs_tpfa.c
opm/core/pressure/tpfa/TransTpfa.cpp
opm/core/pressure/tpfa/trans_tpfa.c
opm/core/pressure/legacy_well.c
opm/core/props/BlackoilPropertiesBasic.cpp
opm/core/props/BlackoilPropertiesFromDeck.cpp
opm/core/props/IncompPropertiesBasic.cpp
opm/core/props/IncompPropertiesFromDeck.cpp
opm/core/props/IncompPropertiesSinglePhase.cpp
opm/core/props/pvt/BlackoilPvtProperties.cpp
opm/core/props/pvt/PvtPropertiesBasic.cpp
opm/core/props/pvt/PvtPropertiesIncompFromDeck.cpp
opm/core/props/pvt/PvtDead.cpp
opm/core/props/pvt/PvtDeadSpline.cpp
opm/core/props/pvt/PvtInterface.cpp
opm/core/props/pvt/PvtLiveGas.cpp
opm/core/props/pvt/PvtLiveOil.cpp
opm/core/props/rock/RockBasic.cpp
opm/core/props/rock/RockCompressibility.cpp
opm/core/props/rock/RockFromDeck.cpp
opm/core/props/satfunc/SatFuncGwseg.cpp
opm/core/props/satfunc/SatFuncSimple.cpp
opm/core/props/satfunc/SatFuncStone2.cpp
opm/core/props/satfunc/SaturationPropsBasic.cpp
opm/core/props/satfunc/SaturationPropsFromDeck.cpp
opm/core/simulator/AdaptiveSimulatorTimer.cpp
opm/core/simulator/BlackoilState.cpp
opm/core/simulator/TimeStepControl.cpp
opm/core/simulator/SimulatorCompressibleTwophase.cpp
opm/core/simulator/SimulatorIncompTwophase.cpp
opm/core/simulator/SimulatorOutput.cpp
opm/core/simulator/SimulatorReport.cpp
opm/core/simulator/SimulatorState.cpp
opm/core/simulator/SimulatorTimer.cpp
opm/core/flowdiagnostics/AnisotropicEikonal.cpp
opm/core/flowdiagnostics/DGBasis.cpp
opm/core/flowdiagnostics/FlowDiagnostics.cpp
opm/core/flowdiagnostics/TofReorder.cpp
opm/core/flowdiagnostics/TofDiscGalReorder.cpp
opm/core/transport/TransportSolverTwophaseInterface.cpp
opm/core/transport/implicit/TransportSolverTwophaseImplicit.cpp
opm/core/transport/implicit/transport_source.c
opm/core/transport/minimal/spu_explicit.c
opm/core/transport/minimal/spu_implicit.c
opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.cpp
opm/core/transport/reorder/ReorderSolverInterface.cpp
opm/core/transport/reorder/TransportSolverTwophaseReorder.cpp
opm/core/transport/reorder/reordersequence.cpp
opm/core/transport/reorder/tarjan.c
opm/core/utility/Event.cpp
opm/core/utility/MonotCubicInterpolator.cpp
opm/core/utility/StopWatch.cpp
opm/core/utility/VelocityInterpolation.cpp
opm/core/utility/WachspressCoord.cpp
opm/core/utility/miscUtilities.cpp
opm/core/utility/miscUtilitiesBlackoil.cpp
opm/core/utility/NullStream.cpp
opm/core/utility/parameters/Parameter.cpp
opm/core/utility/parameters/ParameterGroup.cpp
opm/core/utility/parameters/ParameterTools.cpp
opm/core/utility/parameters/ParameterXML.cpp
opm/core/utility/parameters/tinyxml/tinystr.cpp
opm/core/utility/parameters/tinyxml/tinyxml.cpp
opm/core/utility/parameters/tinyxml/tinyxmlerror.cpp
opm/core/utility/parameters/tinyxml/tinyxmlparser.cpp
opm/core/utility/parameters/tinyxml/xmltest.cpp
opm/core/version.c
opm/core/wells/InjectionSpecification.cpp
opm/core/wells/ProductionSpecification.cpp
opm/core/wells/WellCollection.cpp
opm/core/wells/WellsGroup.cpp
opm/core/wells/WellsManager.cpp
opm/core/wells/wells.c
opm/core/wells/well_controls.c
)
# originally generated with the command:
# find tests -name '*.cpp' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_SOURCE_FILES
tests/test_writenumwells.cpp
tests/test_EclipseWriter.cpp
tests/test_EclipseWriteRFTHandler.cpp
tests/test_compressedpropertyaccess.cpp
tests/test_spline.cpp
tests/test_propertysystem.cpp
tests/test_dgbasis.cpp
tests/test_cartgrid.cpp
tests/test_ug.cpp
tests/test_cubic.cpp
tests/test_event.cpp
tests/test_flowdiagnostics.cpp
tests/test_nonuniformtablelinear.cpp
tests/test_parallelistlinformation.cpp
tests/test_sparsevector.cpp
tests/test_sparsetable.cpp
tests/test_velocityinterpolation.cpp
tests/test_quadratures.cpp
tests/test_uniformtablelinear.cpp
tests/test_wells.cpp
tests/test_wachspresscoord.cpp
tests/test_column_extract.cpp
tests/test_geom2d.cpp
tests/test_linearsolver.cpp
tests/test_parallel_linearsolver.cpp
tests/test_param.cpp
tests/test_blackoilfluid.cpp
tests/test_satfunc.cpp
tests/test_shadow.cpp
tests/test_equil.cpp
tests/test_regionmapping.cpp
tests/test_units.cpp
tests/test_blackoilstate.cpp
tests/test_parser.cpp
tests/test_wellsmanager.cpp
tests/test_wellcontrols.cpp
tests/test_wellsgroup.cpp
tests/test_wellcollection.cpp
tests/test_pinchprocessor.cpp
tests/test_timer.cpp
tests/test_minpvprocessor.cpp
tests/test_gridutilities.cpp
tests/test_anisotropiceikonal.cpp
tests/test_stoppedwells.cpp
tests/test_relpermdiagnostics.cpp
tests/test_norne_pvt.cpp
)
# originally generated with the command:
# find tests -name '*.param' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
# find tests -name '*.xml' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
list (APPEND TEST_DATA_FILES
tests/extratestdata.xml
tests/testdata.xml
tests/liveoil.DATA
tests/capillary.DATA
tests/capillary_overlap.DATA
tests/capillarySwatinit.DATA
tests/compressed_gridproperty.data
tests/deadfluids.DATA
tests/equil_livegas.DATA
tests/equil_liveoil.DATA
@ -128,23 +223,31 @@ list (APPEND TEST_DATA_FILES
tests/satfuncEPS_D.DATA
tests/testBlackoilState1.DATA
tests/testBlackoilState2.DATA
tests/testPinch1.DATA
tests/testBlackoilState3.DATA
tests/wells_manager_data.data
tests/wells_manager_data_expanded.data
tests/wells_manager_data_wellSTOP.data
tests/wells_group.data
tests/TESTTIMER.DATA
tests/CORNERPOINT_ACTNUM.DATA
tests/wells_stopped.data
tests/relpermDiagnostics.DATA
tests/norne_pvt.data
)
)
# originally generated with the command:
# find examples -name '*.c*' -printf '\t%p\n' | sort
# find tutorials examples -name '*.c*' -printf '\t%p\n' | sort
list (APPEND EXAMPLE_SOURCE_FILES
examples/compute_eikonal_from_files.cpp
examples/compute_initial_state.cpp
examples/compute_tof.cpp
examples/compute_tof_from_files.cpp
examples/diagnose_relperm.cpp
examples/mirror_grid.cpp
examples/sim_2p_comp_reorder.cpp
examples/sim_2p_incomp.cpp
examples/wells_example.cpp
tutorials/tutorial1.cpp
tutorials/tutorial2.cpp
tutorials/tutorial3.cpp
tutorials/tutorial4.cpp
)
# originally generated with the command:
@ -161,90 +264,207 @@ list (APPEND ATTIC_FILES
# programs listed here will not only be compiled, but also marked for
# installation
list (APPEND PROGRAM_SOURCE_FILES
examples/mirror_grid.cpp
examples/sim_2p_comp_reorder.cpp
examples/sim_2p_incomp.cpp
)
# originally generated with the command:
# find opm -name '*.h*' -a ! -name '*-pch.hpp' -printf '\t%p\n' | sort
list (APPEND PUBLIC_HEADER_FILES
opm/core/doxygen_main.hpp
opm/core/flowdiagnostics/AnisotropicEikonal.hpp
opm/core/flowdiagnostics/DGBasis.hpp
opm/core/flowdiagnostics/FlowDiagnostics.hpp
opm/core/flowdiagnostics/TofDiscGalReorder.hpp
opm/core/flowdiagnostics/TofReorder.hpp
opm/core/linalg/LinearSolverFactory.hpp
opm/core/linalg/LinearSolverInterface.hpp
opm/core/linalg/LinearSolverIstl.hpp
opm/core/linalg/LinearSolverPetsc.hpp
opm/core/linalg/LinearSolverUmfpack.hpp
opm/core/linalg/ParallelIstlInformation.hpp
opm/core/linalg/call_umfpack.h
opm/core/linalg/sparse_sys.h
opm/core/pressure/CompressibleTpfa.hpp
opm/core/pressure/FlowBCManager.hpp
opm/core/pressure/IncompTpfa.hpp
opm/core/pressure/flow_bc.h
opm/core/pressure/legacy_well.h
opm/core/pressure/mimetic/mimetic.h
opm/core/pressure/msmfem/dfs.h
opm/core/pressure/msmfem/partition.h
opm/core/pressure/tpfa/cfs_tpfa_residual.h
opm/core/pressure/tpfa/compr_quant_general.h
opm/core/pressure/tpfa/compr_source.h
opm/core/pressure/tpfa/ifs_tpfa.h
opm/core/props/BlackoilPhases.hpp
opm/core/props/BlackoilPropertiesBasic.hpp
opm/core/props/BlackoilPropertiesFromDeck.hpp
opm/core/props/BlackoilPropertiesInterface.hpp
opm/core/props/IncompPropertiesBasic.hpp
opm/core/props/IncompPropertiesFromDeck.hpp
opm/core/props/IncompPropertiesInterface.hpp
opm/core/props/IncompPropertiesShadow.hpp
opm/core/props/IncompPropertiesShadow_impl.hpp
opm/core/props/IncompPropertiesSinglePhase.hpp
opm/core/props/phaseUsageFromDeck.hpp
opm/core/props/pvt/PvtPropertiesBasic.hpp
opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp
opm/core/props/pvt/ThermalGasPvtWrapper.hpp
opm/core/props/pvt/ThermalOilPvtWrapper.hpp
opm/core/props/pvt/ThermalWaterPvtWrapper.hpp
opm/core/props/rock/RockBasic.hpp
opm/core/props/rock/RockCompressibility.hpp
opm/core/props/rock/RockFromDeck.hpp
opm/core/props/satfunc/RelpermDiagnostics.hpp
opm/core/props/satfunc/SaturationPropsBasic.hpp
opm/core/props/satfunc/SaturationPropsFromDeck.hpp
opm/core/props/satfunc/SaturationPropsInterface.hpp
opm/core/props/satfunc/RelpermDiagnostics_impl.hpp
opm/core/simulator/BlackoilState.hpp
opm/core/simulator/BlackoilStateToFluidState.hpp
opm/core/simulator/EquilibrationHelpers.hpp
opm/core/simulator/ExplicitArraysFluidState.hpp
opm/core/simulator/ExplicitArraysSatDerivativesFluidState.hpp
opm/core/simulator/SimulatorReport.hpp
opm/core/simulator/TwophaseState.hpp
opm/core/simulator/WellState.hpp
opm/core/simulator/initState.hpp
opm/core/simulator/initStateEquil.hpp
opm/core/simulator/initStateEquil_impl.hpp
opm/core/simulator/initState_impl.hpp
opm/core/transport/TransportSolverTwophaseInterface.hpp
opm/core/transport/reorder/ReorderSolverInterface.hpp
opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.hpp
opm/core/transport/reorder/TransportSolverTwophaseReorder.hpp
opm/core/transport/reorder/reordersequence.h
opm/core/transport/reorder/tarjan.h
opm/core/utility/initHydroCarbonState.hpp
opm/core/utility/miscUtilities.hpp
opm/core/utility/miscUtilitiesBlackoil.hpp
opm/core/utility/miscUtilities_impl.hpp
opm/core/well_controls.h
opm/core/wells.h
opm/core/wells/InjectionSpecification.hpp
opm/core/wells/ProductionSpecification.hpp
opm/core/wells/WellCollection.hpp
opm/core/wells/WellsGroup.hpp
opm/core/wells/WellsManager.hpp
opm/core/wells/DynamicListEconLimited.hpp
opm/core/wells/WellsManager_impl.hpp
opm/core/doxygen_main.hpp
opm/core/grid.h
opm/core/grid/CellQuadrature.hpp
opm/core/grid/ColumnExtract.hpp
opm/core/grid/FaceQuadrature.hpp
opm/core/grid/GridHelpers.hpp
opm/core/grid/GridManager.hpp
opm/core/grid/GridUtilities.hpp
opm/core/grid/MinpvProcessor.hpp
opm/core/grid/cart_grid.h
opm/core/grid/cornerpoint_grid.h
opm/core/grid/cpgpreprocess/facetopology.h
opm/core/grid/cpgpreprocess/geometry.h
opm/core/grid/cpgpreprocess/preprocess.h
opm/core/grid/cpgpreprocess/uniquepoints.h
opm/core/io/eclipse/CornerpointChopper.hpp
opm/core/io/eclipse/EclipseGridInspector.hpp
opm/core/io/eclipse/EclipseUnits.hpp
opm/core/io/eclipse/EclipseWriter.hpp
opm/core/io/eclipse/EclipseWriteRFTHandler.hpp
opm/core/io/eclipse/writeECLData.hpp
opm/core/io/OutputWriter.hpp
opm/core/io/vag/vag.hpp
opm/core/io/vtk/writeVtkData.hpp
opm/core/linalg/LinearSolverFactory.hpp
opm/core/linalg/LinearSolverInterface.hpp
opm/core/linalg/LinearSolverIstl.hpp
opm/core/linalg/LinearSolverUmfpack.hpp
opm/core/linalg/LinearSolverPetsc.hpp
opm/core/linalg/ParallelIstlInformation.hpp
opm/core/linalg/blas_lapack.h
opm/core/linalg/call_umfpack.h
opm/core/linalg/sparse_sys.h
opm/core/version.h
opm/core/wells.h
opm/core/well_controls.h
opm/core/pressure/CompressibleTpfa.hpp
opm/core/pressure/FlowBCManager.hpp
opm/core/pressure/IncompTpfa.hpp
opm/core/pressure/IncompTpfaSinglePhase.hpp
opm/core/pressure/flow_bc.h
opm/core/pressure/fsh.h
opm/core/pressure/fsh_common_impl.h
opm/core/pressure/legacy_well.h
opm/core/pressure/mimetic/hybsys.h
opm/core/pressure/mimetic/hybsys_global.h
opm/core/pressure/mimetic/mimetic.h
opm/core/pressure/msmfem/coarse_conn.h
opm/core/pressure/msmfem/coarse_sys.h
opm/core/pressure/msmfem/dfs.h
opm/core/pressure/msmfem/hash_set.h
opm/core/pressure/msmfem/ifsh_ms.h
opm/core/pressure/msmfem/partition.h
opm/core/pressure/tpfa/cfs_tpfa.h
opm/core/pressure/tpfa/cfs_tpfa_residual.h
opm/core/pressure/tpfa/compr_bc.h
opm/core/pressure/tpfa/compr_quant.h
opm/core/pressure/tpfa/compr_quant_general.h
opm/core/pressure/tpfa/compr_source.h
opm/core/pressure/tpfa/ifs_tpfa.h
opm/core/pressure/tpfa/TransTpfa.hpp
opm/core/pressure/tpfa/TransTpfa_impl.hpp
opm/core/pressure/tpfa/trans_tpfa.h
opm/core/props/BlackoilPhases.hpp
opm/core/props/BlackoilPropertiesBasic.hpp
opm/core/props/BlackoilPropertiesFromDeck.hpp
opm/core/props/BlackoilPropertiesFromDeck_impl.hpp
opm/core/props/BlackoilPropertiesInterface.hpp
opm/core/props/IncompPropertiesBasic.hpp
opm/core/props/IncompPropertiesFromDeck.hpp
opm/core/props/IncompPropertiesInterface.hpp
opm/core/props/IncompPropertiesShadow.hpp
opm/core/props/IncompPropertiesShadow_impl.hpp
opm/core/props/IncompPropertiesSinglePhase.hpp
opm/core/props/phaseUsageFromDeck.hpp
opm/core/props/pvt/BlackoilPvtProperties.hpp
opm/core/props/pvt/PvtPropertiesBasic.hpp
opm/core/props/pvt/PvtPropertiesIncompFromDeck.hpp
opm/core/props/pvt/PvtConstCompr.hpp
opm/core/props/pvt/PvtDead.hpp
opm/core/props/pvt/PvtDeadSpline.hpp
opm/core/props/pvt/PvtInterface.hpp
opm/core/props/pvt/PvtLiveGas.hpp
opm/core/props/pvt/PvtLiveOil.hpp
opm/core/props/pvt/ThermalWaterPvtWrapper.hpp
opm/core/props/pvt/ThermalOilPvtWrapper.hpp
opm/core/props/pvt/ThermalGasPvtWrapper.hpp
opm/core/props/rock/RockBasic.hpp
opm/core/props/rock/RockCompressibility.hpp
opm/core/props/rock/RockFromDeck.hpp
opm/core/props/satfunc/SatFuncBase.hpp
opm/core/props/satfunc/SatFuncGwseg.hpp
opm/core/props/satfunc/SatFuncSimple.hpp
opm/core/props/satfunc/SatFuncStone2.hpp
opm/core/props/satfunc/SaturationPropsBasic.hpp
opm/core/props/satfunc/SaturationPropsFromDeck.hpp
opm/core/props/satfunc/SaturationPropsFromDeck_impl.hpp
opm/core/props/satfunc/SaturationPropsInterface.hpp
opm/core/simulator/AdaptiveSimulatorTimer.hpp
opm/core/simulator/AdaptiveTimeStepping.hpp
opm/core/simulator/AdaptiveTimeStepping_impl.hpp
opm/core/simulator/BlackoilState.hpp
opm/core/simulator/EquilibrationHelpers.hpp
opm/core/simulator/TimeStepControl.hpp
opm/core/simulator/SimulatorCompressibleTwophase.hpp
opm/core/simulator/SimulatorIncompTwophase.hpp
opm/core/simulator/SimulatorOutput.hpp
opm/core/simulator/SimulatorReport.hpp
opm/core/simulator/SimulatorState.hpp
opm/core/simulator/SimulatorTimerInterface.hpp
opm/core/simulator/SimulatorTimer.hpp
opm/core/simulator/TimeStepControlInterface.hpp
opm/core/simulator/TwophaseState.hpp
opm/core/simulator/TwophaseState_impl.hpp
opm/core/simulator/WellState.hpp
opm/core/simulator/initState.hpp
opm/core/simulator/initState_impl.hpp
opm/core/simulator/initStateEquil.hpp
opm/core/simulator/initStateEquil_impl.hpp
opm/core/flowdiagnostics/AnisotropicEikonal.hpp
opm/core/flowdiagnostics/DGBasis.hpp
opm/core/flowdiagnostics/FlowDiagnostics.hpp
opm/core/flowdiagnostics/TofReorder.hpp
opm/core/flowdiagnostics/TofDiscGalReorder.hpp
opm/core/transport/TransportSolverTwophaseInterface.hpp
opm/core/transport/implicit/CSRMatrixBlockAssembler.hpp
opm/core/transport/implicit/CSRMatrixUmfpackSolver.hpp
opm/core/transport/implicit/ImplicitAssembly.hpp
opm/core/transport/implicit/ImplicitTransport.hpp
opm/core/transport/implicit/JacobianSystem.hpp
opm/core/transport/implicit/NormSupport.hpp
opm/core/transport/implicit/SinglePointUpwindTwoPhase.hpp
opm/core/transport/implicit/TransportSolverTwophaseImplicit.hpp
opm/core/transport/implicit/SimpleFluid2pWrappingProps.hpp
opm/core/transport/implicit/SimpleFluid2pWrappingProps_impl.hpp
opm/core/transport/implicit/transport_source.h
opm/core/transport/minimal/spu_explicit.h
opm/core/transport/minimal/spu_implicit.h
opm/core/transport/reorder/TransportSolverCompressibleTwophaseReorder.hpp
opm/core/transport/reorder/ReorderSolverInterface.hpp
opm/core/transport/reorder/TransportSolverTwophaseReorder.hpp
opm/core/transport/reorder/reordersequence.h
opm/core/transport/reorder/tarjan.h
opm/core/utility/Average.hpp
opm/core/utility/ClassName.hpp
opm/core/utility/CompressedPropertyAccess.hpp
opm/core/utility/DataMap.hpp
opm/core/utility/ErrorMacros.hpp
opm/core/utility/Event.hpp
opm/core/utility/Event_impl.hpp
opm/core/utility/Exceptions.hpp
opm/core/utility/Factory.hpp
opm/core/utility/MonotCubicInterpolator.hpp
opm/core/utility/NonuniformTableLinear.hpp
opm/core/utility/NullStream.hpp
opm/core/utility/PolynomialUtils.hpp
opm/core/utility/RegionMapping.hpp
opm/core/utility/RootFinders.hpp
opm/core/utility/SparseTable.hpp
opm/core/utility/SparseVector.hpp
opm/core/utility/Spline.hpp
opm/core/utility/StopWatch.hpp
opm/core/utility/TridiagonalMatrix.hpp
opm/core/utility/UniformTableLinear.hpp
opm/core/utility/Units.hpp
opm/core/utility/Unused.hpp
opm/core/utility/VelocityInterpolation.hpp
opm/core/utility/WachspressCoord.hpp
opm/core/utility/buildUniformMonotoneTable.hpp
opm/core/utility/have_boost_redef.hpp
opm/core/utility/linearInterpolation.hpp
opm/core/utility/miscUtilities.hpp
opm/core/utility/miscUtilities_impl.hpp
opm/core/utility/miscUtilitiesBlackoil.hpp
opm/core/utility/parameters/Parameter.hpp
opm/core/utility/parameters/ParameterGroup.hpp
opm/core/utility/parameters/ParameterGroup_impl.hpp
opm/core/utility/parameters/ParameterMapItem.hpp
opm/core/utility/parameters/ParameterRequirement.hpp
opm/core/utility/parameters/ParameterStrings.hpp
opm/core/utility/parameters/ParameterTools.hpp
opm/core/utility/parameters/ParameterXML.hpp
opm/core/utility/parameters/tinyxml/tinystr.h
opm/core/utility/parameters/tinyxml/tinyxml.h
opm/core/utility/platform_dependent/disable_warnings.h
opm/core/utility/platform_dependent/reenable_warnings.h
opm/core/utility/PropertySystem.hpp
opm/core/utility/share_obj.hpp
opm/core/utility/thresholdPressures.hpp
opm/core/wells/InjectionSpecification.hpp
opm/core/wells/ProductionSpecification.hpp
opm/core/wells/WellCollection.hpp
opm/core/wells/WellsGroup.hpp
opm/core/wells/WellsManager.hpp
opm/core/wells/WellsManager_impl.hpp
)

View File

@ -2,6 +2,6 @@
set(CTEST_PROJECT_NAME "${${project}_NAME}")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "cdash.opm-project.org")
set(CTEST_DROP_LOCATION "/submit.php?project=${${project}_NAME}")
set(CTEST_DROP_SITE "opm-project.org")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=${${project}_NAME}")
set(CTEST_DROP_SITE_CDASH TRUE)

View File

@ -1,7 +1,5 @@
# Open Porous Media Core Library
THIS MODULE IS DEPRECATED.
The code is now integrated in the other modules.
Open Porous Media Core Library
==============================
These are release notes for opm-core.
@ -11,13 +9,13 @@ CONTENT
opm-core is the core library within OPM and contains the following
* Eclipse deck input and preprosessing
* Fluid properties (basic PVT models and rock properties)
* Grid handling (cornerpoint grids, unstructured grid interface)
* Linear Algebra (interface to different linear solvers)
* Pressure solvers (various discretization schemes, flow models)
* Simulators (some basic examples of simulators based on sequential splitting schemes)
* Transport solvers (various discretization schemes, flow models)
* Flow diagnostics (time-of-flight and tracer solvers, diagnostic functions)
* Utilities (input and output processing, unit conversion)
* Wells (basic well handling)
@ -65,12 +63,7 @@ sudo apt-get install libdune-common-dev libdune-istl-dev libdune-grid-dev
# libraries necessary for OPM
sudo apt-get install -y libtinyxml-dev
# Ensemble based Reservoir Tool Eclipse utilities module
# IMPORTANT: if you install this (binary) version of ERT,
# you will get the 2015.04 release version. That
# is only compatible with the 2015.04 release version
# of OPM! If you are building OPM from source you should
# use the latest master branches of both ERT and OPM.
# optional: Ensemble based Reservoir Tool Eclipse utilities module
sudo apt-get install ert.ecl
Note: You should compile the OPM modules using the same toolchain that
@ -95,7 +88,7 @@ sudo zypper in gcc gcc-c++ gcc-fortran cmake git doxygen
# DUNE libraries
sudo zypper in dune-common-devel dune-istl-devel
# Ensemble-based Reservoir Tools Eclipse utility module
# optional: Ensemble-based Reservoir Tools Eclipse utility module
git sudo zypper ar http://www.opm-project.org/packages/current/opensuse/12/opm.repo
sudo zypper in zlib-devel ert.ecl-devel
@ -118,12 +111,11 @@ sudo yum install boost-devel suitesparse-devel blas-devel lapack-devel
# libraries necessary for OPM
sudo yum install tinyxml-devel
# optional libraries
sudo yum-config-manager --add-repo \
http://www.opm-project.org/packages/current/redhat/6/opm.repo
sudo yum install libsuperlu3 ert.ecl-devel
# optional
sudo yum install dune-istl-devel
sudo yum install libsuperlu3 ert.ecl-devel dune-istl-devel
DEPENDENCIES FOR MACOS X

View File

@ -0,0 +1,102 @@
# - Add options without repeating them on the command line
#
# Synopsis:
#
# add_options (lang build opts)
#
# where:
#
# lang Name of the language whose compiler should receive the
# options, e.g. CXX. If a comma-separated list is received
# then the option is added for all those languages. Use the
# special value ALL_LANGUAGES for these languages: CXX, C
# and Fortran
#
# build Kind of build to which this options should apply,
# such as DEBUG and RELEASE. This can also be a comma-
# separated list. Use the special value ALL_BUILDS to apply
# to all builds.
#
# opts List of options to add. Each should be quoted.
#
# Example:
#
# add_options (CXX RELEASE "-O3" "-DNDEBUG" "-Wall")
function (add_options langs builds)
# special handling of empty language specification
if ("${langs}" STREQUAL "ALL_LANGUAGES")
set (langs CXX C Fortran)
endif ("${langs}" STREQUAL "ALL_LANGUAGES")
foreach (lang IN LISTS langs)
# prepend underscore if necessary
foreach (build IN LISTS builds)
if (NOT ("${build}" STREQUAL "ALL_BUILDS"))
set (_bld "_${build}")
string (TOUPPER "${_bld}" _bld)
else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
set (_bld "")
endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
# if we want everything in the "global" flag, then simply
# ignore the build type here and go add everything to that one
if (CMAKE_NOT_USING_CONFIG_FLAGS)
set (_bld "")
endif ()
foreach (_opt IN LISTS ARGN)
set (_var "CMAKE_${lang}_FLAGS${_bld}")
#message (STATUS "Adding \"${_opt}\" to \${${_var}}")
# remove it first
string (REPLACE "${_opt}" "" _without "${${_var}}")
string (STRIP "${_without}" _without)
# we need to strip this one as well, so they are comparable
string (STRIP "${${_var}}" _stripped)
# if it wasn't there, then add it at the end
if ("${_without}" STREQUAL "${_stripped}")
# don't add any extra spaces if no options yet are set
if (NOT ${_stripped} STREQUAL "")
set (${_var} "${_stripped} ${_opt}")
else (NOT ${_stripped} STREQUAL "")
set (${_var} "${_opt}")
endif (NOT ${_stripped} STREQUAL "")
set (${_var} "${${_var}}" PARENT_SCOPE)
endif ("${_without}" STREQUAL "${_stripped}")
endforeach (_opt)
endforeach (build)
endforeach (lang)
endfunction (add_options lang build)
# set varname to flag unless user has specified something that matches regex
function (set_default_option lang varname flag regex)
# lang is either C, CXX or Fortran
if ("${lang}" STREQUAL "Fortran")
set (letter "F")
else ()
set (letter "${lang}")
endif ()
string (TOUPPER "${CMAKE_BUILD_TYPE}" _build)
if ((NOT ("$ENV{${letter}FLAGS}" MATCHES "${regex}"))
AND (NOT ("${CMAKE_${lang}_FLAGS}" MATCHES "${regex}"))
AND (NOT ("${CMAKE_${lang}_FLAGS_${_build}}" MATCHES "${regex}")))
set (${varname} ${flag} PARENT_SCOPE)
else ()
set (${varname} PARENT_SCOPE)
endif ()
endfunction (set_default_option)
# clear default options as a proxy for not using any default options
# at all. there is one *huge* problem with this: CMake runs the platform
# initialization before executing any line at all in the project and
# there seems to be no way to disable that behaviour, so we cannot really
# distinguish between a platform default and something that the user has
# passed on the command line. the best thing we can do is to all user-
# defined setting if they are something other than the platform default.
macro (no_default_options)
foreach (lang IN ITEMS C CXX Fortran)
foreach (build IN ITEMS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
if ("${CMAKE_${lang}_FLAGS_${build}}" STREQUAL "${CMAKE_${lang}_FLAGS_${build}_INIT}")
# for some strange reason we cannot clear this flag, only set it to empty
set (CMAKE_${lang}_FLAGS_${build} "")
endif ()
endforeach (build)
endforeach (lang)
endmacro (no_default_options)

View File

@ -0,0 +1,111 @@
# - Create config.h based on a list of variables
#
# Synopsis:
# configure_vars (FILE syntax filename verb varlist)
# where
# syntax CXX or CMAKE, depending on target
# filename Full path (including name) of config.h
# verb WRITE or APPEND if truncating or not
# varlist List of variable names that has been defined
#
# In addition, this function will define HAVE_CONFIG_H for the
# following compilations, (only) if the filename is "config.h".
#
# Example:
# list (APPEND FOO_CONFIG_VARS
# "/* bar library */"
# "HAVE_BAR"
# "HAVE_BAR_VERSION_2"
# )
# configure_vars (
# FILE CXX ${PROJECT_BINARY_DIR}/config.h
# WRITE ${FOO_CONFIG_VARS}
# )
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
function (configure_vars obj syntax filename verb)
# this is just to make the syntax look like the build-in commands
if (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
message (FATAL_ERROR "Syntax error in argument list")
endif (NOT ("${obj}" STREQUAL "FILE" AND
(("${verb}" STREQUAL "WRITE") OR ("${verb}" STREQUAL "APPEND"))))
if (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
message (FATAL_ERROR "Invalid target syntax \"${syntax}\"")
endif (NOT (("${syntax}" STREQUAL "CXX") OR ("${syntax}" STREQUAL "CMAKE")))
# truncate the file if the verb was "WRITE"
if (verb STREQUAL "WRITE")
file (WRITE "${filename}" "")
endif (verb STREQUAL "WRITE")
# whenever we use this, we also signal to the header files that we
# have "config.h". add this before any other files (known till now)
# to avoid confusion from other configuration files.
get_filename_component (_config_path "${filename}" PATH)
get_filename_component (_config_file "${filename}" NAME)
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
add_definitions (-DHAVE_CONFIG_H=1)
include_directories (BEFORE "${_config_path}")
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
# only write the current value of each variable once
set (_args ${ARGN})
if (_args)
list (REMOVE_DUPLICATES _args)
endif (_args)
# process each variable
set (_prev_verbatim TRUE)
foreach (_var IN LISTS _args)
# massage the name to remove source code formatting
string (REGEX REPLACE "^[\\n\\t\\ ]+" "" _var "${_var}")
string (REGEX REPLACE "[\\n\\t\\ ]+$" "" _var "${_var}")
# if the name of a variable has the syntax of a comments, write it
# verbatim to the file; this can be used to create headings
if ("${_var}" MATCHES "^/[/*]")
if (NOT _prev_verbatim)
file (APPEND "${filename}" "\n")
endif (NOT _prev_verbatim)
file (APPEND "${filename}" "${_var}\n")
set (_prev_verbatim TRUE)
else ("${_var}" MATCHES "^/[/*]")
# write a CMake statements that warns if the value has changed
if ("${syntax}" STREQUAL "CMAKE")
set (_db "\${") # to avoid parsing problems
file (APPEND "${filename}" "if (DEFINED ${_var} AND NOT \"${_db}${_var}}\" STREQUAL \"${${_var}}\")\n")
file (APPEND "${filename}" "\tmessage (WARNING \"Incompatible value \\\"${_db}${_var}}\\\" of variable \\\"${_var}\\\"\")\n")
file (APPEND "${filename}" "endif ()\n")
endif ()
# check for empty variable; variables that are explicitly set to false
# is not included in this clause
if ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
if ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "set (${_var})\n")
else ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "/* #undef ${_var} */\n")
endif ("${syntax}" STREQUAL "CMAKE")
else ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
# write to file using the correct syntax
if ("${syntax}" STREQUAL "CMAKE")
# escape backslash and double quote characters
string (REPLACE "\\" "\\\\" _quoted "${${_var}}")
string (REPLACE "\"" "\\\"" _quoted "${_quoted}")
file (APPEND "${filename}" "set (${_var} \"${_quoted}\")\n")
else ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "#define ${_var} ${${_var}}\n")
endif ("${syntax}" STREQUAL "CMAKE")
endif ((NOT DEFINED ${_var}) OR ("${${_var}}" STREQUAL ""))
set (_prev_verbatim FALSE)
endif ("${_var}" MATCHES "^/[/*]")
endforeach(_var)
endfunction (configure_vars obj syntax filename verb)

View File

@ -0,0 +1,47 @@
# - Dunecontrol compatibility
#
# Enables this build to be a part of a dunecontrol chain. The
# DUNE_CHECK_MODULES macro greps the top-level Makefile for the
# presence of the abs_top_srcdir variable (!) and uses that as
# the include directory of a module. Also, the contents are not
# checked so if the variable is not present, it generates an
# invalid command line (-I without argument) which causes the
# autoconf probe to fail. This module patches our Makefile (!!)
# so the necessary string will be there; in itself this string
# has no use for us, it is solemnly to satisfy the M4 scripts.
if (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# we need an up-to-date, patched Makefile. this is always checked when
# the makefile is run, thus the need for a marker file to keep a
# timestamp to see when it was last patched (by us)
# amazingly, nothing depends on the generated Makefile, so this can be
# run whenever in the build without trigging a compile of e.g. config.h
add_custom_target (dune-compat ALL
COMMAND ${CMAKE_COMMAND} -DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY} -P ${OPM_MACROS_ROOT}/cmake/Scripts/DuneCompat2.cmake
COMMENT "Patching Makefile to be DUNE compatible"
)
endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")
# dunecontrol refuses to use a build tree as module directory unless
# there is a dune.module in it. however, if we are in a sub-dir. of
# the source, we are probably using dunecontrol with a --build-dir
# argument, and won't call dunecontrol from the parent (which is the
# source dir and most likely doesn't contain other projects) anyway,
# i.e. we only copy if we are truly out-of-source
string (LENGTH "${PROJECT_SOURCE_DIR}/" _src_dir_len)
string (LENGTH "${PROJECT_BINARY_DIR}/" _bin_dir_len)
if (_src_dir_len GREATER _bin_dir_len)
set (_not_substring TRUE)
else (_src_dir_len GREATER _bin_dir_len)
string (SUBSTRING "${PROJECT_BINARY_DIR}/" 0 ${_src_dir_len} _proj_prefix)
if ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
set (_not_substring FALSE)
else ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
set (_not_substring TRUE)
endif ("${PROJECT_SOURCE_DIR}/" STREQUAL "${_proj_prefix}")
endif (_src_dir_len GREATER _bin_dir_len)
if (_not_substring)
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${PROJECT_SOURCE_DIR}/dune.module ${PROJECT_BINARY_DIR}/dune.module
)
endif (_not_substring)

View File

@ -0,0 +1,38 @@
# - Remove duplicate library declarations
#
# Synopsis:
#
# remove_duplicate_libraries (module)
#
# where
# module Name of the module whose libraries should be pruned
# Copyright (C) 2013 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
# libraries should always be trimmed from the beginning, so that also
# missing functions in those later in the list will be resolved
macro (remove_duplicate_libraries module)
if (DEFINED ${module}_LIBRARIES)
list (REVERSE ${module}_LIBRARIES)
list (REMOVE_DUPLICATES ${module}_LIBRARIES)
list (REVERSE ${module}_LIBRARIES)
endif (DEFINED ${module}_LIBRARIES)
endmacro (remove_duplicate_libraries module)
# headers can be trimmed from the end, since adding a directory to
# the list is an idempotent action
macro (remove_duplicate_var module suffix)
if (DEFINED ${module}_${suffix})
list (REMOVE_DUPLICATES ${module}_${suffix})
endif (DEFINED ${module}_${suffix})
endmacro (remove_duplicate_var module suffix)
# fix up both headers and libraries, in case two dependencies have
# included the same second-level library independently
macro (remove_dup_deps module)
remove_duplicate_var (${module} INCLUDE_DIRS)
remove_duplicate_var (${module} LINKER_FLAGS)
remove_duplicate_var (${module} CONFIG_VARS)
remove_duplicate_libraries (${module})
endmacro (remove_dup_deps module)

View File

@ -0,0 +1,150 @@
#find_package(PkgConfig)
include(CheckLibraryExists)
macro(_opm_set_alugrid val)
set(ALUGRID_FOUND ${val})
if(NOT ALUGRID_FOUND AND ALUGRID_FIND_REQUIRED)
message(FATAL_ERROR "Could not find required libary ALUGrid")
endif()
# print status message if requested
if(NOT ALUGRID_FIND_QUIETLY)
if(ALUGRID_FOUND)
message(STATUS "Found ALUGrid")
else()
message(STATUS "Could not find ALUGrid")
endif()
endif()
endmacro()
if(ALUGRID_ROOT)
find_path(ALUGRID_PKGCONFIG_DIR alugrid.pc PATHS ${ALUGRID_ROOT}
PATH_SUFFIXES lib/pkgconfig/ alugrid/lib/pkgconfig
NO_DEFAULT_PATH)
find_file(ALUGRID_VERSION alugridversion PATHS ${ALUGRID_ROOT}/bin
NO_DEFAULT_PATH)
else()
find_path(ALUGRID_PKGCONFIG_DIR alugrid.pc
PATH_SUFFIXES lib/pkgconfig/ alugrid/lib/pkgconfig)
get_filename_component(_GUESSED_ALUGRID_ROOT ${ALUGRID_PKGCONFIG_DIR}/../../ ABSOLUTE)
find_file(ALUGRID_VERSION alugridversion PATHS ${_GUESSED_ALUGRID_ROOT}/bin NO_DEFAULT_PATH)
if(ALUGRID_VERSION)
set(ALUGRID_ROOT ${_GUESSED_ALUGRID_ROOT})
else(ALUGRID_VERSION_PATH)
get_filename_component(_GUESSED_ALUGRID_ROOT ${ALUGRID_PKGCONFIG_DIR}/../../.. ABSOLUTE)
find_file(ALUGRID_VERSION alugridversion
PATHS ${_GUESSED_ALUGRID_ROOT}
PATH_SUFFIXES bin
NO_DEFAULT_PATH)
if(ALUGRID_VERSION)
set(ALUGRID_ROOT ${_GUESSED_ALUGRID_ROOT})
endif(ALUGRID_VERSION)
endif(ALUGRID_VERSION)
endif()
unset(ALUGRID_PKGCONFIG_DIR CACHE)
set(ALUGRID_VERSION_REQUIRED 1.50)
if(NOT ALUGRID_VERSION)
message(STATUS "Could not find ALUGrid.")
_opm_set_alugrid(0)
return()
endif(NOT ALUGRID_VERSION)
execute_process(COMMAND ${ALUGRID_VERSION} -c ${ALUGRID_VERSION_REQUIRED} OUTPUT_VARIABLE ALUGRID_VERSION)
if(ALUGRID_VERSION LESS 0)
message(STATUS "ALUGrid version is less than ${ALUGRID_VERSION_REQUIRED}")
_opm_set_alugrid(0)
unset(ALUGRID_VERSION CACHE)
return()
else()
message(STATUS "ALUGrid version is compatible")
endif()
unset(ALUGRID_VERSION CACHE)
find_path(ALUGRID_INCLUDE_DIR "alugrid_serial.h"
PATHS "${ALUGRID_ROOT}" PATH_SUFFIXES "include" "include/serial"
NO_DEFAULT_PATH DOC "Include path of serial alugrid headers.")
if (NOT ALUGRID_INCLUDE_DIR)
message(STATUS "Could not deterimine ALUGrid include directory")
_opm_set_alugrid(0)
return()
endif()
mark_as_advanced(ALUGRID_INCLUDE_DIR)
find_library(ALUGRID_LIBRARY alugrid
PATHS "${ALUGRID_ROOT}"
PATH_SUFFIXES lib lib32 lib64
DOC "ALUGrid library"
NO_DEFAULT_PATH)
if (NOT ALUGRID_LIBRARY)
message(STATUS "Could not find ALUGrid usable library")
_opm_set_alugrid(0)
return()
endif()
set(ALUGRID_LIBRARIES ${ALUGRID_LIBRARY})
mark_as_advanced(ALUGRID_LIBRARIES)
set(ALUGRID_INCLUDE_DIRS
${ALUGRID_INCLUDE_DIR}
${ALUGRID_INCLUDE_DIR}/serial
${ALUGRID_INCLUDE_DIR}/duneinterface)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ALUGRID_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ALUGRID_LIBRARIES})
check_include_file_cxx(stlheaders.h ALUGRID_SERIAL_FOUND)
if(ALUGRID_SERIAL_FOUND)
check_cxx_source_compiles("#include <alugrid_defineparallel.h>
#if ALU3DGRID_BUILD_FOR_PARALLEL == 0
#error
#endif
int main(){}"
ALUGRID_PARALLEL_FOUND)
else()
message(STATUS "alugrid_serial.h found, but could not be compiled.")
_opm_set_alugrid(0)
return()
endif()
if(ALUGRID_PARALLEL_FOUND AND MPI_FOUND)
# must link with METIS if we are going to use parallel ALUGrid
find_package(METIS)
if (METIS_FOUND)
list(APPEND ALUGRID_LIBRARIES ${METIS_LIBRARIES})
# check for parallel ALUGrid
find_path(ALUGRID_PARALLEL_INCLUDE_PATH "alumetis.hh"
PATHS ${ALUGRID_INCLUDE_DIR}
PATH_SUFFIXES "parallel"
NO_DEFAULT_PATH)
if(ALUGRID_PARALLEL_INCLUDE_PATH)
list(APPEND ALUGRID_INCLUDE_DIRS ${ALUGRID_PARALLEL_INCLUDE_PATH})
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${ALUGRID_INCLUDE_DIRS})
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${ALUGRID_LIBRARIES})
#set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
check_include_file_cxx(alugrid_parallel.h ALUGRID_PARALLEL_FOUND)
unset(ALUGRID_PARALLEL_INCLUDE_PATH CACHE)
if(NOT ALUGRID_PARALLEL_FOUND)
message(STATUS "alumetis.hh not found in ${ALUGRID_PARALLEL_INCLUDE_PATH}")
endif()
else()
message (STATUS "METIS not found, parallel ALUGrid disabled")
set (ALUGRID_PARALLEL_FOUND 0)
endif()
else()
message(STATUS "alumetis.hh not found (required by parallel alugrid).")
set(ALUGRID_PARALLEL_FOUND 0)
endif()
endif()
if(ALUGRID_SERIAL_FOUND)
_opm_set_alugrid(1)
endif(ALUGRID_SERIAL_FOUND)

View File

@ -0,0 +1,25 @@
# - Module that checks for supported C99 features.
# macro to only add option once
include (AddOptions)
# try to use compiler flag -std=c99
set (C_STD99_FLAGS "-std=c99")
# incidently, the C++ test is so simple that it can be used to compile C as well
include (CheckCCompilerFlag)
check_c_compiler_flag (${C_STD99_FLAGS} HAVE_C99)
# add option if we are capable
if (HAVE_C99)
add_options (C ALL_BUILDS "${C_STD99_FLAGS}")
else (HAVE_C99)
set (C_STD99_FLAGS)
endif (HAVE_C99)
# handle quiet and required
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (C99
DEFAULT_MSG
C_STD99_FLAGS
)

View File

@ -0,0 +1,470 @@
#
# Module that checks for supported C++11 (former C++0x) features.
#
# Sets the follwing variable:
#
# HAVE_FINAL True if the compiler supports the "final" quantifier
# HAVE_TYPE_TRAITS True if the <type_traits> header is available and implements sufficient functionality
# HAVE_SHARED_PTR True if std::shared_ptr is available
# HAVE_UNIQUE_PTR True if std::unique_ptr is available
# HAVE_NULLPTR True if nullptr is available
# HAVE_REGEX True if std::regex available and sufficiently usable
# HAVE_ARRAY True if header <array> and fill() are available
# HAVE_ATTRIBUTE_ALWAYS_INLINE True if attribute always inline is supported
# HAS_ATTRIBUTE_UNUSED True if attribute unused is supported
# HAS_ATTRIBUTE_DEPRECATED True if attribute deprecated is supported
# HAS_ATTRIBUTE_DEPRECATED_MSG True if attribute deprecated("msg") is supported
# HAVE_CONSTEXPR True if constexpr attribute is available
# HAVE_INTEGRAL_CONSTANT True if compiler supports integral_constant
# HAVE_STATIC_ASSERT True if static_assert is available
# HAVE_AUTO True if the compiler supports the auto keyword
# HAVE_VARIADIC_TEMPLATES True if variadic templates are supported
# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported
# HAVE_RVALUE_REFERENCES True if rvalue references are supported
# HAVE_TUPLE True if std::tuple is available
# HAVE_TR1_TUPLE True if std::tr1::tuple is available
include(CheckCXXSourceCompiles)
include(CheckCXXSourceRuns)
# test for C++11 flags
include(TestCXXAcceptsFlag)
include(CheckIncludeFileCXX)
# macro to only add option once
include(AddOptions)
# try to use compiler flag -std=c++11
CHECK_CXX_ACCEPTS_FLAG("-std=c++11" CXX_FLAG_CXX11)
if(CXX_FLAG_CXX11)
add_options (CXX ALL_BUILDS "-std=c++11")
set(CXX_STD0X_FLAGS "-std=c++11")
else()
# try to use compiler flag -std=c++0x for older compilers
CHECK_CXX_ACCEPTS_FLAG("-std=c++0x" CXX_FLAG_CXX0X)
if(CXX_FLAG_CXX0X)
add_options (CXX ALL_BUILDS "-std=c++0x")
set(CXX_STD0X_FLAGS "-std=c++0x")
endif(CXX_FLAG_CXX0X)
endif(CXX_FLAG_CXX11)
# if we are building with an Apple toolchain in MacOS X,
# we cannot use the old GCC 4.2 fork, but must use the
# new runtime library
set (CXX_STDLIB_FLAGS)
string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
if (APPLE AND (_comp_id MATCHES "CLANG"))
CHECK_CXX_ACCEPTS_FLAG ("-stdlib=libc++" CXX_FLAG_STDLIB_LIBCXX)
if (CXX_FLAG_STDLIB_LIBCXX)
add_options (CXX ALL_BUILDS "-stdlib=libc++")
set (CXX_STDLIB_FLAGS "-stdlib=libc++")
endif (CXX_FLAG_STDLIB_LIBCXX)
endif (APPLE AND (_comp_id MATCHES "CLANG"))
# to format the command-line options pretty, we have an optional space
if (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE " ")
else (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
set (CXX_SPACE)
endif (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
# perform tests
include(CheckCXXSourceCompiles)
# the "final" method specifier
CHECK_CXX_SOURCE_COMPILES("
struct Base {
virtual void foo() = 0;
};
struct Derived : public Base {
virtual void foo() final {};
};
int main()
{
return 0;
}
" HAVE_FINAL
)
# std::is_convertible, std::is_base_of
CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>
class Base {};
class Derived : public Base {};
int main()
{
bool foo = std::is_convertible<int, double>::value;
bool bar = std::is_base_of<Base, Derived>::value;
bool foobar = std::is_integral<double>::value;
return 0;
}
" HAVE_TYPE_TRAITS
)
# nullptr
CHECK_CXX_SOURCE_COMPILES("
#include <memory>
int main(void)
{
std::shared_ptr<int> foo(new int(123));
return 0;
}
" HAVE_SHARED_PTR
)
# this is required by dune-common to avoid linker errors. "fun"!
if (HAVE_SHARED_PTR)
set(HAVE_MAKE_SHARED 1)
set(SHARED_PTR_HEADER "<memory>")
set(SHARED_PTR_NAMESPACE "std")
endif()
# nullptr
CHECK_CXX_SOURCE_COMPILES("
#include <memory>
int main(void)
{
std::unique_ptr<int> foo(new int(123));
return 0;
}
" HAVE_UNIQUE_PTR
)
# nullptr
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
char* ch = nullptr;
return 0;
}
" HAVE_NULLPTR
)
# <regex>
CHECK_CXX_SOURCE_RUNS("
#include <regex>
int main(void)
{
std::regex r(\"AB.*|BC+|DE.+\", std::regex::extended);
if (!std::regex_match(\"AB\", r))
return 1;
if (!std::regex_match(\"ABC\", r))
return 2;
if (!std::regex_match(\"ABC!#\", r))
return 3;
if (std::regex_match(\"B\", r))
return 4;
if (!std::regex_match(\"BC\", r))
return 5;
if (std::regex_match(\"BCE\", r))
return 6;
if (std::regex_match(\"DE\", r))
return 7;
if (!std::regex_match(\"DEF\", r))
return 8;
return 0;
}
" HAVE_REGEX
)
# constexpr
CHECK_CXX_SOURCE_COMPILES("
template <class T>
inline constexpr int foo(T bar) { return bar*2; }
int main(void)
{
constexpr int foobar = foo(100);
return 0;
}
" HAVE_CONSTEXPR
)
# array and fill
CHECK_CXX_SOURCE_COMPILES("
#include <array>
int main(void)
{
std::array<int,2> a;
a.fill(9);
return 0;
}
" HAVE_ARRAY
)
# Check whether if std::integral_constant< T, v > is supported and casts into T
CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>
void f( int ){}
int main(void){
f( std::integral_constant< int, 42 >() );
}
" HAVE_INTEGRAL_CONSTANT
)
# Check whether if <tuple> is available
check_include_file_cxx("tuple" HAVE_TUPLE)
# Check whether if <tr1/tuple> is available
check_include_file_cxx("tr1/tuple" HAVE_TR1_TUPLE)
# __attribute__((always_inline))
CHECK_CXX_SOURCE_COMPILES("
void __attribute__((always_inline)) foo(void) {}
int main(void)
{
foo();
return 0;
};
" HAVE_ATTRIBUTE_ALWAYS_INLINE
)
# __attribute__((unused))
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
int __attribute__((unused)) foo;
return 0;
};
" HAS_ATTRIBUTE_UNUSED
)
# __attribute__((deprecated))
CHECK_CXX_SOURCE_COMPILES("
#define DEP __attribute__((deprecated))
class bar
{
bar() DEP;
};
class peng { } DEP;
template <class T>
class t_bar
{
t_bar() DEP;
};
template <class T>
class t_peng {
t_peng() {};
} DEP;
void foo() DEP;
void foo() {};
int main(void)
{
return 0;
};
" HAS_ATTRIBUTE_DEPRECATED
)
# __attribute__((deprecated("msg")))
CHECK_CXX_SOURCE_COMPILES("
#define DEP __attribute__((deprecated(\"message\")))
class bar {
bar() DEP;
};
class peng { } DEP;
template <class T>
class t_bar
{
t_bar() DEP;
};
template <class T>
class t_peng
{
t_peng() {};
} DEP;
void foo() DEP;
void foo() {};
int main(void)
{
return 0;
};
" HAS_ATTRIBUTE_DEPRECATED_MSG
)
# static assert
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
static_assert(true,\"MSG\");
return 0;
}
" HAVE_STATIC_ASSERT
)
# auto keyword
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
auto foo = 1.23;
return 0;
}
" HAVE_AUTO
)
# variadic template support
CHECK_CXX_SOURCE_COMPILES("
#include <cassert>
template<typename... T>
int addints(T... x);
int add_ints()
{
return 0;
}
template<typename T1, typename... T>
int add_ints(T1 t1, T... t)
{
return t1 + add_ints(t...);
}
int main(void)
{
assert( 5 == add_ints(9,3,-5,-2) );
return 0;
}
" HAVE_VARIADIC_TEMPLATES
)
# SFINAE on variadic template constructors within template classes
CHECK_CXX_SOURCE_COMPILES("
#include <functional>
template<typename... U>
struct A
{
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) < 2)>::type
>
A(T... t)
: i(1)
{}
template<typename... T,
typename = typename std::enable_if<(sizeof...(T) >= 2)>::type,
typename = void
>
A(T... t)
: i(-1)
{}
A()
: i(1)
{}
int i;
};
int main(void)
{
return (A<int>().i + A<int>(2).i + A<int>(\"foo\",3.4).i + A<int>(8,'a',A<int>()).i == 0 ? 0 : 1);
}
" HAVE_VARIADIC_CONSTRUCTOR_SFINAE
)
# rvalue references
CHECK_CXX_SOURCE_COMPILES("
#include <cassert>
#include <utility>
int foo(int&& x) { return 1; }
int foo(const int& x) { return -1; }
template<typename T>
int forward(T&& x)
{
return foo(std::forward<T>(x));
}
int main(void)
{
int i = 0;
assert( forward(i) + forward(int(2)) == 0);
return 0;
}
" HAVE_RVALUE_REFERENCES
)
include(CheckIncludeFile)
include(CheckIncludeFileCXX)
# Search for some tr1 headers
foreach(_HEADER tuple tr1/tuple type_traits tr1/type_traits)
string(REPLACE "/" "_" _HEADER_VAR ${_HEADER})
string(TOUPPER ${_HEADER_VAR} _HEADER_VAR )
check_include_file_cxx(${_HEADER} "HAVE_${_HEADER_VAR}")
endforeach(_HEADER tuple tr1/tuple tr1/type_traits)
# make sure that the C++-11 features implemented by the compiler are a
# superset of those provided by GCC 4.4. This makes the test fail on
# all GCC compilers before 4.4.
set(CXX_FEATURES_MISSING "")
if (NOT HAVE_TYPE_TRAITS)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Sufficiently conformant type traits (defined by the 'type_traits' header file)\n")
endif()
if (NOT HAVE_SHARED_PTR)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Shared pointers (the std::shared_ptr class)\n")
endif()
if (NOT HAVE_UNIQUE_PTR)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Unique pointers (the std::unique_ptr class)\n")
endif()
if (NOT HAVE_ARRAY)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Statically sized arrays (the std::array class)\n")
endif()
if (NOT HAVE_STATIC_ASSERT)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Static assertations (the static_assert() mechanism)\n")
endif()
if (NOT HAVE_AUTO)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Automatically typed variables (the 'auto' keyword)\n")
endif()
if (NOT HAVE_VARIADIC_TEMPLATES)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Variable number of template arguments\n")
endif()
if (NOT HAVE_VARIADIC_CONSTRUCTOR_SFINAE)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Constructors with variable number of template arguments obeying the SFINAE (specialization failure is not an error) rule\n")
endif()
if (NOT HAVE_RVALUE_REFERENCES)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - References to rvalue objects\n")
endif()
if (NOT HAVE_TUPLE)
set(CXX_FEATURES_MISSING
"${CXX_FEATURES_MISSING} - Tuples (the std::tuple class)\n")
endif()
if(CXX_FEATURES_MISSING)
set (CXX11FEATURES_FOUND FALSE)
if (CXX11Features_FIND_REQUIRED)
message(FATAL_ERROR
"Your C++ compiler does not support the minimum set of C++-2011 features required. "
"Make sure to use a compiler which implements all C++-2011 features provided by GCC 4.4. "
"Your compiler does not seem to implement the following features:\n"
"${CXX_FEATURES_MISSING}")
endif()
else ()
set (CXX11FEATURES_FOUND TRUE)
endif()

View File

@ -0,0 +1,23 @@
# Module that checks whether the compiler supports the
# abi::__cxa_demangle function required to
# make the type names returned by typeid() human-readable
#
# Sets the following variable:
# HAVE_CXA_DEMANGLE
#
# perform tests
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <cxxabi.h>
int main(void){
int foobar = 0;
const char *foo = typeid(foobar).name();
int status;
char *demangled = abi::__cxa_demangle( foo, 0, 0, &status );
}" HAVE_CXA_DEMANGLE)
include (FindPackageHandleStandardArgs)
# prevent useless message from being displayed
set (FIND_PACKAGE_MESSAGE_DETAILS_CxaDemangle "[1][v()]"
CACHE INTERNAL "Details about finding CxaDemangle")
find_package_handle_standard_args (CxaDemangle DEFAULT_MSG HAVE_CXA_DEMANGLE)

240
cmake/Modules/FindERT.cmake Normal file
View File

@ -0,0 +1,240 @@
# - Find the Ensemble-based Reservoir Tool (ERT)
#
# Set the cache variable ERT_ROOT to the install location of the ERT
# libraries and header files.
#
# If found, it sets these variables:
#
# ERT_INCLUDE_DIRS Header file directories
# ERT_LIBRARIES Archives and shared objects
# ERT_CONFIG_VARS Definitions that goes in config.h
# ERT_LINKER_FLAGS Options that must be passed to linker
#
# It will also add to CMAKE_C_FLAGS and CMAKE_CXX_FLAGS if necessary to
# link with the ERT libraries.
# variables to pass on to other packages
if (FIND_QUIETLY)
set (ERT_QUIET "QUIET")
else (FIND_QUIETLY)
set (ERT_QUIET "")
endif (FIND_QUIETLY)
# if a directory has been specified by the user, then don't go look
# in the system directories as well
if (ERT_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
else (ERT_ROOT)
set (_no_default_path "")
endif (ERT_ROOT)
# ERT doesn't have any config-mode file, so we need to specify the root
# directory in its own variable
find_path (ERT_ECL_INCLUDE_DIR
NAMES "ert/ecl/ecl_util.h"
HINTS "${ERT_ROOT}"
PATHS "../ert"
PATH_SUFFIXES "devel/libecl/include/" "include"
DOC "Path to ERT Eclipse library header files"
${_no_default_path}
)
find_path (ERT_UTIL_INCLUDE_DIR
NAMES "ert/util/stringlist.h"
HINTS "${ERT_ROOT}"
PATHS "../ert"
PATH_SUFFIXES "devel/libert_util/include/" "include"
DOC "Path to ERT Eclipse library header files"
${_no_default_path}
)
find_path (ERT_GEN_INCLUDE_DIR
NAMES "ert/util/int_vector.h"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "libert_util/include/" "include"
DOC "Path to ERT generated library header files"
${_no_default_path}
)
# need all of these libraries
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
find_library (ERT_LIBRARY_ECL
NAMES "ecl"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files"
${_no_default_path}
)
find_library (ERT_LIBRARY_ECL_WELL
NAMES "ecl_well"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files"
${_no_default_path}
)
find_library (ERT_LIBRARY_GEOMETRY
NAMES "ert_geometry"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Geometry library archive/shared object files"
${_no_default_path}
)
find_library (ERT_LIBRARY_UTIL
NAMES "ert_util"
HINTS "${ERT_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../ert" "${PROJECT_BINARY_DIR}/../ert-build"
"${PROJECT_BINARY_DIR}/../ert/devel"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Utilities library archive/shared object files"
${_no_default_path}
)
# the "library" found here is actually a list of several files
list (APPEND ERT_INCLUDE_DIR
${ERT_ECL_INCLUDE_DIR}
${ERT_UTIL_INCLUDE_DIR}
${ERT_GEN_INCLUDE_DIR}
)
list (APPEND ERT_LIBRARY
${ERT_LIBRARY_ECL}
${ERT_LIBRARY_ECL_WELL}
${ERT_LIBRARY_GEOMETRY}
${ERT_LIBRARY_UTIL}
)
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
# if we didn't find any files, then don't proceed through the entire dependency list
include (FindPackageHandleStandardArgs)
if (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
find_package_handle_standard_args (ERT
DEFAULT_MSG
ERT_INCLUDE_DIR ERT_LIBRARY
)
# clear the cache so the find probe is attempted again if files becomes
# available (only upon a unsuccessful *compile* should we disable further
# probing)
set (HAVE_ERT)
unset (HAVE_ERT CACHE)
return ()
endif (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND")
# these system variables are probed for, and used in HEADER files (sic)
list (APPEND ERT_CONFIG_VARS
HAVE_ISFINITE
HAVE_GLOB
HAVE_FORK
HAVE_GETUID
HAVE_LOCKF
HAVE_OPENDIR
HAVE_PROC
HAVE_READLINKAT
HAVE_SYMLINK
HAVE_VA_COPY
)
include (CheckSymbolExists)
include (CheckFunctionExists)
check_symbol_exists (isfinite math.h HAVE_ISFINITE)
check_function_exists (glob HAVE_GLOB)
check_function_exists (fork HAVE_FORK)
check_function_exists (getuid HAVE_GETUID)
check_function_exists (lockf HAVE_LOCKF)
check_function_exists (opendir HAVE_OPENDIR)
check_function_exists (readlinkat HAVE_READLINKAT)
check_function_exists (symlink HAVE_SYMLINK)
check_symbol_exists (va_copy stdarg.h HAVE_VA_COPY)
if (UNIX)
set (HAVE_PROC 1)
else (UNIX)
set (HAVE_PROC)
endif (UNIX)
# dependencies
# parallel programming
include (UseOpenMP)
find_openmp (ERT)
# compression library
find_package (ZLIB ${ERT_QUIET})
if (ZLIB_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${ZLIB_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${ZLIB_LIBRARIES})
endif (ZLIB_FOUND)
# numerics
find_package (BLAS ${ERT_QUIET})
if (BLAS_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${BLAS_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${BLAS_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
endif (BLAS_FOUND)
find_package (LAPACK ${ERT_QUIET})
if (LAPACK_FOUND)
list (APPEND ERT_INCLUDE_DIRS ${LAPACK_INCLUDE_DIRS})
list (APPEND ERT_LIBRARIES ${LAPACK_LIBRARIES})
list (APPEND ERT_LINKER_FLAGS ${LAPACK_LINKER_FLAGS})
endif (LAPACK_FOUND)
# math library (should exist on all unices; automatically linked on Windows)
if (UNIX)
find_library (MATH_LIBRARY
NAMES "m"
)
list (APPEND ERT_LIBRARIES ${MATH_LIBRARY})
endif (UNIX)
# if shared libraries are disabled on linux, explcitly linking to the
# pthreads library is required by ERT
find_package(Threads ${ERT_QUIET})
if (CMAKE_THREAD_LIBS_INIT)
list (APPEND ERT_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif()
# Platform specific library where dlopen with friends lives
list (APPEND ERT_LIBRARIES ${CMAKE_DL_LIBS})
# since OpenMP often implies pthreads, we need to tidy up
# (last instance of library must be left standing, thus reversing that
# list before removing duplicates)
include (Duplicates)
remove_dup_deps (ERT)
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${ERT_INCLUDE_DIR})
set (CMAKE_REQUIRED_LIBRARIES ${ERT_LIBRARIES})
check_c_source_compiles (
"#include <ert/ecl/ecl_util.h>
int main (void) {
bool ok;
ok = ecl_util_fmt_file (\"foo.bar\", &ok);
return 0;
}" HAVE_ERT)
cmake_pop_check_state ()
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
# clear the cache so the find probe is attempted again if files becomes
# available (only upon a unsuccessful *compile* should we disable further
# probing)
set (HAVE_ERT)
unset (HAVE_ERT CACHE)
endif (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
# if the test program didn't compile, but was required to do so, bail
# out now and display an error; otherwise limp on
find_package_handle_standard_args (ERT
DEFAULT_MSG
ERT_INCLUDE_DIR ERT_LIBRARY HAVE_ERT
)

View File

@ -0,0 +1,125 @@
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN3_FOUND - system has eigen lib with correct version
# EIGEN3_INCLUDE_DIR - the eigen include directory
# EIGEN3_VERSION - eigen version
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
if(NOT Eigen3_FIND_VERSION)
if(NOT Eigen3_FIND_VERSION_MAJOR)
set(Eigen3_FIND_VERSION_MAJOR 2)
endif(NOT Eigen3_FIND_VERSION_MAJOR)
if(NOT Eigen3_FIND_VERSION_MINOR)
set(Eigen3_FIND_VERSION_MINOR 91)
endif(NOT Eigen3_FIND_VERSION_MINOR)
if(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION_PATCH 0)
endif(NOT Eigen3_FIND_VERSION_PATCH)
set(Eigen3_FIND_VERSION "${Eigen3_FIND_VERSION_MAJOR}.${Eigen3_FIND_VERSION_MINOR}.${Eigen3_FIND_VERSION_PATCH}")
endif(NOT Eigen3_FIND_VERSION)
macro(_eigen3_check_version)
file(READ "${EIGEN3_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)
string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN3_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN3_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN3_MINOR_VERSION "${CMAKE_MATCH_1}")
set(EIGEN3_VERSION ${EIGEN3_WORLD_VERSION}.${EIGEN3_MAJOR_VERSION}.${EIGEN3_MINOR_VERSION})
if(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK FALSE)
else(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
set(EIGEN3_VERSION_OK TRUE)
endif(${EIGEN3_VERSION} VERSION_LESS ${Eigen3_FIND_VERSION})
if(NOT EIGEN3_VERSION_OK)
message(STATUS "Eigen3 version ${EIGEN3_VERSION} found in ${EIGEN3_INCLUDE_DIR}, "
"but at least version ${Eigen3_FIND_VERSION} is required")
endif(NOT EIGEN3_VERSION_OK)
endmacro(_eigen3_check_version)
# only probe if we haven't a path in our cache
if (NOT EIGEN3_INCLUDE_DIR)
# allow Eigen3_ROOT to be used in addition to EIGEN3_ROOT
if (Eigen3_ROOT)
set (EIGEN3_ROOT "${Eigen3_ROOT}")
endif (Eigen3_ROOT)
# if the _ROOT is specified, then look *only* there; don't allow any
# other version to be swapped in to substitute; if not specified, then
# go search usual locations
if (EIGEN3_ROOT)
# if we are given the path to a "build" tree (meaning somewhere Eigen3
# has been configured), then use the eigen3.pc file to figure out the
# name of the *real* root directory
if (EXISTS "${EIGEN3_ROOT}/CMakeCache.txt")
# get the cache entry that tells use the source tree location
set (_regex "Eigen_SOURCE_DIR:STATIC=\(.*\)")
file (STRINGS
"${EIGEN3_ROOT}/CMakeCache.txt"
EIGEN3_SOURCE_TREE
REGEX "${_regex}"
)
# trim away the key definition, be left with the value
if (EIGEN3_SOURCE_TREE)
string (REGEX REPLACE
"${_regex}"
"\\1"
EIGEN3_SOURCE_TREE
"${EIGEN3_SOURCE_TREE}"
)
# if something doesn't look as expected, abort and search in _ROOT
else ()
set (EIGEN3_SOURCE_TREE "${EIGEN3_ROOT}")
endif ()
else ()
set (EIGEN3_SOURCE_TREE "${EIGEN3_ROOT}")
endif ()
find_path (EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
PATHS ${EIGEN3_SOURCE_TREE}
PATH_SUFFIXES eigen3 include/eigen3 eigen include/eigen
NO_DEFAULT_PATH
)
else (EIGEN3_ROOT)
# assume that if there is a sibling directory to our project which
# is called eigen3, there is a newer version located there, or that
# it may have been checked out next to the build directory
find_path(EIGEN3_INCLUDE_DIR
NAMES signature_of_eigen3_matrix_library
HINTS ${CMAKE_SOURCE_DIR}/../
${PROJECT_SOURCE_DIR}/../
${CMAKE_INSTALL_PREFIX}/include
${KDE4_INCLUDE_DIR}
PATH_SUFFIXES eigen3 eigen
)
endif (EIGEN3_ROOT)
endif (NOT EIGEN3_INCLUDE_DIR)
if(EIGEN3_INCLUDE_DIR)
_eigen3_check_version()
endif(EIGEN3_INCLUDE_DIR)
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Eigen3 DEFAULT_MSG EIGEN3_INCLUDE_DIR EIGEN3_VERSION_OK)
mark_as_advanced(EIGEN3_INCLUDE_DIR)

View File

@ -0,0 +1,49 @@
# -*-cmake-*-
#
# Try to find the libMETIS graph partioning library
#
# Once done, this will define:
#
# METIS_FOUND - system has the libMETIS graph partioning library
# HAVE_METIS - like METIS_FOUND, but for the inclusion in config.h
# METIS_INCLUDE_DIR - incude paths to use libMETIS
# METIS_LIBRARIES - Link these to use libMETIS
set(METIS_SEARCH_PATH "/usr" "/usr/local" "/opt" "/opt/local")
set(METIS_NO_DEFAULT_PATH "")
if(METIS_ROOT)
set(METIS_SEARCH_PATH "${METIS_ROOT}")
set(METIS_NO_DEFAULT_PATH "NO_DEFAULT_PATH")
endif()
# search for files which implements this module
find_path (METIS_INCLUDE_DIRS
NAMES "metis.h"
PATHS ${METIS_SEARCH_PATH}
PATH_SUFFIXES "include" "METISLib" "include/metis"
${METIS_NO_DEFAULT_PATH})
# only search in architecture-relevant directory
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
find_library(METIS_LIBRARIES
NAMES "metis"
PATHS ${METIS_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${METIS_NO_DEFAULT_PATH})
set (METIS_FOUND FALSE)
if (METIS_INCLUDE_DIRS OR METIS_LIBRARIES)
set(METIS_FOUND TRUE)
set(HAVE_METIS TRUE)
endif()
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(METIS
DEFAULT_MSG
METIS_LIBRARIES
METIS_INCLUDE_DIRS
)

View File

@ -0,0 +1,148 @@
# - Try to find Petsc lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Petsc)
#
# Once done this will define
#
# PETSC_FOUND - system has Petsc lib with correct version
# PETSC_INCLUDE_DIRS - the Petsc include directory
# PETSC_LIBRARIES - the Petsc library.
# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.
# find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
# if PETSC_ROOT is set, then this is the only place searched for petsc headers
# and includes
set(_no_default_path "")
if(PETSC_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
endif()
# look for a system-wide BLAS library
set(PETSC_BLAS_LIBRARY "")
find_package(BLAS QUIET)
list(APPEND PETSC_BLAS_LIBRARY "${BLAS_LIBRARIES}")
# if BLAS wasn't found, look for it in PETSC_ROOT. Won't search if
# PETSC_BLAS_LIBRARY is set.
find_library(PETSC_BLAS_LIBRARY
NAME "blas"
PATH ${PETSC_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
# print message if there was still no blas found!
if(NOT BLAS_FOUND AND NOT PETSC_BLAS_LIBRARY)
message(STATUS "BLAS not found but required for PETSc")
return()
endif()
set(PETSC_LAPACK_LIBRARY "")
find_package(LAPACK QUIET)
list(APPEND PETSC_LAPACK_LIBRARY "${LAPACK_LIBRARIES}")
# if LAPACK wasn't found, look for it in PETSC_ROOT
find_library(PETSC_LAPACK_LIBRARY
NAME "lapack"
PATH ${PETSC_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
# print message if there was still no blas found!
if(NOT LAPACK_FOUND AND NOT PETSC_LAPACK_LIBRARY)
message(STATUS "LAPACK not found but required for PETSc")
return()
endif()
find_package(X11 QUIET)
if (X11_FOUND)
list(APPEND PETSC_X11_LIBRARY "${X11_LIBRARIES}")
endif()
# these variables must exist. Since not finding MPI, both the header and the
# object file , may not be an error, we want the option of concatenating the
# empty variable onto the PETSC_LIBRARIES/INCLUDE_DIRS lists
set(PETSC_MPI_LIBRARY "")
set(PETSC_MPI_INCLUDE_DIRS "")
find_package(MPI)
if(MPI_FOUND)
list(APPEND PETSC_MPI_LIBRARY "${MPI_LIBRARIES}")
set(PETSC_MPI_INCLUDE_DIRS ${MPI_INCLUDE_PATH})
else(MPI_FOUND)
# if a system MPI wasn't found, look for PETSc's serial implementation. This
# won't be available if PETSc was compiled with --with-mpi=0, so not finding
# this won't be an error. This only needs to find the header, as the MPI
# implementation should be already be compiled into PETSc.
message(STATUS "Could not find a system provided MPI. Searching for PETSc provided mpiuni fallback implementation.")
find_path(PETSC_MPI_INCLUDE_DIRS
NAMES "mpi.h"
PATHS ${PETSC_ROOT}/include
PATH_SUFFIXES "mpiuni"
${_no_default_path}
)
endif(MPI_FOUND)
if(NOT PETSC_MPI_INCLUDE_DIRS)
message(WARNING "Could not find any MPI implementation. If PETSc is compiled with --with-mpi=0 this is ok. Otherwise you will get linker errors or (possibly subtle) runtime errors. Continuing.")
if(NOT USE_MPI)
message("To build with MPI support, pass -DUSE_MPI=ON to CMake.")
endif(NOT USE_MPI)
endif(NOT PETSC_MPI_INCLUDE_DIRS)
# only probe if we haven't a path in our cache
if (Petsc_ROOT)
set (PETSC_ROOT "${Petsc_ROOT}")
endif (Petsc_ROOT)
find_path (PETSC_NORMAL_INCLUDE_DIR
NAMES "petsc.h"
PATHS ${PETSC_ROOT}
PATH_SUFFIXES "include" "petsc"
${_no_default_path}
)
list(APPEND PETSC_INCLUDE_DIR ${PETSC_NORMAL_INCLUDE_DIR})
# look for actual Petsc library
find_library(PETSC_LIBRARY
NAMES "petsc-3.4.3" "petsc-3.4.4" "petsc"
PATHS ${PETSC_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
if(NOT PETSC_LIBRARY)
message(STATUS "Could not find the PETSc library")
return()
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Petsc DEFAULT_MSG PETSC_INCLUDE_DIR PETSC_LIBRARY)
mark_as_advanced(PETSC_INCLUDE_DIR PETSC_LIBRARY)
# if both headers and library are found, store results
if(PETSC_FOUND)
set(PETSC_INCLUDE_DIRS ${PETSC_INCLUDE_DIR})
list(APPEND PETSC_INCLUDE_DIRS ${PETSC_MPI_INCLUDE_DIRS})
set(PETSC_LIBRARIES ${PETSC_LIBRARY})
list(APPEND PETSC_LIBRARIES ${PETSC_BLAS_LIBRARY})
list(APPEND PETSC_LIBRARIES ${PETSC_LAPACK_LIBRARY})
list(APPEND PETSC_LIBRARIES ${PETSC_X11_LIBRARY})
list(APPEND PETSC_LIBRARIES ${PETSC_MPI_LIBRARY})
endif()

View File

@ -0,0 +1,39 @@
# Module that checks whether the compiler supports the
# quadruple precision floating point math
#
# Sets the following variables:
# HAVE_QUAD
# QUADMATH_LIBRARIES
#
# perform tests
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif()
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_CXX_SOURCE_COMPILES("
#include <quadmath.h>
int main(void){
__float128 foo = sqrtq(123.456);
foo = FLT128_MIN;
}" HAVE_QUAD)
cmake_pop_check_state()
if (HAVE_QUAD)
set(QUADMATH_LIBRARIES "quadmath")
endif()
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(QuadMath
DEFAULT_MSG
QUADMATH_LIBRARIES
HAVE_QUAD
)

View File

@ -0,0 +1,294 @@
# - Find Tim Davis' SuiteSparse collection of sparse matrix libraries
#
# Synopsis:
# find_package (SuiteSparse COMPONENTS <list-of-components>)
#
# Components are:
# amd Approximate Minimum Degree ordering
# camd Constrained Approximate Minimum Degree ordering
# colamd COLumn Approximate Minimum Degree ordering
# ccolamd Constrained COLumn Approximate Minimum Degree ordering
# cholmod Supernodal sparse Cholesky factorization and update
# umfpack Unsymmetric MultiFrontal sparse LU factorization
#
# The following variables will be set:
#
# SuiteSparse_FOUND True if all dependencies are satisfied
# SuiteSparse_Xxx_FOUND True if module Xxx is found
# HAVE_SUITESPARSE_Xxx_H Binary value indicating presence of header
# SuiteSparse_INCLUDE_DIRS Paths containing the SuiteSparse header files
# SuiteSparse_LIBRARIES Name of the libraries which must be linked
# SuiteSparse_DEFINITIONS Defines that must be passed to the compiler
# SuiteSparse_LINKER_FLAGS Options that must be passed when linking
#
# The following options can be set to configure the module:
#
# SUITESPARSE_USE_STATIC Link with a static library, even if a
# dynamic library is also present. Note that
# setting this to OFF does not ensure that a
# shared library will be used.
#
# See <http://www.cise.ufl.edu/research/sparse/SuiteSparse>.
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
function (try_compile_umfpack varname)
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${UMFPACK_INCLUDE_DIRS})
set (CMAKE_REQUIRED_LIBRARIES ${UMFPACK_LIBRARY} ${ARGN} ${SuiteSparse_EXTRA_LIBS})
check_c_source_compiles (
"#include <umfpack.h>
int main (void) {
void *Symbolic, *Numeric;
double Info[UMFPACK_INFO], Control[UMFPACK_CONTROL];
umfpack_dl_defaults(Control);
umfpack_dl_symbolic(0, 0, 0, 0, 0,
&Symbolic, Control, Info);
umfpack_dl_numeric (0, 0, 0,
Symbolic, &Numeric, Control, Info);
umfpack_dl_free_symbolic(&Symbolic);
umfpack_dl_solve(UMFPACK_A, 0, 0, 0, 0, 0,
Numeric, Control, Info);
umfpack_dl_free_numeric(&Numeric);
umfpack_timer ();
return 0;
}" ${varname})
cmake_pop_check_state ()
set (${varname} "${${varname}}" PARENT_SCOPE)
endfunction (try_compile_umfpack varname)
# variables to pass on to other packages
if (FIND_QUIETLY)
set (SuiteSparse_QUIET "QUIET")
else (FIND_QUIETLY)
set (SuiteSparse_QUIET "")
endif (FIND_QUIETLY)
# we need to link to BLAS and LAPACK
if (NOT BLAS_FOUND)
find_package (BLAS ${SuiteSparse_QUIET} REQUIRED)
endif (NOT BLAS_FOUND)
if (NOT LAPACK_FOUND)
find_package (LAPACK ${SuiteSparse_QUIET} REQUIRED)
endif (NOT LAPACK_FOUND)
# we also need the math part of the runtime library
find_library (MATH_LIBRARY NAMES "m")
set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MATH_LIBRARY})
# if we don't get any further clues about where to look, then start
# roaming around the system
set (_no_default_path "")
# search system directories by default
set (SuiteSparse_SEARCH_PATH)
# pick up paths from the environment if specified there; these replace the
# pre-defined paths so that we don't accidentially pick up old stuff
if (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}")
endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
if (SuiteSparse_DIR)
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}")
endif (SuiteSparse_DIR)
# CMake uses _DIR suffix as default for config-mode files; it is unlikely
# that we are building SuiteSparse ourselves; use _ROOT suffix to specify
# location to pre-canned binaries
if (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_ROOT}")
endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
if (SuiteSparse_ROOT)
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}")
endif (SuiteSparse_ROOT)
# most commonly, we use the uppercase version of this variable
if (SUITESPARSE_ROOT)
set (SuiteSparse_SEARCH_PATH "${SUITESPARSE_ROOT}")
endif (SUITESPARSE_ROOT)
# if we have specified a search path, then confine ourselves to that
if (SuiteSparse_SEARCH_PATH)
set (_no_default_path "NO_DEFAULT_PATH")
endif (SuiteSparse_SEARCH_PATH)
# transitive closure of dependencies; after this SuiteSparse_MODULES is the
# full list of modules that must be found to satisfy the user's link demands
set (SuiteSparse_MODULES ${SuiteSparse_FIND_COMPONENTS})
list (FIND SuiteSparse_MODULES "umfpack" UMFPACK_DESIRED)
if (NOT UMFPACK_DESIRED EQUAL -1)
list (APPEND SuiteSparse_MODULES amd cholmod)
endif (NOT UMFPACK_DESIRED EQUAL -1)
list (FIND SuiteSparse_MODULES "cholmod" CHOLMOD_DESIRED)
if (NOT CHOLMOD_DESIRED EQUAL -1)
list (APPEND SuiteSparse_MODULES amd camd colamd)
endif (NOT CHOLMOD_DESIRED EQUAL -1)
if (SuiteSparse_MODULES)
list (REMOVE_DUPLICATES SuiteSparse_MODULES)
endif (SuiteSparse_MODULES)
# if someone else already have found all the packages for us, then don't do anything
set (SuiteSparse_EVERYTHING_FOUND TRUE)
foreach (module IN LISTS SuiteSparse_MODULES)
string (TOUPPER ${module} MODULE)
if (NOT SuiteSparse_${MODULE}_FOUND)
set (SuiteSparse_EVERYTHING_FOUND FALSE)
break ()
endif (NOT SuiteSparse_${MODULE}_FOUND)
endforeach (module)
if (SuiteSparse_EVERYTHING_FOUND)
return ()
endif (SuiteSparse_EVERYTHING_FOUND)
# only search in architecture-relevant directory
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
# if we are told to link SuiteSparse statically, add these parts
# to the name so we always match only that particular type of lib
option (SUITESPARSE_USE_STATIC "Link SuiteSparse statically" OFF)
mark_as_advanced (SUITESPARSE_USE_STATIC)
if (SUITESPARSE_USE_STATIC)
set (_pref_ "${CMAKE_STATIC_LIBRARY_PREFIX}")
set (_suff_ "${CMAKE_STATIC_LIBRARY_SUFFIX}")
else (SUITESPARSE_USE_STATIC)
set (_pref_ "")
set (_suff_ "")
endif (SUITESPARSE_USE_STATIC)
# if SuiteSparse >= 4.0 we must also link with libsuitesparseconfig
# assume that this is the case if we find the library; otherwise just
# ignore it (older versions don't have a file named like this)
find_library (config_LIBRARY
NAMES "${_pref_}suitesparseconfig${_suff_}"
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES ".libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
${_no_default_path}
)
if (config_LIBRARY)
list (APPEND SuiteSparse_EXTRA_LIBS ${config_LIBRARY})
# POSIX.1-2001 REALTIME portion require us to link this library too for
# clock_gettime() which is used by suitesparseconfig
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
list (APPEND SuiteSparse_EXTRA_LIBS "-lrt")
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
endif (config_LIBRARY)
# search filesystem for each of the module individually
foreach (module IN LISTS SuiteSparse_MODULES)
string (TOUPPER ${module} MODULE)
# search for files which implements this module
find_path (${MODULE}_INCLUDE_DIR
NAMES ${module}.h
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES "include" "include/suitesparse" "include/ufsparse" "${MODULE}/Include"
${_no_default_path}
)
find_library (${MODULE}_LIBRARY
NAMES "${_pref_}${module}${_suff_}"
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse" "${MODULE}/Lib"
${_no_default_path}
)
# start out by including the module itself; other dependencies will be added later
set (${MODULE}_INCLUDE_DIRS ${${MODULE}_INCLUDE_DIR})
set (${MODULE}_LIBRARIES ${${MODULE}_LIBRARY})
endforeach (module)
# insert any inter-modular dependencies here
if (CHOLMOD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${AMD_LIBRARIES} ${COLAMD_LIBRARIES})
# optional libraries; don't insert any -NOT_FOUND paths
if (CAMD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${CAMD_LIBRARIES})
endif (CAMD_LIBRARY)
if (CCOLAMD_LIBRARY)
list (APPEND CHOLMOD_LIBRARIES ${CCOLAMD_LIBRARIES})
endif (CCOLAMD_LIBRARY)
list (REVERSE CHOLMOD_LIBRARIES)
# always remove the *first* library from the list
list (REMOVE_DUPLICATES CHOLMOD_LIBRARIES)
list (REVERSE CHOLMOD_LIBRARIES)
endif (CHOLMOD_LIBRARY)
if (UMFPACK_LIBRARY)
set (UMFPACK_EXTRA_LIBS)
# test if umfpack is usable with only amd and not cholmod
try_compile_umfpack (HAVE_UMFPACK_WITHOUT_CHOLMOD ${AMD_LIBRARIES})
if (HAVE_UMFPACK_WITHOUT_CHOLMOD)
list (APPEND UMFPACK_EXTRA_LIBS ${AMD_LIBRARIES})
else (HAVE_UMFPACK_WITHOUT_CHOLMOD)
if (CHOLMOD_LIBRARIES)
try_compile_umfpack (HAVE_UMFPACK_WITH_CHOLMOD ${CHOLMOD_LIBRARIES})
if (HAVE_UMFPACK_WITH_CHOLMOD)
list (APPEND UMFPACK_EXTRA_LIBS ${CHOLMOD_LIBRARIES})
else (HAVE_UMFPACK_WITH_CHOLMOD)
set (UMFPACK_EXTRA_LIBS "-NOTFOUND")
endif (HAVE_UMFPACK_WITH_CHOLMOD)
else (CHOLMOD_LIBRARIES)
# if we don't have cholmod, then we certainly cannot have umfpack with cholmod
set (UMFPACK_EXTRA_LIBS "-NOTFOUND")
endif (CHOLMOD_LIBRARIES)
endif (HAVE_UMFPACK_WITHOUT_CHOLMOD)
list (APPEND UMFPACK_LIBRARIES ${UMFPACK_EXTRA_LIBS})
list (REVERSE UMFPACK_LIBRARIES)
list (REMOVE_DUPLICATES UMFPACK_LIBRARIES)
list (REVERSE UMFPACK_LIBRARIES)
endif (UMFPACK_LIBRARY)
# don't reset these sets; if two packages request SuiteSparse with
# different modules, we want the sets to be merged
#set (SuiteSparse_LIBRARIES "")
#set (SuiteSparse_INCLUDE_DIRS "")
# determine which modules were found based on whether all dependencies
# were satisfied; create a list of ALL modules (specified) that was found
# (to be included in one swoop in CMakeLists.txt)
set (SuiteSparse_FOUND TRUE)
foreach (module IN LISTS SuiteSparse_FIND_COMPONENTS)
string (TOUPPER ${module} MODULE)
set (SuiteSparse_${MODULE}_FOUND TRUE)
foreach (file IN LISTS ${MODULE}_INCLUDE_DIRS ${MODULE}_LIBRARIES)
if (NOT EXISTS ${file})
set (SuiteSparse_${MODULE}_FOUND FALSE)
endif (NOT EXISTS ${file})
endforeach (file)
if (NOT SuiteSparse_${MODULE}_FOUND)
set (SuiteSparse_FOUND FALSE)
# use empty string instead of zero, so it can be tested with #ifdef
# as well as #if in the source code
set (HAVE_SUITESPARSE_${MODULE}_H "" CACHE INT "Is ${module} header present?")
else (NOT SuiteSparse_${MODULE}_FOUND)
set (HAVE_SUITESPARSE_${MODULE}_H 1 CACHE INT "Is ${module} header present?")
list (APPEND SuiteSparse_LIBRARIES "${${MODULE}_LIBRARIES}")
list (APPEND SuiteSparse_LINKER_FLAGS "${${MODULE}_LINKER_FLAGS}")
list (APPEND SuiteSparse_INCLUDE_DIRS "${${MODULE}_INCLUDE_DIRS}")
endif (NOT SuiteSparse_${MODULE}_FOUND)
mark_as_advanced (HAVE_SUITESPARSE_${MODULE}_H)
mark_as_advanced (${MODULE}_INCLUDE_DIR)
mark_as_advanced (${MODULE}_LIBRARY)
endforeach (module)
if (SuiteSparse_INCLUDE_DIRS)
list (REMOVE_DUPLICATES SuiteSparse_INCLUDE_DIRS)
endif (SuiteSparse_INCLUDE_DIRS)
if (SuiteSparse_LIBRARIES)
list (REVERSE SuiteSparse_LIBRARIES)
list (REMOVE_DUPLICATES SuiteSparse_LIBRARIES)
list (REVERSE SuiteSparse_LIBRARIES)
endif (SuiteSparse_LIBRARIES)
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (SuiteSparse
DEFAULT_MSG
SuiteSparse_LIBRARIES
SuiteSparse_INCLUDE_DIRS
)
# add these after checking to not pollute the message output (checking for
# BLAS and LAPACK is REQUIRED so if they are not found, we'll have failed
# already; suitesparseconfig is "optional" anyway)
list (APPEND SuiteSparse_LIBRARIES ${SuiteSparse_EXTRA_LIBS})

View File

@ -0,0 +1,149 @@
#
# Module that checks whether SuperLU is available and usable.
# SuperLU must be a version released after the year 2005.
#
# Variables used by this module which you may want to set:
# SUPERLU_ROOT Path list to search for SuperLU
#
# Sets the follwing variable:
#
# SUPERLU_FOUND True if SuperLU available and usable.
# SUPERLU_MIN_VERSION_4_3 True if SuperLU version >= 4.3.
# SUPERLU_POST_2005_VERSION True if SuperLU is from post-2005
# SUPERLU_WITH_VERSION Human readable string containing version information.
# SUPERLU_INCLUDE_DIRS Path to the SuperLU include dirs.
# SUPERLU_LIBRARIES Name to the SuperLU library.
#
include(CheckIncludeFiles)
include(CMakePushCheckState)
include(CheckCSourceCompiles)
cmake_push_check_state()
# find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
# look for files only at the positions given by the user if
# an explicit path is specified
if(SUPERLU_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
else()
set (_no_default_path "")
endif()
# look for a system-wide BLAS library
find_package(BLAS QUIET)
# look for the internal SuperLU blas library (but only if no
# system-wide library was found and a path to the superLU library was
# specified)
set(SUPERLU_BLAS_LIBRARY "")
if (BLAS_FOUND)
list(APPEND SUPERLU_BLAS_LIBRARY "${BLAS_LIBRARIES}")
elseif(SUPERLU_ROOT)
find_library(SUPERLU_BLAS_LIBRARY
NAMES "blas"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
NO_DEFAULT_PATH)
endif()
# print message if there was still no blas found!
if(NOT BLAS_FOUND AND NOT SUPERLU_BLAS_LIBRARY)
message(STATUS "BLAS not found but required for SuperLU")
return()
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${SUPERLU_BLAS_LIBRARY}")
# find the directory containing the SuperLU include files
if (NOT SUPERLU_INCLUDE_DIR)
find_path(SUPERLU_INCLUDE_DIR
NAMES "supermatrix.h"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
${_no_default_path}
)
endif()
if(NOT SUPERLU_INCLUDE_DIR)
message(STATUS "Directory with the SuperLU include files not found")
return()
endif()
list(APPEND CMAKE_REQUIRED_INCLUDES "${SUPERLU_INCLUDE_DIR}")
# look for actual SuperLU library
if (NOT SUPERLU_LIBRARY)
find_library(SUPERLU_LIBRARY
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
PATHS ${SUPERLU_ROOT}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${_no_default_path}
)
endif()
if(NOT SUPERLU_LIBRARY)
message(STATUS "Directory with the SuperLU library not found")
return()
endif()
list(APPEND CMAKE_REQUIRED_LIBRARIES "${SUPERLU_LIBRARY}")
# check whether "mem_usage_t.expansions" was found in "slu_ddefs.h"
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
mem_usage_t mem;
return mem.expansions;
}"
HAVE_MEM_USAGE_T_EXPANSIONS)
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
return SLU_DOUBLE;
}"
SUPERLU_MIN_VERSION_4_3)
# check whether version is at least post-2005
CHECK_C_SOURCE_COMPILES("
#include <slu_ddefs.h>
int main(void)
{
GlobalLU_t g;
return 0;
}"
SUPERLU_POST_2005_VERSION)
cmake_pop_check_state()
if(SUPERLU_MIN_VERSION_4_3)
set(SUPERLU_WITH_VERSION "SuperLU >= 4.3" CACHE STRING
"Human readable string containing SuperLU version information.")
else()
set(SUPERLU_WITH_VERSION "SuperLU <= 4.2, post 2005" CACHE STRING
"Human readable string containing SuperLU version information.")
endif()
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SuperLU"
DEFAULT_MSG
SUPERLU_INCLUDE_DIR
SUPERLU_LIBRARY)
mark_as_advanced(SUPERLU_INCLUDE_DIR SUPERLU_LIBRARY)
# if both headers and library are found, store results
if(SUPERLU_FOUND)
set(SUPERLU_INCLUDE_DIRS ${SUPERLU_INCLUDE_DIR})
set(SUPERLU_LIBRARIES ${SUPERLU_LIBRARY})
if (SUPERLU_BLAS_LIBRARY)
list(APPEND SUPERLU_LIBRARIES ${SUPERLU_BLAS_LIBRARY})
endif()
endif()
cmake_pop_check_state()

View File

@ -0,0 +1,37 @@
# - Find TinyXML library
#
# Defines the following variables:
# TinyXML_INCLUDE_DIRS Directory of header files
# TinyXML_LIBRARIES Directory of shared object files
# TinyXML_DEFINITIONS Defines that must be set to compile
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (OpmPackage)
find_opm_package (
# module name
"TinyXML"
# dependencies
""
# header to search for
"tinyxml.h"
# library to search for
"tinyxml"
# defines to be added to compilations
""
# test program
"#include <tinyxml.h>
int main (void) {
TiXmlDocument doc;
return 0;
}
"
# config variables
"")

112
cmake/Modules/FindUG.cmake Normal file
View File

@ -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()

View File

@ -0,0 +1,25 @@
# Find Valgrind.
#
# This module defines:
# VALGRIND_INCLUDE_DIR, where to find valgrind/memcheck.h, etc.
# VALGRIND_PROGRAM, the valgrind executable.
# VALGRIND_FOUND, If false, do not try to use valgrind.
#
# If you have valgrind installed in a non-standard place, you can define
# VALGRIND_ROOT to tell cmake where it is.
if (VALGRIND_FOUND)
return()
endif()
find_path(VALGRIND_INCLUDE_DIR valgrind/memcheck.h
/usr/include /usr/local/include ${VALGRIND_ROOT}/include)
# if VALGRIND_ROOT is empty, we explicitly add /bin to the search
# path, but this does not hurt...
find_program(VALGRIND_PROGRAM NAMES valgrind PATH ${VALGRIND_ROOT}/bin)
find_package_handle_standard_args(VALGRIND DEFAULT_MSG
VALGRIND_INCLUDE_DIR
VALGRIND_PROGRAM)
mark_as_advanced(VALGRIND_ROOT VALGRIND_INCLUDE_DIR VALGRIND_PROGRAM)

View File

@ -0,0 +1,51 @@
# -*-cmake-*-
#
# Try to find the libzoltan graph partioning library
#
# Once done, this will define:
#
# ZOLTAN_FOUND - system has the libzoltan graph partioning library
# HAVE_ZOLTAN - like ZOLTAN_FOUND, but for the inclusion in config.h
# ZOLTAN_INCLUDE_DIR - incude paths to use libzoltan
# ZOLTAN_LIBRARIES - Link these to use libzoltan
set(ZOLTAN_SEARCH_PATH "/usr" "/usr/local" "/opt" "/opt/local")
set(ZOLTAN_NO_DEFAULT_PATH "")
if(ZOLTAN_ROOT)
set(ZOLTAN_SEARCH_PATH "${ZOLTAN_ROOT}")
set(ZOLTAN_NO_DEFAULT_PATH "NO_DEFAULT_PATH")
endif()
# search for files which implements this module
find_path (ZOLTAN_INCLUDE_DIRS
NAMES "zoltan.h"
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "include"
${ZOLTAN_NO_DEFAULT_PATH})
# only search in architecture-relevant directory
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
find_library(ZOLTAN_LIBRARIES
NAMES "zoltan"
PATHS ${ZOLTAN_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
${ZOLTAN_NO_DEFAULT_PATH})
set (ZOLTAN_FOUND FALSE)
if (ZOLTAN_INCLUDE_DIRS OR ZOLTAN_LIBRARIES)
set(ZOLTAN_FOUND TRUE)
set(HAVE_ZOLTAN 1)
endif()
set (ZOLTAN_CONFIG_VAR HAVE_ZOLTAN)
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(ZOLTAN
DEFAULT_MSG
ZOLTAN_LIBRARIES
ZOLTAN_INCLUDE_DIRS
)

View File

@ -0,0 +1,90 @@
# Look for the cjson library; will probably newer be found.
# If found, it sets these variables:
#
# CJSON_INCLUDE_DIRS Header file directories
# CJSON_LIBRARIES Archive/shared objects
include (FindPackageHandleStandardArgs)
if ((NOT CJSON_ROOT) AND OPM_PARSER_ROOT)
set( CJSON_ROOT ${OPM_PARSER_ROOT})
endif()
if (CJSON_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
else (CJSON_ROOT)
set (_no_default_path "")
endif (CJSON_ROOT)
find_path (CJSON_INCLUDE_DIR
NAMES "cjson/cJSON.h"
HINTS "${CJSON_ROOT}"
PATHS "${PROJECT_SOURCE_DIR}" "${PROJECT_SOURCE_DIR}/../opm-parser"
PATH_SUFFIXES "include" "opm/json"
DOC "Path to cjson library header files"
${_no_default_path} )
# find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}")
find_library (CJSON_LIBRARY
NAMES "cjson"
HINTS "${CJSON_ROOT}"
PATHS "${PROJECT_BINARY_DIR}/../opm-parser"
"${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}"
"${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}"
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"opm/json"
DOC "Path to cjson library archive/shared object files"
${_no_default_path} )
# setup list of all required libraries to link with cjson
set (CJSON_INCLUDE_DIRS ${CJSON_INCLUDE_DIR})
set (CJSON_LIBRARIES ${CJSON_LIBRARY})
# math library (should exist on all unices; automatically linked on Windows)
if (UNIX)
find_library (MATH_LIBRARY NAMES "m")
list (APPEND CJSON_LIBRARIES ${MATH_LIBRARY})
endif (UNIX)
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
if (NOT (CJSON_INCLUDE_DIRS MATCHES "-NOTFOUND" OR CJSON_LIBRARIES MATCHES "-NOTFOUND"))
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${CJSON_INCLUDE_DIRS})
set (CMAKE_REQUIRED_LIBRARIES ${CJSON_LIBRARIES})
check_c_source_compiles (
"#include <stdlib.h>
#include <cjson/cJSON.h>
int main (void) {
cJSON root;
return 0;
}" HAVE_CJSON)
cmake_pop_check_state ()
else ()
# clear the cache so the find probe is attempted again if files becomes
# available (only upon a unsuccessful *compile* should we disable further
# probing)
set (HAVE_CJSON)
unset (HAVE_CJSON CACHE)
endif ()
# if the test program didn't compile, but was required to do so, bail
# out now and display an error; otherwise limp on
set (CJSON_FIND_REQUIRED ${cjson_FIND_REQUIRED})
set (CJSON_FIND_QUIETLY ${cjson_FIND_QUIETLY})
find_package_handle_standard_args (CJSON
DEFAULT_MSG
CJSON_INCLUDE_DIRS CJSON_LIBRARIES HAVE_CJSON
)
set (cjson_FOUND ${CJSON_FOUND})

View File

@ -0,0 +1,51 @@
# - Find DUNE ALUgrid library
#
# Defines the following variables:
# dune-alugrid_INCLUDE_DIRS Directory of header files
# dune-alugrid_LIBRARIES Directory of shared object files
# dune-alugrid_DEFINITIONS Defines that must be set to compile
# dune-alugrid_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_ALUGRID 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-alugrid"
# 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-grid REQUIRED;
ZLIB REQUIRED;
ZOLTAN;
METIS
"
# header to search for
"dune/alugrid/grid.hh"
# library to search for
"dunealugrid;alugrid_2d;alugrid_parallel;alugrid_serial"
# defines to be added to compilations
""
# test program
"#include <dune/alugrid/2d/indexsets.hh>
int main (void) {
return 0;
}
"
# config variables
"HAVE_DUNE_ALUGRID
")
#debug_find_vars ("dune-grid")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "alugrid")

View File

@ -0,0 +1,71 @@
# - Find DUNE common library
#
# Defines the following variables:
# dune-common_INCLUDE_DIRS Directory of header files
# dune-common_LIBRARIES Directory of shared object files
# dune-common_DEFINITIONS Defines that must be set to compile
# dune-common_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_COMMON Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-common"
# dependencies
"CXX11Features REQUIRED;
BLAS REQUIRED;
LAPACK REQUIRED;
CxaDemangle;
MPI
"
# header to search for
"dune/common/fvector.hh"
# library to search for
"dunecommon"
# defines to be added to compilations
"DUNE_COMMON_FIELDVECTOR_SIZE_IS_METHOD=1"
# test program
"#include <dune/common/fvector.hh>
#include <dune/common/fmatrix.hh>
int main (void) {
Dune::FieldVector<double,1> v;
Dune::FieldMatrix<double,1,1> m;
m[0][0] = 1.0;
v[0] = 1.0;
Dune::FieldVector<double,1> w = m*v;
return 0;
}
"
# config variables
"HAS_ATTRIBUTE_UNUSED;
HAS_ATTRIBUTE_DEPRECATED;
HAS_ATTRIBUTE_DEPRECATED_MSG;
HAVE_ARRAY;
HAVE_BOOST_MAKE_SHARED_HPP;
HAVE_BOOST_SHARED_PTR_HPP;
HAVE_DUNE_BOOST;
HAVE_GMP;
HAVE_MAKE_SHARED;
HAVE_MPI;
HAVE_NULLPTR;
HAVE_STATIC_ASSERT;
HAVE_SHARED_PTR;
SHARED_PTR_HEADER;
SHARED_PTR_NAMESPACE;
HAVE_TYPE_TRAITS;
HAVE_TR1_TUPLE;
HAVE_TUPLE;
HAVE_CXA_DEMANGLE
")
#debug_find_vars ("dune-common")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "common")

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 (dune-cornerpoint-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"${dune-cornerpoint_DEPS}"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
"HAVE_DUNE_CORNERPOINT"
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"${dune-cornerpoint_CONFIG_VAR}"
)
#debug_find_vars ("dune-cornerpoint")

View File

@ -0,0 +1,51 @@
# - 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")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "geometry")

View File

@ -0,0 +1,66 @@
# - 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)
set(DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS 1)
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;
MPI;
ALUGrid;
UG
"
# 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>
int main (void) {
Dune::OneDGrid grid(1, 0., 1.);
return grid.lbegin<0>(0) == grid.lend<0>(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;
DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
")
#debug_find_vars ("dune-grid")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "grid")

View File

@ -0,0 +1,60 @@
# - Find DUNE ISTL library
#
# Defines the following variables:
# dune-istl_INCLUDE_DIRS Directory of header files
# dune-istl_LIBRARIES Directory of shared object files
# dune-istl_DEFINITIONS Defines that must be set to compile
# dune-istl_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_ISTL Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-istl"
# required dependencies
"dune-common REQUIRED;
SuperLU
"
# header to search for
"dune/istl/bcrsmatrix.hh"
# library to search for
""
# defines to be added to compilations
""
# test program
"#include <dune/common/deprecated.hh>
#include <dune/istl/bcrsmatrix.hh>
#include <dune/common/fmatrix.hh>
int main (void) {
typedef Dune::BCRSMatrix<Dune::FieldMatrix<double,1,1> > Matrix;
Matrix matrix( 3, 3, Matrix::random );
for (int i = 0; i < 3; ++i) matrix.setrowsize(i, 2);
matrix.endrowsizes();
return 0;
}
"
# config variables
"HAVE_BOOST_FUSION;
HAVE_MEM_USAGE_T_EXPANSIONS;
HAVE_PARDISO;
HAVE_BOOST;
HAVE_MPI;
HAVE_PARMETIS;
HAVE_SUPERLU;
HAVE_UMFPACK;
SUPERLU_MIN_VERSION_4_3;
SUPERLU_POST_2005_VERSION
")
#debug_find_vars ("dune-istl")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "istl")

View File

@ -0,0 +1,42 @@
# - Find DUNE localfunctions library
#
# Defines the following variables:
# dune-localfunctions_INCLUDE_DIRS Directory of header files
# dune-localfunctions_LIBRARIES Directory of shared object files
# dune-localfunctions_DEFINITIONS Defines that must be set to compile
# dune-localfunctions_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_LOCALFUNCTIONS Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-localfunctions"
# required dependencies
"dune-common REQUIRED"
# header to search for
"dune/localfunctions/common/localbasis.hh"
# library to search for
""
# defines to be added to compilations
""
# test program
"#include <dune/localfunctions/common/localbasis.hh>
int main (void) {
return 0;
}
"
# config variables
"")
#debug_find_vars ("dune-localfunctions")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "localfunctions")

View File

@ -0,0 +1,42 @@
# - Find OPM eWoms module
#
# Defines the following variables:
# ewoms_INCLUDE_DIRS Directory of header files
# ewoms_LIBRARIES Directory of shared object files
# ewoms_DEFINITIONS Defines that must be set to compile
# ewoms_CONFIG_VARS List of defines that should be in config.h
# HAVE_EWOMS Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (ewoms-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"ewoms"
# dependencies
"${ewoms_DEPS}"
# header to search for
"ewoms/common/start.hh"
# library to search for
""
# defines to be added to compilations
""
# test program
"#include <ewoms/common/start.hh>
int main (void) {
return 0;
}
"
# config variables
"${ewoms_CONFIG_VAR}"
)
#include (UseDynamicBoost)
#debug_find_vars ("ewoms")

View File

@ -0,0 +1,44 @@
# - Find OPM automatic differentiation library
#
# Defines the following variables:
# opm-autodiff_INCLUDE_DIRS Directory of header files
# opm-autodiff_LIBRARIES Directory of shared object files
# opm-autodiff_DEFINITIONS Defines that must be set to compile
# opm-autodiff_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_AUTODIFF Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-autodiff-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-autodiff"
# dependencies
"${opm-autodiff_DEPS}"
# header to search for
"opm/autodiff/AutoDiff.hpp"
# library to search for
"opmautodiff"
# defines to be added to compilations
""
# test program
"#include <opm/autodiff/AutoDiff.hpp>
int main (void) {
Opm::AutoDiff<double> x = Opm::AutoDiff<double>::constant(42.);
(void) x;
return 0;
}
"
# config variables
"${opm-autodiff_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-autodiff")

View File

@ -0,0 +1,45 @@
# - Find OPM core library
#
# Defines the following variables:
# opm-core_INCLUDE_DIRS Directory of header files
# opm-core_LIBRARIES Directory of shared object files
# opm-core_DEFINITIONS Defines that must be set to compile
# opm-core_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_CORE Binary value to use in config.h
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
# use the generic find routine
include (opm-core-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-core"
# dependencies
"${opm-core_DEPS}"
# header to search for
"opm/core/grid.h"
# library to search for
"opmcore"
# defines to be added to compilations
""
# test program
"#include <opm/core/grid.h>
int main (void) {
struct UnstructuredGrid *g;
g = create_grid_empty ();
destroy_grid (g);
return 0;
}
"
# config variables
"${opm-core_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-core")

View File

@ -0,0 +1,43 @@
# - Find OPM materials library
#
# Defines the following variables:
# opm-material_INCLUDE_DIRS Directory of header files
# opm-material_LIBRARIES Directory of shared object files
# opm-material_DEFINITIONS Defines that must be set to compile
# opm-material_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_MATERIAL 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
# use the generic find routine
include (opm-material-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-material"
# dependencies
"${opm-material_DEPS}"
# header to search for
"opm/material/Constants.hpp"
# library to search for
""
# defines to be added to compilations
""
# test program
"#include <opm/material/Constants.hpp>
int main (void) {
double c = Opm::Constants<double>::c;
return 0;
}
"
# config variables
"${opm-material_CONFIG_VAR}"
)
include (UseDynamicBoost)
#debug_find_vars ("opm-material")

View File

@ -0,0 +1,159 @@
# Find the OPM Eclipse input parser.
#
# Set the cache variable OPM_PARSER_ROOT to the install location of the
# library, or OPM_ROOT to the parent directory of the build tree.
#
# If found, it sets these variables:
#
# HAVE_OPM_PARSER Defined if a test program compiled
# OPM_PARSER_INCLUDE_DIRS Header file directories
# OPM_PARSER_LIBRARIES Archives and shared objects
include (FindPackageHandleStandardArgs)
# variables to pass on to other packages
if (FIND_QUIETLY)
set (OPM_PARSER_QUIET "QUIET")
else ()
set (OPM_PARSER_QUIET "")
endif ()
# use lowercase versions of the variables if those are set
if (opm-parser_ROOT)
set (OPM_PARSER_ROOT ${opm-parser_ROOT})
endif ()
if (opm_ROOT)
set (OPM_ROOT ${opm_ROOT})
endif ()
# inherit "suite" root if not specifically set for this library
if ((NOT OPM_PARSER_ROOT) AND OPM_ROOT)
set (OPM_PARSER_ROOT "${OPM_ROOT}/opm-parser")
endif ()
# Detect the build dir suffix or subdirectory
string(REGEX REPLACE "${PROJECT_SOURCE_DIR}/?(.*)" "\\1" BUILD_DIR_SUFFIX "${PROJECT_BINARY_DIR}")
# if a root is specified, then don't search in system directories
# or in relative directories to this one
if (OPM_PARSER_ROOT)
set (_no_default_path "NO_DEFAULT_PATH")
set (_opm_parser_source "")
set (_opm_parser_build "")
else ()
set (_no_default_path "")
set (_opm_parser_source
"${PROJECT_SOURCE_DIR}/../opm-parser")
set (_opm_parser_build
"${PROJECT_BINARY_DIR}/../opm-parser"
"${PROJECT_BINARY_DIR}/../opm-parser${BUILD_DIR_SUFFIX}"
"${PROJECT_BINARY_DIR}/../../opm-parser/${BUILD_DIR_SUFFIX}")
endif ()
# use this header as signature
find_path (OPM_PARSER_INCLUDE_DIR
NAMES "opm/parser/eclipse/Parser/Parser.hpp"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_source}
PATH_SUFFIXES "include"
DOC "Path to OPM parser header files"
${_no_default_path} )
# backup: if we didn't find any headers there, but a CMakeCache.txt,
# then it is probably a build directory; read the CMake cache of
# opm-parser to figure out where the source directory is
if ((NOT OPM_PARSER_INCLUDE_DIR) AND
(OPM_PARSER_ROOT AND (EXISTS "${OPM_PARSER_ROOT}/CMakeCache.txt")))
set (_regex "^OPMParser_SOURCE_DIR:STATIC=\(.*\)$")
file (STRINGS
"${OPM_PARSER_ROOT}/CMakeCache.txt"
_cache_entry
REGEX "${_regex}")
string(REGEX REPLACE "${_regex}" "\\1"
OPM_PARSER_INCLUDE_DIR
"${_cache_entry}")
if (OPM_PARSER_INCLUDE_DIR)
set (OPM_PARSER_INCLUDE_DIR "${OPM_PARSER_INCLUDE_DIR}"
CACHE PATH "Path to OPM parser header files" FORCE)
endif ()
endif ()
# find out the size of a pointer. this is required to only search for
# libraries in the directories relevant for the architecture
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif ()
# these libraries constitute the parser core
find_library (OPM_PARSER_LIBRARY
NAMES "Parser"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_build}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"opm/parser/eclipse"
DOC "Path to OPM parser library archive/shared object files"
${_no_default_path} )
# find the OPM-parser wrapper library around cJSON
find_library (OPM_JSON_LIBRARY
NAMES "opm-json"
HINTS "${OPM_PARSER_ROOT}"
PATHS ${_opm_parser_build}
PATH_SUFFIXES "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
"opm/json"
DOC "Path to OPM JSON library archive/shared object files"
${_no_default_path} )
# get the prerequisite ERT libraries
if (NOT ERT_FOUND)
find_package(ERT ${OPM_PARSER_QUIET})
endif ()
# get the prerequisite Boost libraries
find_package(Boost 1.44.0 COMPONENTS filesystem date_time system unit_test_framework regex ${OPM_PARSER_QUIET})
if (ERT_FOUND AND Boost_FOUND AND
OPM_PARSER_LIBRARY AND OPM_JSON_LIBRARY AND OPM_PARSER_INCLUDE_DIR)
# setup list of all required libraries to link with opm-parser. notice that
# we use the plural form to get *all* the libraries needed by cjson
set (opm-parser_INCLUDE_DIRS
${OPM_PARSER_INCLUDE_DIR}
${Boost_INCLUDE_DIRS}
${ERT_INCLUDE_DIRS})
set (opm-parser_LIBRARIES
${OPM_PARSER_LIBRARY}
${OPM_JSON_LIBRARY}
${Boost_LIBRARIES}
${ERT_LIBRARIES})
# see if we can compile a minimum example
# CMake logical test doesn't handle lists (sic)
include (CMakePushCheckState)
include (CheckCSourceCompiles)
cmake_push_check_state ()
set (CMAKE_REQUIRED_INCLUDES ${opm-parser_INCLUDE_DIRS})
set (CMAKE_REQUIRED_LIBRARIES ${opm-parser_LIBRARIES})
check_cxx_source_compiles (
"#include <cstdlib>
#include <opm/parser/eclipse/Deck/Deck.hpp>
int main (void) {
return EXIT_SUCCESS;
}" HAVE_OPM_PARSER)
cmake_pop_check_state ()
endif()
# if the test program didn't compile, but was required to do so, bail
# out now and display an error; otherwise limp on
set (OPM_PARSER_FIND_REQUIRED ${opm-parser_FIND_REQUIRED})
find_package_handle_standard_args (opm-parser
DEFAULT_MSG
opm-parser_INCLUDE_DIRS opm-parser_LIBRARIES HAVE_OPM_PARSER
)
set (opm-parser_CONFIG_VARS "HAVE_OPM_PARSER;HAVE_REGEX")
set (opm-parser_FOUND ${OPM-PARSER_FOUND})
mark_as_advanced(opm-parser_LIBRARIES opm-parser_INCLUDE_DIRS OPM-PARSER_FOUND)

View File

@ -0,0 +1,42 @@
# - 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 (opm-polymer-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-polymer"
# dependencies
"${opm-polymer_DEPS}"
# 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
"${opm-polymer_CONFIG_VAR}"
)
#debug_find_vars ("opm-polymer")

View File

@ -0,0 +1,41 @@
# - 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 (opm-porsol-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-porsol"
# dependencies
"${opm-porsol_DEPS}"
# 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
"${opm-porsol_CONFIG_VAR}"
)
#debug_find_vars ("opm-porsol")

View File

@ -0,0 +1,41 @@
# - 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 (opm-upscaling-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-upscaling"
# dependencies
"${opm-upscaling_DEPS}"
# 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
"${opm-upscaling_CONFIG_VAR}"
)
#debug_find_vars ("opm-upscaling")

View File

@ -0,0 +1,41 @@
# - Find OPM vertical equilibrium library
#
# Defines the following variables:
# opm-verteq_INCLUDE_DIRS Directory of header files
# opm-verteq_LIBRARIES Directory of shared object files
# opm-verteq_DEFINITIONS Defines that must be set to compile
# opm-verteq_CONFIG_VARS List of defines that should be in config.h
# HAVE_OPM_VERTEQ 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
# use the generic find routine
include (opm-verteq-prereqs)
include (OpmPackage)
find_opm_package (
# module name
"opm-verteq"
# dependencies
"${opm-verteq_DEPS}"
# header to search for
"opm/verteq/verteq.hpp"
# library to search for
"opmverteq"
# defines to be added to compilations
""
# test program
"#include <opm/verteq/verteq.hpp>
int main (void) {
return 0;
}
"
# config variables
"")
include (UseDynamicBoost)
#debug_find_vars ("opm-verteq")

View File

@ -0,0 +1,165 @@
# translate a list of libraries into a command-line that can be passed to the
# compiler/linker. first parameter is the name of the variable that will
# receive this list, the rest is considered the list of libraries
function (linker_cmdline what INTO outvar FROM)
# if we are going to put these in regexps, we must escape period
string (REPLACE "." "\\." esc_dl_pref "${CMAKE_SHARED_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_dl_suff "${CMAKE_SHARED_LIBRARY_SUFFIX}")
string (REPLACE "." "\\." esc_ar_pref "${CMAKE_STATIC_LIBRARY_PREFIX}")
string (REPLACE "." "\\." esc_ar_suff "${CMAKE_STATIC_LIBRARY_PREFIX}")
# CMake loves absolute paths, whereas libtool won't have any of it!
# (you get an error message about argument not parsed). translate each
# of the libraries into a linker option
set (deplib_list "")
foreach (deplib IN LISTS ARGN)
# starts with a hyphen already? then just add it
string (SUBSTRING ${deplib} 0 1 dash)
if (${dash} STREQUAL "-")
list (APPEND deplib_list ${deplib})
else (${dash} STREQUAL "-")
# otherwise, parse the name into a directory and a name
get_filename_component (deplib_dir ${deplib} PATH)
get_filename_component (deplib_orig ${deplib} NAME)
string (REGEX REPLACE
"^${esc_dl_pref}(.*)${esc_dl_suff}$"
"\\1"
deplib_name
${deplib_orig}
)
string (REGEX REPLACE
"^${esc_ar_pref}(.*)${esc_ar_suff}$"
"\\1"
deplib_name
${deplib_name}
)
# directory and name each on their own; this is somewhat
# unsatisfactory because it may be that a system dir is specified
# by an earlier directory and you start picking up libraries from
# there instead of the "closest" path here. also, the soversion
# is more or less lost. remove system default path, to lessen the
# chance that we pick the wrong library
if (NOT ((deplib_dir STREQUAL "/usr/lib") OR
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
list (APPEND deplib_list "-L${deplib_dir}")
endif (NOT ((deplib_dir STREQUAL "/usr/lib") OR
(deplib_dir STREQUAL "/usr/${CMAKE_INSTALL_LIBDIR}")))
# if there was no translation of the name, the library is named
# unconventionally (.so.3gf, I'm looking at you), so pass this
# name unmodified to the linker switch
if (deplib_orig STREQUAL deplib_name)
list (APPEND deplib_list "-l:${deplib_orig}")
else (deplib_orig STREQUAL deplib_name)
list (APPEND deplib_list "-l${deplib_name}")
endif (deplib_orig STREQUAL deplib_name)
endif (${dash} STREQUAL "-")
endforeach (deplib)
# caller determines whether we want it returned as a list or a string
if ("${what}" STREQUAL "LIST")
set (${outvar} ${deplib_list})
else ("${what}" STREQUAL "LIST")
set (${outvar} "${deplib_list}")
string (REPLACE ";" " " ${outvar} "${${outvar}}")
endif ("${what}" STREQUAL "LIST")
set (${outvar} "${${outvar}}" PARENT_SCOPE)
endfunction (linker_cmdline what INTO outvar FROM)
function (configure_la name target)
if (NOT (UNIX OR MSYS OR MINGW))
return ()
endif (NOT (UNIX OR MSYS OR MINGW))
# these generic variables are initialized from the project info
set (current "${${name}_VERSION_MAJOR}")
set (age "${${name}_VERSION_MINOR}")
set (inherited_linker_flags "${${name}_LINKER_FLAGS}")
set (dependency_libs "${${name}_LIBRARIES}")
# translate list of libraries to command line
linker_cmdline (LIST INTO dependency_libs FROM ${dependency_libs})
# convert from CMake list (i.e. semi-colon separated)
string (REPLACE ";" " " inherited_linker_flags "${inherited_linker_flags}")
string (REPLACE ";" " " dependency_libs "${dependency_libs}")
# this is the preferred installation path
set (libdir "${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}")
# ${name}_LIBRARY_TYPE is either SHARED or STATIC
if (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (libprefix "${CMAKE_SHARED_LIBRARY_PREFIX}")
set (libsuffix "${CMAKE_SHARED_LIBRARY_SUFFIX}")
set (libname "${CMAKE_SHARED_LIBRARY_PREFIX}${target}${CMAKE_SHARED_LIBRARY_SUFFIX}")
# only Unix has soversion in library names
if (UNIX)
set (dlname "${libname}.${current}")
set (library_names "${libname}.${current}.${age} ${libname}.${current} ${libname}")
else (UNIX)
set (dlname "${libname}")
set (library_names "${libname}")
endif (UNIX)
set (old_library "")
else (${name}_LIBRARY_TYPE STREQUAL "SHARED")
set (dlname "")
set (library_names "")
set (old_library "${CMAKE_STATIC_LIBRARY_PREFIX}${target}${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif (${name}_LIBRARY_TYPE STREQUAL "SHARED")
# get the version of libtool installed on the system; this is
# necessary because libtool checks that the file contains its own
# signature(!)
if (NOT libtool_MAIN)
find_file (
libtool_MAIN
ltmain.sh
PATHS /usr
PATH_SUFFIXES share/libtool/config/
DOC "Location of libtool"
)
mark_as_advanced (libtool_MAIN)
# notify the user if it not found after we explicitly searched
if (NOT libtool_MAIN)
message (STATUS "Libtool not found!")
endif (NOT libtool_MAIN)
endif (NOT libtool_MAIN)
if (libtool_MAIN)
file (STRINGS
${libtool_MAIN}
ltversion_STRING
REGEX "^VERSION=\".*\""
)
endif (libtool_MAIN)
if (ltversion_STRING)
string (REGEX REPLACE
"^VERSION=\"?(.*)\"?"
"\\1"
ltversion
${ltversion_STRING}
)
endif (ltversion_STRING)
# assume that we are in cmake/Modules, and that the template have been
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
# this is in a function, and we cannot know who's calling us
set (templ_dir "${OPM_MACROS_ROOT}/cmake/Templates")
# only write an .la if libtool is found; otherwise we have no use
# for it.
if (ltversion)
set (la_file "lib${target}.la")
message (STATUS "Writing libtool archive for ${target}")
configure_file (
${templ_dir}/la.in
${CMAKE_ARCHIVE_OUTPUT_DIRECTORY}/${la_file}
@ONLY@
)
else (ltversion)
set (la_file "")
endif (ltversion)
# return this variable to the caller
if (ARGV2)
set (${ARGV2} "${la_file}" PARENT_SCOPE)
endif (ARGV2)
endfunction (configure_la target)

View File

@ -0,0 +1,26 @@
# - Alias probed variables for compatibility with DUNE buildsystem
#
# DUNE build system sets some variables which have different names
# in the CMake modules we are using; this module set those variable
# so they can be exported to config.h visible to DUNE headers
function (set_aliases)
# hardcoded list of "dune-var opm-var" pairs, where the components
# are separated by space
set (aliases
"HAVE_UMFPACK HAVE_SUITESPARSE_UMFPACK_H"
"HAVE_DUNE_BOOST HAVE_BOOST"
)
foreach (alias IN LISTS aliases)
# convert entry "X Y" into a list "X;Y", then pick apart
string (REGEX REPLACE "\ +" ";" tuple "${alias}")
list (GET tuple 0 var)
list (GET tuple 1 name)
# write this alias to cache
set (${var} ${${name}} PARENT_SCOPE)
endforeach (alias)
endfunction (set_aliases)
# always call this when the module is imported
set_aliases ()

View File

@ -0,0 +1,71 @@
# - Compile main library target
option (STRIP_DEBUGGING_SYMBOLS "use separate files for the executable code and the debugging symbols" OFF)
macro (opm_compile opm)
# some CMake properties do not do list expansion
string (REPLACE ";" " " ${opm}_LINKER_FLAGS_STR "${${opm}_LINKER_FLAGS}")
# name of the library should not contain dashes, as CMake will
# define a symbol with that name, and those cannot contain dashes
string (REPLACE "-" "" ${opm}_TARGET "${${opm}_NAME}")
# all public header files are together with the source. prepend our own
# source path to the one of the dependencies so that our version of any
# ambigious paths are used.
set (${opm}_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
set (${opm}_INCLUDE_DIRS ${${opm}_INCLUDE_DIR} ${${opm}_INCLUDE_DIRS})
# create this library, if there are any compilation units
include_directories (${${opm}_INCLUDE_DIRS})
link_directories (${${opm}_LIBRARY_DIRS})
add_definitions (${${opm}_DEFINITIONS})
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
if (${opm}_SOURCES)
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
set_target_properties (${${opm}_TARGET} PROPERTIES
SOVERSION ${${opm}_VERSION_MAJOR}
VERSION ${${opm}_VERSION}
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
)
target_link_libraries (${${opm}_TARGET} ${${opm}_LIBRARIES})
if (STRIP_DEBUGGING_SYMBOLS)
# queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
endif()
else (${opm}_SOURCES)
# unset this variable to signal that no library is generated
set (${opm}_TARGET)
endif (${opm}_SOURCES)
# pre-compile common headers; this is setup *after* the library to pick
# up extra options set there
if (PRECOMPILE_HEADERS)
# if we have no library, then use the static setting as this will
# build the same way as any test programs (no -fPIC option)
if (${opm}_TARGET)
get_target_property (_type ${${opm}_TARGET} TYPE)
else ()
set (_type "STATIC")
endif ()
precompile_header (CXX ${_type}
HEADER "${${opm}_PRECOMP_CXX_HEADER}"
TARGET ${opm}_CXX_pch
FLAGS ${opm}_PRECOMP_CXX_FLAGS
)
# must set property on source files instead of entire target, because
# it only applies to C++ modules (and cannot be used for C)
set_source_files_properties (${${opm}_CXX_SOURCES} PROPERTIES
OBJECT_DEPENDS "${${opm}_CXX_pch}"
COMPILE_FLAGS "${${opm}_PRECOMP_CXX_FLAGS}"
)
message (STATUS "Precompiled headers: ${${opm}_CXX_pch}")
endif (PRECOMPILE_HEADERS)
# we need to know the name of the library which is generated
if (${opm}_TARGET)
get_target_property (${opm}_LIBRARY ${${opm}_TARGET} LOCATION)
endif (${opm}_TARGET)
endmacro (opm_compile opm)

View File

@ -0,0 +1,99 @@
# - Default settings for the build
include (UseCompVer)
is_compiler_gcc_compatible ()
include(TestCXXAcceptsFlag)
macro (opm_defaults opm)
# if we are installing a development version (default when checking out of
# VCS), then remember which directories were used when configuring. package
# distribution should disable this option.
option (USE_RUNPATH "Embed original dependency paths in installed library" ON)
if (USE_RUNPATH)
if (CXX_COMPAT_GCC)
check_cxx_accepts_flag ("-Wl,--enable-new-dtags" HAVE_RUNPATH)
if (HAVE_RUNPATH)
list (APPEND ${opm}_LINKER_FLAGS "-Wl,--enable-new-dtags")
endif (HAVE_RUNPATH)
endif ()
# set this to avoid CMake stripping it off again
set (CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
endif (USE_RUNPATH)
# build release by default
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Release")
endif (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
# default to building a static library, but let user override
if (DEFINED BUILD_SHARED_LIBS)
if (BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE SHARED)
else (BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE STATIC)
endif (BUILD_SHARED_LIBS)
else (DEFINED BUILD_SHARED_LIBS)
set (${opm}_LIBRARY_TYPE STATIC)
endif (DEFINED BUILD_SHARED_LIBS)
# precompile standard headers to speed up compilation
# unfortunately, this functionality is buggy and tends to segfault at
# least up to version 4.7.2, so it should be disabled by default there
set (_precomp_def OFF)
option (PRECOMPILE_HEADERS "Precompile common headers for speed." ${_precomp_def})
mark_as_advanced (PRECOMPILE_HEADERS)
if (NOT PRECOMPILE_HEADERS)
message (STATUS "Precompiled headers: disabled")
endif(NOT PRECOMPILE_HEADERS)
# Use of OpenMP is considered experimental
set (USE_OPENMP_DEFAULT OFF)
# if we are on a system where CMake 2.6 is the default (Hi RHEL 6!),
# the configuration files for Boost will trip up the library paths
# (look for /usr/lib64/lib64/ in the log) when used with FindBoost
# module bundled with CMake 2.8. this can be circumvented by turning
# off config mode probing if we have not explicitly specified a
# directory to look for it. for more details, see
# <http://stackoverflow.com/questions/9948375/cmake-find-package-succeeds-but-returns-wrong-path>
if (NOT BOOST_ROOT)
set (Boost_NO_BOOST_CMAKE ON)
endif (NOT BOOST_ROOT)
endmacro (opm_defaults opm)
# overwrite a cache entry's value, but keep docstring and type
# if not already in cache, then does nothing
function (update_cache name)
get_property (_help CACHE "${name}" PROPERTY HELPSTRING)
get_property (_type CACHE "${name}" PROPERTY TYPE)
if (NOT "${_type}" STREQUAL "")
#message ("Setting ${name} to \"${${name}}\" in cache.")
set ("${name}" "${${name}}" CACHE ${_type} "${_help}" FORCE)
endif ()
endfunction (update_cache name)
# put all compiler options currently set back into the cache, so that
# they can be queried from there (using ccmake for instance)
function (write_back_options)
# build type
update_cache (CMAKE_BUILD_TYPE)
# compilers
set (languages C CXX Fortran)
foreach (language IN LISTS _languages)
if (CMAKE_${language}_COMPILER)
update_cache (CMAKE_${language}_COMPILER)
endif ()
endforeach (language)
# flags (notice use of IN LISTS to get the empty variant)
set (buildtypes "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO")
set (processors "C" "CXX" "Fortran" "EXE_LINKER" "MODULE_LINKER" "SHARED_LINKER")
foreach (processor IN LISTS processors)
foreach (buildtype IN LISTS buildtypes)
if (CMAKE_${processor}_FLAGS${buildtype})
update_cache (CMAKE_${processor}_FLAGS${buildtype})
endif ()
endforeach (buildtype)
endforeach (processor)
endfunction (write_back_options)

View File

@ -0,0 +1,89 @@
# - Cleanup configuration files
#
# Remove files generated by the configuration (not by the build); the
# purpose is to get back a clean directory with no build artifacts
# (some empty directories may be left behind, though)
#
# The following suffices are supported:
# _NAME Name of the project
# _STYLESHEET_COPIED Stylesheet that was copied for the documentation
# _LIBTOOL_ARCHIVE Libtool archive file generated for library
# _DEBUG Debug information extracted from library
macro (opm_dist_clean opm)
# which generator have we been using
string (TOUPPER "${CMAKE_GENERATOR}" _gen)
if (_gen MATCHES "UNIX MAKEFILES")
set (_gen_is_makefiles TRUE)
set (_gen_is_ninja FALSE)
elseif (_gen MATCHES "NINJA")
set (_gen_is_makefiles FALSE)
set (_gen_is_ninja TRUE)
else ()
set (_gen_is_makefiles FALSE)
set (_gen_is_ninja FALSE)
endif ()
set (DISTCLEAN_FILES
CMakeCache.txt
cmake_install.cmake
config.h
config.h.tmp
${${opm}_NAME}-config.cmake
${${opm}_NAME}-config-version.cmake
${${opm}_NAME}-install.cmake
${${opm}_NAME}.pc
${${opm}_NAME}-install.pc
${doxy_dir}/Doxyfile
${doxy_dir}/Doxyfile.in
CTestTestfile.cmake
DartConfiguration.tcl
lib/${${opm}_LIBTOOL_ARCHIVE}
${${opm}_DEBUG}
${tests_DEBUG}
${examples_DEBUG}
${tutorial_DEBUG}
install_manifest.txt
${${opm}_STYLESHEET_COPIED}
${tests_INPUT_FILES}
project-version.h
project-version.tmp
)
if (_gen_is_makefiles)
list (APPEND DISTCLEAN_FILES
Makefile)
endif ()
if (_gen_is_ninja)
list (APPEND DISTCLEAN_FILES
build.ninja
rules.ninja
)
endif ()
# only remove these files if they were actually copied
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
list (APPEND DISTCLEAN_FILES
dune.module
dunemod.tmp
)
endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# script to remove empty directories (can't believe this isn't included!)
set (rmdir "${OPM_MACROS_ROOT}/cmake/Scripts/RemoveEmptyDir.cmake")
add_custom_target (distclean
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} -- clean
COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES}
COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/
COMMAND ${CMAKE_COMMAND} -E remove_directory Testing/
COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_LIBRARY_OUTPUT_DIRECTORY} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR=${CMAKE_RUNTIME_OUTPUT_DIRECTORY} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${doxy_dir} -P ${rmdir}
COMMAND ${CMAKE_COMMAND} -DDIR:LOCATION=${tests_DIR} -P ${rmdir}
# cannot depend on clean because it is only defined in the master Makefile
# not in CMakeFiles/Makefile where this target will end up
# DEPENDS clean
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}
COMMENT Removing CMake-generated files
VERBATIM
)
endmacro (opm_dist_clean opm)

View File

@ -0,0 +1,81 @@
# - Setup documentation
#
# Assumes that a Doxyfile template is located in the project root
# directory, and that all documentation is going to be generated
# into its own Documentation/ directory. It will also generate an
# installation target for the documentation (not built by default)
#
# Requires the following variables to be set:
# ${opm}_NAME Name of the project
#
# Output the following variables:
# ${opm}_STYLESHEET_COPIED Location of stylesheet to be removed in distclean
macro (opm_doc opm doxy_dir)
# combine the template with local customization
file (READ ${OPM_MACROS_ROOT}/cmake/Templates/Doxyfile _doxy_templ)
string (REPLACE ";" "\\;" _doxy_templ "${_doxy_templ}")
if (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
file (READ ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal _doxy_local)
string (REPLACE ";" "\\;" _doxy_local "${_doxy_local}")
else (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
set (_doxy_local)
endif (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
file (MAKE_DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir})
file (WRITE ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile.in ${_doxy_templ} ${_doxy_local})
# set this generically named variable so even the custom file can be shared
set (src_DIR "${${opm}_DIR}")
# replace variables in this combined file
configure_file (
${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile.in
${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
@ONLY
)
find_package (Doxygen)
if (DOXYGEN_FOUND)
add_custom_target (doc
COMMAND ${DOXYGEN_EXECUTABLE} ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
SOURCES ${PROJECT_BINARY_DIR}/${doxy_dir}/Doxyfile
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir}
COMMENT "Generating API documentation with Doxygen"
VERBATIM
)
# distributions have various naming conventions; this enables the packager
# to direct where the install target should put the documentation. the names
# here are taken from GNUInstallDirs.cmake
set (CMAKE_INSTALL_DATAROOTDIR "share" CACHE STRING "Read-only arch.-indep. data root")
set (CMAKE_INSTALL_DOCDIR "${CMAKE_INSTALL_DATAROOTDIR}/doc${${opm}_VER_DIR}/${${opm}_NAME}" CACHE STRING "Documentation root")
set (_formats html)
foreach (format IN LISTS _formats)
string (TOUPPER ${format} FORMAT)
install (
DIRECTORY ${PROJECT_BINARY_DIR}/${doxy_dir}/${format}
DESTINATION ${CMAKE_INSTALL_DOCDIR}
COMPONENT ${format}
OPTIONAL
)
# target to install just HTML documentation
add_custom_target (install-${format}
COMMAND ${CMAKE_COMMAND} -DCOMPONENT=${format} -P cmake_install.cmake
COMMENT Installing ${FORMAT} documentation
VERBATIM
)
# since the documentation is optional, it is not automatically built
add_dependencies (install-${format} doc)
endforeach (format)
endif (DOXYGEN_FOUND)
# stylesheets must be specified with relative path in Doxyfile, or the
# full path (to the source directory!) will be put in the output HTML.
# thus, we'll need to copy the stylesheet to this path relative to where
# Doxygen will be run (in the output tree)
if ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
file (COPY ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css
DESTINATION ${PROJECT_BINARY_DIR}/${doxy_dir}
)
set (${opm}_STYLESHEET_COPIED "${doxy_dir}/style.css")
else ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
set (${opm}_STYLESHEET_COPIED "")
endif ((NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) AND (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/style.css))
endmacro (opm_doc opm)

View File

@ -0,0 +1,100 @@
# - Identify source code
macro (opm_out_dirs)
# put libraries in lib/ (no multi-arch support in build tree)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set (CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/lib")
set (CMAKE_RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bin")
set (CMAKE_Fortran_MODULE_DIRECTORY "${PROJECT_BINARY_DIR}/CMakeFiles")
endmacro (opm_out_dirs)
# support for some of the variables that are used in Autotools
# template files
macro (opm_auto_dirs)
set (abs_top_builddir "${PROJECT_BINARY_DIR}")
set (abs_top_srcdir "${PROJECT_SOURCE_DIR}")
endmacro (opm_auto_dirs)
macro (opm_sources opm)
# this is necessary to set so that we know where we are going to
# execute the test programs (and make datafiles available)
set (tests_DIR "tests")
# how to retrieve the "fancy" name from the filename
set (tests_REGEXP
"^test_([^/]*)$"
"^([^/]*)_test$"
)
# these are the lists that must be defined in CMakeLists_files
# - MAIN_SOURCE_FILES
# - EXAMPLE_SOURCE_FILES
# - TEST_SOURCE_FILES
# - TEST_DATA_FILES
# - PUBLIC_HEADER_FILES
# - PROGRAM_SOURCE_FILES
# rename from "friendly" names to ones that fit the "almost-structural"
# scheme used in the .cmake modules, converting them to absolute file
# names in the process
foreach (_file IN LISTS MAIN_SOURCE_FILES)
list (APPEND ${opm}_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
# further classify into language if some other modules need to add props
if (_file MATCHES ".*\\.[cC][a-zA-Z]*$")
if (_file MATCHES ".*\\.c$")
list (APPEND ${opm}_C_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
else (_file MATCHES ".*\\.c$")
list (APPEND ${opm}_CXX_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endif (_file MATCHES ".*\\.c$")
elseif (_file MATCHES ".*\\.[fF][a-zA-Z]*$")
list (APPEND ${opm}_Fortran_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endif (_file MATCHES ".*\\.[cC][a-zA-Z]*$")
endforeach (_file)
foreach (_file IN LISTS PUBLIC_HEADER_FILES)
list (APPEND ${opm}_HEADERS ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS TEST_SOURCE_FILES)
list (APPEND tests_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS TEST_DATA_FILES)
list (APPEND tests_DATA ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS EXAMPLE_SOURCE_FILES)
list (APPEND examples_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS PROGRAM_SOURCE_FILES)
list (APPEND examples_SOURCES_DIST ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
foreach (_file IN LISTS ATTIC_FILES)
list (APPEND attic_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
endforeach (_file)
# identify pre-compile header; if the project is called opm-foobar,
# then it should be in opm/foobar/opm-foobar-pch.hpp
string (REPLACE "-" "/" opm_NAME_AS_DIR ${${opm}_NAME})
set (${opm}_PRECOMP_CXX_HEADER "${opm_NAME_AS_DIR}/${${opm}_NAME}-pch.hpp")
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
set (${opm}_PRECOMP_CXX_HEADER "")
endif (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
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)

218
cmake/Modules/OpmFind.cmake Normal file
View File

@ -0,0 +1,218 @@
# - Generic inclusion of packages
#
# Synopsis:
#
# find_and_append_package (name args)
#
# where
#
# name Name of the package, e.g. Boost
# args Other arguments, e.g. COMPONENTS, REQUIRED, QUIET etc.
#
# This macro will append the list of standard variables found by the
# package to this project's standard variables
#
########################################################################
#
# - Generic inclusion of a list of packages
#
# Synopsis:
#
# find_and_append_package_list (args)
#
# where
#
# args List of package strings. Each string must be quoted if
# it contains more than one word.
#
# Example:
#
# find_and_append_package_list (
# "Boost COMPONENTS filesystem REQUIRED"
# SUPERLU
# )
include (Duplicates)
# list of suffixes for all the project variables
set (_opm_proj_vars
SOURCES
LINKER_FLAGS
LIBRARIES
DEFINITIONS
INCLUDE_DIRS
LIBRARY_DIRS
CONFIG_VARS
CONFIG_IMPL_VARS
)
# ensure that they are at least the empty list after we're done
foreach (name IN LISTS _opm_proj_vars)
if (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name})
set (${CMAKE_PROJECT_NAME}_${name} "")
endif (NOT DEFINED ${CMAKE_PROJECT_NAME}_${name})
endforeach (name)
# these dependencies must always be handled by the find module
set (_opm_proj_exemptions
dune-common
dune-istl
dune-grid
dune-geometry
opm-parser
)
# although a DUNE module, it is delivered in the OPM suite
set (dune-cornerpoint_SUITE "opm")
set (ewoms_SUITE "opm")
# insert this boilerplate whenever we are going to find a new package
macro (find_and_append_package_to prefix name)
# special handling for Boost to avoid inadvertedly picking up system
# libraries when we want our own version. this is done here because
# having a custom Boost is common, but the logic to search only there
# does not follow any particular convention.
if (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS)
set (Boost_NO_SYSTEM_PATHS TRUE)
endif (BOOST_ROOT AND NOT DEFINED Boost_NO_SYSTEM_PATHS)
# if we have specified a directory, don't revert to searching the
# system default paths afterwards
string (TOUPPER "${name}" NAME)
string (REPLACE "-" "_" NAME "${NAME}")
# only use suite if module-specific variable is not set. this allows
# us to override one dir in a suite
if (NOT (${name}_DIR OR ${name}_ROOT OR ${NAME}_ROOT))
# module is part of a suite if it has name with the pattern xxx-yyy
if (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
# allow to override if the module doesn't quite fit the convention
# e.g. dune-cornerpoint
if (NOT DEFINED ${name}_SUITE)
# extract suite name from module
string (REGEX REPLACE "([^-]+)-.+" "\\1" ${name}_SUITE "${name}")
endif (NOT DEFINED ${name}_SUITE)
# assume that each module has its own subdir directly under suite dir
string (TOUPPER "${${name}_SUITE}" ${name}_SUITE_UPPER)
if (DEFINED ${${name}_SUITE_UPPER}_ROOT)
set (${NAME}_ROOT ${${${name}_SUITE_UPPER}_ROOT}/${name})
endif (DEFINED ${${name}_SUITE_UPPER}_ROOT)
endif (("${name}" MATCHES "[^-]+-.+") OR ${name}_SUITE)
endif (NOT (${name}_DIR OR ${name}_ROOT OR ${NAME}_ROOT))
# the documentation says that if *-config.cmake files are not found,
# find_package will revert to doing a full search, but that is not
# true, so unconditionally setting ${name}_DIR is not safe. however,
# if the directory given to us contains a config file, then copy the
# value over to this variable to switch to config mode (CMake will
# always use config mode if *_DIR is defined)
if (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT))
if (EXISTS ${${name}_ROOT}/${name}-config.cmake OR EXISTS ${${name}_ROOT}/${name}Config.cmake)
set (${name}_DIR "${${name}_ROOT}")
endif (EXISTS ${${name}_ROOT}/${name}-config.cmake OR EXISTS ${${name}_ROOT}/${name}Config.cmake)
if (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake)
set (${name}_DIR "${${NAME}_ROOT}")
endif (EXISTS ${${NAME}_ROOT}/${name}-config.cmake OR EXISTS ${${NAME}_ROOT}/${name}Config.cmake)
endif (NOT DEFINED ${name}_DIR AND (DEFINED ${name}_ROOT OR DEFINED ${NAME}_ROOT))
# these libraries need special handling which is not provided in
# the -config.cmake file, but which must be provided by this project,
# something which is done in our find module
list (FIND _opm_proj_exemptions "${name}" _${name}_exempted)
if ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR))
set (${name}_ROOT "${${name}_DIR}")
# store this for later, in case we reconfigure
set (${name}_ROOT "${${name}_ROOT}" CACHE LOCATION "Path to ${name}")
# clear this to not use config mode
unset (${name}_DIR)
# variables that are given on the command-line is also put in the cache
# removing the local copy only "unshadows" this one
unset (${name}_DIR CACHE)
endif ((NOT (_${name}_exempted EQUAL -1)) AND (DEFINED ${name}_DIR))
# if we're told not to look for the package, pretend it was never found
if (CMAKE_DISABLE_FIND_PACKAGE_${name})
set (${name}_FOUND FALSE)
set (${NAME}_FOUND FALSE)
else ()
# using config mode is better than using module (aka. find) mode
# because then the package has already done all its probes and
# stored them in the config file for us
if (NOT DEFINED ${name}_FOUND AND NOT DEFINED ${NAME}_FOUND)
if (${name}_DIR)
message (STATUS "Finding package ${name} using config mode")
find_package (${name} ${ARGN} NO_MODULE PATHS ${${name}_DIR} NO_DEFAULT_PATH)
else ()
message (STATUS "Finding package ${name} using module mode")
find_package (${name} ${ARGN})
endif ()
endif ()
if (NOT DEFINED ${name}_FOUND)
set (${name}_FOUND "${${NAME}_FOUND}")
endif ()
if (NOT DEFINED ${NAME}_FOUND)
set (${NAME}_FOUND "${${name}_FOUND}")
endif ()
endif ()
# the variable "NAME" may be replaced during find_package (as this is
# now a macro, and not a function anymore), so we must reinitialize
string (TOUPPER "${name}" NAME)
string (REPLACE "-" "_" NAME "${NAME}")
if (${name}_FOUND OR ${NAME}_FOUND)
foreach (var IN LISTS _opm_proj_vars)
if (DEFINED ${name}_${var})
list (APPEND ${prefix}_${var} ${${name}_${var}})
# some packages define an uppercase version of their own name
elseif (DEFINED ${NAME}_${var})
list (APPEND ${prefix}_${var} ${${NAME}_${var}})
endif (DEFINED ${name}_${var})
# some packages define _PATH instead of _DIRS (Hi, MPI!)
if ("${var}" STREQUAL "INCLUDE_DIRS")
if (DEFINED ${name}_INCLUDE_PATH)
list (APPEND ${prefix}_INCLUDE_DIRS ${${name}_INCLUDE_PATH})
elseif (DEFINED ${NAME}_INCLUDE_PATH)
list (APPEND ${prefix}_INCLUDE_DIRS ${${NAME}_INCLUDE_PATH})
endif (DEFINED ${name}_INCLUDE_PATH)
# some packages define only _DIR and not _DIRS (Hi, Eigen3!)
if (DEFINED ${name}_INCLUDE_DIR)
list (APPEND ${prefix}_INCLUDE_DIRS ${${name}_INCLUDE_DIR})
elseif (DEFINED ${NAME}_INCLUDE_DIR)
list (APPEND ${prefix}_INCLUDE_DIRS ${${NAME}_INCLUDE_DIR})
endif (DEFINED ${name}_INCLUDE_DIR)
endif ("${var}" STREQUAL "INCLUDE_DIRS")
# cleanup lists
if ("${var}" STREQUAL "LIBRARIES")
remove_duplicate_libraries (${prefix})
else ("${var}" STREQUAL "LIBRARIES")
remove_duplicate_var (${prefix} ${var})
endif ("${var}" STREQUAL "LIBRARIES")
endforeach (var)
# some libraries only define xxx_FOUND and not a corresponding HAVE_xxx
if (NOT DEFINED HAVE_${NAME})
set (HAVE_${NAME} 1)
endif (NOT DEFINED HAVE_${NAME})
endif (${name}_FOUND OR ${NAME}_FOUND)
endmacro (find_and_append_package_to prefix name)
# append to the list of variables associated with the project
macro (find_and_append_package name)
find_and_append_package_to (${CMAKE_PROJECT_NAME} ${name} ${ARGN})
endmacro (find_and_append_package name)
# find a list of dependencies, adding each one of them
macro (find_and_append_package_list_to prefix)
# setting and separating is necessary to work around apparent bugs
# in CMake's parser (sic)
set (_deps ${ARGN})
foreach (_dep IN LISTS _deps)
separate_arguments (_args UNIX_COMMAND ${_dep})
find_and_append_package_to (${prefix} ${_args})
endforeach (_dep)
endmacro (find_and_append_package_list_to prefix)
# convenience method to supply the project name as prefix
macro (find_and_append_package_list)
find_and_append_package_list_to (${CMAKE_PROJECT_NAME} ${ARGN})
endmacro (find_and_append_package_list)

View File

@ -0,0 +1,81 @@
# - Recreate grid selection macros from DUNE
#
# If anyone requires Dune::GridSelector::GridType, they must call this
# macro in *their* project, to add this information to config.h. (In
# the autotools version, dunecontrol will automatically include m4
# scripts that does this).
#
# Example:
# opm_cornerpoint_grid (${CONFIG_H})
include (CMakeParseArguments)
function (opm_grid_type)
cmake_parse_arguments (a "" "FILENAME;SYMBOL;TYPE;CONDITION" "HEADERS" ${ARGN})
# write prelude of a condition to use this particular grid, an inclusion guard,
# and checks to see if the number of dimensions fits for this type of grid
file (APPEND ${a_FILENAME}
"/* add GRIDTYPE typedef for grid implementation ${a_TYPE}:
defining ${a_SYMBOL} during compilation typedefs this grid implementation as GridType
in namespace Dune::GridSelector;
also integer constants dimgrid and dimworld are set in this namespace.
The required headers for this grid implementation are also included.
*/
#if defined ${a_SYMBOL} && ! defined USED_${a_SYMBOL}_GRIDTYPE
/* someone else has already defined a gridtype */
#if HAVE_GRIDTYPE
#error \"Ambigious definition of GRIDTYPE\"
#endif
#ifndef WORLDDIM
#define WORLDDIM GRIDDIM
#endif
#if not (WORLDDIM >= GRIDDIM)
#error \"WORLDDIM < GRIDDIM does not make sense.\"
#endif
#if ! (${a_CONDITION})
#error \"Preprocessor assertion ${a_CONDITION} failed.\"
#endif
")
# write headers which are capable of defining the type. this should
# really just have consisted of a forward declaration, but the damage
# is done: clients expect to just pull in config.h and have the
# proper type available.
foreach (header IN LISTS a_HEADERS)
file (APPEND ${a_FILENAME}
"#include <${header}>\n"
)
endforeach (header)
# main part which does the typedef and then a postlude which marks
# the grid as "taken" and make sure that no one else does the same
file (APPEND ${a_FILENAME}
"
namespace Dune {
namespace GridSelector {
const int dimgrid = GRIDDIM;
const int worldgrid = WORLDDIM;
typedef ${a_TYPE} GridType;
}
}
#define HAVE_GRIDTYPE 1
#define USED_${a_SYMBOL}_GRIDTYPE 1
#endif
")
endfunction (opm_grid_type)
# write the grid type for dune-cornerpoint
function (opm_cornerpoint_grid config_h)
opm_grid_type (
FILENAME ${CONFIG_H}
SYMBOL CPGRID
HEADERS "dune/grid/CpGrid.hpp" "dune/grid/cpgrid/dgfparser.hh"
TYPE Dune::CpGrid
CONDITION "(GRIDDIM == 3) && (WORLDDIM == 3)"
)
endfunction (opm_cornerpoint_grid config_h)

View File

@ -0,0 +1,73 @@
# - Initialize project-specific variables
#
# This will read the dune.module file for project information and
# set the following variables:
#
# project From the Module: field
# ${project}_NAME Same as above
# ${project}_DESCRIPTION From the Description: field
# ${project}_VERSION_MAJOR From the Version: field
# ${project}_VERSION_MINOR From the Version: field also
#
# This module should be the first to be included in the project,
# because most of the others (OpmXxx.cmake) use these variables.
# helper macro to retrieve a single field of a dune.module file
macro(OpmGetDuneModuleDirective field variable contents)
string (REGEX MATCH ".*${field}:[ ]*([^\n]+).*" ${variable} "${contents}")
string (REGEX REPLACE ".*${field}:[ ]*([^\n]+).*" "\\1" "${variable}" "${${variable}}")
string (STRIP "${${variable}}" ${variable})
endmacro()
function (OpmInitProjVars)
# locate the "dune.module" file
set (DUNE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dune.module")
# read this file into a variable
file (READ "${DUNE_MODULE_PATH}" DUNE_MODULE)
# read fields from the file
OpmGetDuneModuleDirective ("Module" project "${DUNE_MODULE}")
OpmGetDuneModuleDirective ("Description" description "${DUNE_MODULE}")
OpmGetDuneModuleDirective ("Version" version "${DUNE_MODULE}")
OpmGetDuneModuleDirective ("Label" label "${DUNE_MODULE}")
# parse the version number
set (verno_regex "^([0-9]*)\\.([0-9]*).*\$")
string (REGEX REPLACE "${verno_regex}" "\\1" major "${version}")
string (REGEX REPLACE "${verno_regex}" "\\2" minor "${version}")
# return these variables
set (project "${project}" PARENT_SCOPE)
set (${project}_NAME "${project}" PARENT_SCOPE)
set (${project}_DESCRIPTION "${description}" PARENT_SCOPE)
set (${project}_VERSION_MAJOR "${major}" PARENT_SCOPE)
set (${project}_VERSION_MINOR "${minor}" PARENT_SCOPE)
set (${project}_LABEL "${label}" PARENT_SCOPE)
endfunction ()
macro (OpmInitDirVars)
# these are the most common (and desired locations)
set (${project}_DIR "opm")
set (doxy_dir "doc/doxygen")
# but for backward compatibility we can override it
if (COMMAND dir_hook)
dir_hook ()
endif (COMMAND dir_hook)
endmacro ()
OpmInitProjVars ()
OpmInitDirVars ()
# if we are backporting this release to a system which already have an
# earlier version, set this flag to have everything scoped into a directory
# which incorporates the label of the release. this is done by interjecting
# the ${project}_VER_DIR into the installation path.
option (USE_VERSIONED_DIR "Put files in release-specific directories" OFF)
set (${project}_SUITE "opm")
if (USE_VERSIONED_DIR)
set (${project}_VER_DIR "/${${project}_SUITE}-${${project}_LABEL}")
else ()
set (${project}_VER_DIR "")
endif ()

View File

@ -0,0 +1,64 @@
# - Installation macro
#
# Set up installation targets for the binary library. The following
# suffices must be defined for the prefix passed as parameter:
#
# _NAME Name of the library
# _HEADERS List of header files to install
# _TARGET CMake target which builds the library
# _LIBRARY_TYPE Static or shared library
# _DEBUG File containing debug symbols
include (UseMultiArch)
macro (opm_install opm)
foreach (_hdr IN LISTS ${opm}_HEADERS)
get_filename_component (_dir ${_hdr} PATH)
file (RELATIVE_PATH _rel_dir "${PROJECT_SOURCE_DIR}" "${_dir}")
install (
FILES ${_hdr}
DESTINATION include${${opm}_VER_DIR}/${_rel_dir}
)
endforeach (_hdr)
install (
TARGETS ${${opm}_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
)
# only /usr/lib/debug seems to be searched for debug info; if we have
# write access to that directory (package installation), then default
# to use it; otherwise put the debug files together with the library
# (local installation). everything can be overridden by the option.
if (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set (_sys_dbg_def ON)
else (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
set (_sys_dbg_def OFF)
endif (CMAKE_INSTALL_PREFIX STREQUAL "/usr")
option (SYSTEM_DEBUG "Put .debug files in GDB debug file directory" ${_sys_dbg_def})
set (DEBUG_FILE_DIRECTORY /usr/lib/debug CACHE LOCATION "GDB debug file directory")
mark_as_advanced (DEBUG_FILE_DIRECTORY)
if (SYSTEM_DEBUG AND NOT APPLE)
set (_dbg_prefix "${DEBUG_FILE_DIRECTORY}/")
else (SYSTEM_DEBUG AND NOT APPLE)
set (_dbg_prefix "")
endif (SYSTEM_DEBUG AND NOT APPLE)
# static libraries don't have their debug info stripped, so there is
# only a separate file when we are building shared objects
if (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
# on MacOS X, debug files are actually bundles (directories)
if (APPLE)
set (_dbg_type DIRECTORY)
else ()
set (_dbg_type FILES)
endif ()
install (
${_dbg_type} ${PROJECT_BINARY_DIR}/${${opm}_DEBUG}
DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR}
)
endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG)
# note that the DUNE parts that looks for dune.module is currently (2013-09) not
# multiarch-aware and will thus put in lib64/ on RHEL and lib/ on Debian
install (
FILES ${PROJECT_SOURCE_DIR}/dune.module
DESTINATION ${LIBDIR_MULTIARCH_UNAWARE}${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME}
)
endmacro (opm_install opm)

View File

@ -0,0 +1,58 @@
# -*- 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:
# features that may be used by some packages (Fortran wrappers
# for instance), and this set options for, but which is included
# conditionally and thus does not exist in other packages
set (FEATURE_VARS
USE_UNDERSCORING
)
# emulate the with-xxx feature of autotools to not give warnings
# if we specify the directories of packages that are known to the
# family but not necessarily used
# pick package names from these; opm-xxx, dune-xxx
set (KNOWN_FAMILIES
opm
dune
)
# variables to test; xxx_DIR, xxx_ROOT
set (KNOWN_VARS
DIR
ROOT
)
set (KNOWN_opm_PKGS
autodiff
core
material
parser
polymer
porsol
upscaling
verteq
)
set (KNOWN_dune_PKGS
common
cornerpoint
geometry
grid
istl
localfunctions
)
foreach (family IN ITEMS ${KNOWN_FAMILIES})
foreach (package IN ITEMS ${KNOWN_${family}_PKGS})
foreach (var IN ITEMS ${KNOWN_VARS})
# just "use" the variable, so we don't get warnings
set (_dummy ${${family}-${package}_${var}})
endforeach (var)
endforeach (package)
endforeach (family)
foreach (feature IN ITEMS ${FEATURE_VARS})
set (_dummy ${${feature}})
endforeach (feature)

View File

@ -0,0 +1,294 @@
# -*- 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:
# - Build an OPM library module
#
# This macro assumes that ${project} contains the name of the project,
# e.g. "opm-core", and that various variables that configures the module
# has been setup in advance.
#
# Customize the module configuration by defining these "callback" macros:
#
# prereqs_hook Do special processing before prerequisites are found
# fortran_hook Determine whether Fortran support is necessary or not
# sources_hook Do special processing before sources are compiled
# tests_hook Do special processing before tests are compiled
# files_hook Do special processing before final targets are added
# for CMake >= 3.0, we need to change a few policies:
#
# - CMP0026 to allow access to the LOCATION target property
# - CMP0048 to indicate that we want to deal with the *VERSION*
# variables ourselves
if (POLICY CMP0026)
cmake_policy(SET CMP0026 OLD)
endif()
if (POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()
# include special
if (CMAKE_VERSION VERSION_LESS "2.8.3")
message (STATUS "Enabling compatibility modules for CMake 2.8.3")
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules/compat-2.8.3")
endif (CMAKE_VERSION VERSION_LESS "2.8.3")
if (CMAKE_VERSION VERSION_LESS "2.8.5")
message (STATUS "Enabling compatibility modules for CMake 2.8.5")
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules/compat-2.8.5")
endif (CMAKE_VERSION VERSION_LESS "2.8.5")
if (CMAKE_VERSION VERSION_LESS "2.8.7")
message (STATUS "Enabling compatibility modules for CMake 2.8.7")
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules/compat-2.8.7")
endif (CMAKE_VERSION VERSION_LESS "2.8.7")
# don't write default flags into the cache, preserve that for user set values
include (AddOptions)
no_default_options ()
# C++ project
project (${${project}_NAME})
enable_language (C)
enable_language (CXX)
# print system information to better pinpoint issues from log alone
include (UseSystemInfo)
system_info ()
# very early try to print repo id (to pinpoint version if something goes wrong)
include (UseVCSInfo)
vcs_info ()
# print toolchain information to identify compilers with potential bugs
include (UseCompVer)
compiler_info ()
linker_info ()
# default settings: build static debug library
include (OpmDefaults)
opm_defaults (${project})
message (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
# use tricks to do faster builds
include (UseFastBuilds)
# precompiled headers
include (UsePrecompHeaders)
# optimize full if we're not doing a debug build
include (UseOptimization)
# turn on all warnings; this must be done before adding any
# dependencies, in case they alter the list of warnings
include (UseWarnings)
# parallel computing must be explicitly enabled
option (USE_MPI "Use Message Passing Interface for parallel computing" OFF)
if (NOT USE_MPI)
set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
endif (NOT USE_MPI)
# parallel programming
include (UseOpenMP)
find_openmp (${project})
# callback hook to setup additional dependencies
if (COMMAND prereqs_hook)
prereqs_hook ()
endif (COMMAND prereqs_hook)
# macro to set standard variables (INCLUDE_DIRS, LIBRARIES etc.)
include (OpmFind)
find_and_append_package_list_to (${project} ${${project}_DEPS})
# set aliases to probed variables
include (OpmAliases)
# remove the dependency on the testing framework from the main library;
# it is not possible to query for Boost twice with different components.
list (REMOVE_ITEM "${project}_LIBRARIES" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
# don't import more libraries than we need to
include (UseOnlyNeeded)
# put debug information into every executable
include (UseDebugSymbols)
# detect if Boost is in a shared library
include (UseDynamicBoost)
# needed for Debian installation scheme
include (UseMultiArch)
# Run conditional file hook
files_hook()
# this module contains code to figure out which files is where
include (OpmFiles)
opm_auto_dirs ()
# put libraries in lib/
opm_out_dirs ()
# identify the compilation units in the library; sources in opm/,
# tests files in tests/, examples in tutorials/ and examples/
opm_sources (${project})
# processing after base sources have been identified
if (COMMAND sources_hook)
sources_hook ()
endif (COMMAND sources_hook)
# convenience macro to add version of another suite, e.g. dune-common
macro (opm_need_version_of what)
string (TOUPPER "${what}" _WHAT)
string (REPLACE "-" "_" _WHAT "${_WHAT}")
list (APPEND ${project}_CONFIG_IMPL_VARS
${_WHAT}_VERSION_MAJOR ${_WHAT}_VERSION_MINOR ${_WHAT}_VERSION_REVISION
)
endmacro (opm_need_version_of suite module)
# use this hook to add version macros before we write to config.h
if (COMMAND config_hook)
config_hook ()
endif (COMMAND config_hook)
# create configuration header which describes available features
# 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
include (ConfigVars)
list (APPEND ${project}_CONFIG_VARS ${${project}_CONFIG_VAR})
# write configuration variables to this file. note that it is a temporary.
# _CONFIG_IMPL_VARS are defines that are only written to config.h internal
# to this project; they are not exported to any installed files.
# TESTING_CONFIG_VARS is what's required by the unit tests, and is therefore
# added in an ad-hoc manner to avoid putting dependencies to it in the module
# requirement file. (it should be added if there is .h code that needs it)
message (STATUS "Writing config file \"${PROJECT_BINARY_DIR}/config.h\"...")
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h.tmp")
configure_vars (
FILE CXX ${CONFIG_H}
WRITE ${${project}_CONFIG_VARS}
${${project}_CONFIG_IMPL_VARS}
${TESTING_CONFIG_VARS}
)
# call this hook to let it setup necessary conditions for Fortran support
if (COMMAND fortran_hook)
fortran_hook ()
endif (COMMAND fortran_hook)
if (${project}_FORTRAN_IF)
include (UseFortranWrappers)
define_fc_func (
APPEND ${CONFIG_H}
IF ${${project}_FORTRAN_IF}
)
endif (${project}_FORTRAN_IF)
# overwrite the config.h that is used by the code only if we have some
# real changes. thus, we don't have to recompile if a reconfigure is run
# due to some files being added, for instance
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different ${CONFIG_H} ${PROJECT_BINARY_DIR}/config.h
)
# compile main library; pull in all required includes and libraries
include (OpmCompile)
opm_compile (${project})
# installation target: copy the library together with debug and
# configuration files to system directories
include (OpmInstall)
if (COMMAND install_hook)
install_hook ()
endif (COMMAND install_hook)
opm_install (${project})
message (STATUS "This build defaults to installing in ${CMAKE_INSTALL_PREFIX}")
# installation of CMake modules to help user programs locate the library
include (OpmProject)
opm_cmake_config (${project})
# routines to build satellites such as tests, tutorials and samples
include (OpmSatellites)
# example programs are found in the tutorials/ and examples/ directory
option (BUILD_EXAMPLES "Build the examples/ tree" ON)
if (BUILD_EXAMPLES)
opm_compile_satellites (${project} examples "" "")
endif (BUILD_EXAMPLES)
# attic are programs which are not quite abandoned yet; however, they
# are not actively maintained, so they should not be a part of the
# default compile
opm_compile_satellites (${project} attic EXCLUDE_FROM_ALL "")
# infrastructure for testing
enable_testing ()
include (CTest)
# conditionally disable tests when features aren't available
macro (cond_disable_test name)
if ((NOT DEFINED HAVE_${name}) OR (NOT HAVE_${name}))
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}")
endif ((NOT DEFINED HAVE_${name}) OR (NOT HAVE_${name}))
endmacro (cond_disable_test name)
# special processing for tests
if (COMMAND tests_hook)
tests_hook ()
endif (COMMAND tests_hook)
# make datafiles necessary for tests available in output directory
if (BUILD_TESTING)
opm_data (tests datafiles "${tests_DIR}")
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
endif (BUILD_TESTING)
# use this target to run all tests
add_custom_target (check
COMMAND ${CMAKE_CTEST_COMMAND}
DEPENDS tests
COMMENT "Checking if library is functional"
VERBATIM
)
# generate documentation from source code with Doxygen;
# setup install target for this documentation
include (OpmDoc)
opm_doc (${project} ${doxy_dir})
# provide compatibility with using this build in dunecontrol
include (DuneCompat)
include (LibtoolArchives)
if (${project}_TARGET)
configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
endif ()
### clean in-source builds ###
include (OpmDistClean)
opm_dist_clean (${project})
### emulate the with-xxx feature of autotools;
include (OpmKnown)
# make sure we rebuild if dune.module changes
configure_file (
"${CMAKE_CURRENT_SOURCE_DIR}/dune.module"
"${CMAKE_CURRENT_BINARY_DIR}/dunemod.tmp"
COPYONLY
)
# make sure updated version information is available in the source code
include (UseVersion)
# update the cache for next run
write_back_options ()

View File

@ -0,0 +1,407 @@
# - Find routine for OPM-like modules
#
# Synopsis:
#
# find_opm_package (module deps header lib defs prog conf)
#
# where
#
# module Name of the module, e.g. "dune-common"; this will be the
# stem of all variables defined (see below).
# deps Semi-colon-separated list of dependent modules which must
# be present; those that are required must be marked as such
# explicitly. Quote if more than one word is necessary to
# describe the dependency.
# header Name of the header file to probe for, e.g.
# "dune/common/fvector.hh". Note that you should have to same
# relative path here as is used in the header files.
# lib Name of the library to probe for, e.g. "dunecommon"
# defs Symbols that should be passed to compilations
# prog Program that should compile if library is present
# conf Symbols that should be present in config.h
#
# It will provide these standard Find-module variables:
#
# ${module}_INCLUDE_DIRS Directory of header files
# ${module}_LIBRARIES Directory of shared object files
# ${module}_DEFINITIONS Defines that must be set to compile
# ${module}_CONFIG_VARS List of defines that should be in config.h
# HAVE_${MODULE} Binary value to use in config.h
#
# Note: Arguments should be quoted, otherwise a list will spill into the
# next argument!
# Copyright (C) 2012 Uni Research AS
# This file is licensed under the GNU General Public License v3.0
# <http://www.vtk.org/Wiki/CMake:How_To_Find_Libraries>
include (OpmFind)
option (SIBLING_SEARCH "Search sibling directories before system paths" ON)
mark_as_advanced (SIBLING_SEARCH)
# append all items from src into dst; both must be *names* of lists
macro (append_found src dst)
foreach (_item IN LISTS ${src})
if (NOT "${_item}" MATCHES "-NOTFOUND$")
list (APPEND ${dst} ${_item})
endif (NOT "${_item}" MATCHES "-NOTFOUND$")
endforeach (_item)
endmacro (append_found src dst)
macro (find_opm_package module deps header lib defs prog conf)
# in addition to accepting mod-ule_ROOT, we also accept the somewhat
# more idiomatic MOD_ULE_ROOT variant
string (TOUPPER "${module}" MODULE_UPPER)
string (REPLACE "-" "_" MODULE "${MODULE_UPPER}")
# if someone else has included this test, don't do it again
if (${${MODULE}_FOUND})
return ()
endif (${${MODULE}_FOUND})
# variables to pass on to other packages
if (${module}_FIND_QUIETLY)
set (_${module}_quiet "QUIET")
else (${module}_FIND_QUIETLY)
set (_${module}_quiet "")
endif (${module}_FIND_QUIETLY)
if (${module}_FIND_REQUIRED)
set (_${module}_required "REQUIRED")
else (${module}_FIND_REQUIRED)
set (_${module}_required "")
endif (${module}_FIND_REQUIRED)
# see if there is a pkg-config entry for this package, and use those
# settings as a starting point
find_package (PkgConfig)
pkg_check_modules (PkgConf_${module} QUIET ${module})
# these variables have non-standard names in FindPkgConfig (sic)
set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER})
set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER})
# try to figure out whether we are in a subdir build tree, and attempt
# to put the same name as the appropriate build tree for the module
get_filename_component (_build_dir "${CMAKE_CURRENT_BINARY_DIR}" NAME)
# don't bother if we are in a project specific directory already
# (assuming no-one wants to name the build dir after another module!)
if ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
set (_build_dir "")
endif ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
# if the user hasn't specified any location, and it isn't found
# in standard system locations either, then start to wander
# about and look for it in proximity to ourself. Qt Creator likes
# to put the build-directories as siblings to the source trees,
# but with a -build suffix, DUNE likes to have the the build tree
# in a "build-cmake" sub-directory of each module
if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
string (TOLOWER "${module}" _module_lower)
set (_guess
"../${module}"
"../${_module_lower}"
)
set (_guess_bin_only
"../${module}-build"
"../${_module_lower}-build"
)
# look in similar dirs for the other module
if (_build_dir)
list (APPEND _guess_bin_only
"../../${module}/${_build_dir}"
"../../${_module_lower}/${_build_dir}"
)
endif (_build_dir)
# generate items that are in the build, not source dir
set (_guess_bin)
foreach (_item IN ITEMS ${_guess} ${_guess_bin_only})
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item)
set (_no_system "")
else (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
# start looking at the paths in this order
set (_guess_bin
${${module}_DIR}
${${module}_ROOT}
${${MODULE}_ROOT}
)
# if every package is installed directly in the "suite" directory
# (e.g. /usr) then allow us to back-track one directory from the
# module sub-dir that was added by OpmFind (this happens incidently
# already for the source do to the out-of-source support)
if ("${${MODULE}_ROOT}" MATCHES "/${module}$")
get_filename_component (_suite_parent ${${MODULE}_ROOT} PATH)
list (APPEND _guess_bin
${_suite_parent}
${_suite_parent}/${module}
${_suite_parent}/${module}/${_build_dir}
)
endif ("${${MODULE}_ROOT}" MATCHES "/${module}$")
# when we look for the source, it may be that we have been specified
# a build directory which is a sub-dir of the source, so we look in
# the parent also
set (_guess
${${module}_DIR}
${${module}_ROOT}
${${MODULE}_ROOT}
)
# only add parent directories for those variants that are actually set
# (otherwise, we'll inadvertedly add the root directory (=all))
if (${module}_DIR)
list (APPEND _guess ${${module}_DIR}/..)
endif (${module}_DIR)
if (${module}_ROOT)
list (APPEND _guess ${${module}_ROOT}/..)
endif (${module}_ROOT)
if (${MODULE}_ROOT)
list (APPEND _guess ${${MODULE}_ROOT}/..)
endif (${MODULE}_ROOT)
# don't search the system paths! that would be dangerous; if there
# is a problem in our own specified directory, we don't necessarily
# want an old version that is left in one of the system paths!
set (_no_system "NO_DEFAULT_PATH")
endif (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
# by specifying _guess in the HINTS section, it gets searched before
# the system locations as well. the CMake documentation has a cloudy
# recommendation, but it ends up like this: if NO_DEFAULT_PATH is
# specified, then PATHS is used. Otherwise, it looks in HINTS, then in
# system paths, and the finally in PATHS (!)
if (SIBLING_SEARCH)
set (_guess_hints ${_guess})
set (_guess_hints_bin ${_guess_bin})
else (SIBLING_SEARCH)
set (_guess_hints)
set (_guess_hints_bin)
endif (SIBLING_SEARCH)
# if an include directory is specified directly (e.g. OPM_CORE_INCLUDE_DIR=
# /usr/include/opm-2013.03) then this overrides everything else. Notice that
# this variable uses the fully capitalized version of the name.
if (${MODULE}_INCLUDE_DIR)
set (_guess "${${MODULE}_INCLUDE_DIR}")
set (_no_system_incl "NO_DEFAULT_PATH")
else ()
set (_no_system_incl "${_no_system}")
endif ()
# search for this include and library file to get the installation
# directory of the package; hints are searched before the system locations,
# paths are searched afterwards
find_path (${module}_INCLUDE_DIR
NAMES "${header}"
PATHS ${_guess}
HINTS ${PkgConf_${module}_INCLUDE_DIRS} ${_guess_hints}
PATH_SUFFIXES "include"
${_no_system_incl}
)
# some modules are all in headers
if (NOT "${lib}" STREQUAL "")
if (CMAKE_SIZEOF_VOID_P)
math (EXPR _BITS "8 * ${CMAKE_SIZEOF_VOID_P}")
endif (CMAKE_SIZEOF_VOID_P)
# again, we may directly override the location of the library alone by
# specifying e.g. OPM_CORE_LIB_DIR. notice that this is a *directory*
# and not the name of the library
if (${MODULE}_LIB_DIR)
set (_guess_bin "${${MODULE}_LIB_DIR}")
set (_no_system_lib "NO_DEFAULT_PATH")
else ()
set (_no_system_lib "${_no_system}")
endif ()
# if there is more than one library, then look for all of them, putting
# them in variables with the name of the library appended. however, the
# first entry is assumed to be the "primary" library and will be named
# like the module. thus, with a lib entry of "foo;bar", the first library
# is called ${module}_LIBRARY and the second ${module}_LIBRARY_bar
foreach (_lib IN ITEMS ${lib})
# don't include any suffix if it is the first one
if ("${lib}" MATCHES "^${_lib}")
set (_which)
else ()
set (_which "_${_lib}")
endif ()
find_library (${module}_LIBRARY${_which}
NAMES "${_lib}"
PATHS ${_guess_bin}
HINTS ${PkgConf_${module}_LIBRARY_DIRS} ${_guess_hints_bin}
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "build-cmake/lib"
${_no_system_lib}
)
# debug info if we didn't find the desired library
if (NOT ${module}_LIBRARY${_which})
message (STATUS "Failed to find library \"${_lib}\" for module ${module}")
endif ()
endforeach (_lib)
else (NOT "${lib}" STREQUAL "")
set (${module}_LIBRARY "")
endif (NOT "${lib}" STREQUAL "")
# add dependencies so that our result variables are complete
# list of necessities to build with the software
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIR}")
foreach (_lib IN ITEMS ${lib})
if ("${lib}" MATCHES "^${_lib}")
set (${module}_LIBRARIES "${${module}_LIBRARY}")
else ()
list (APPEND ${module}_LIBRARIES "${${module}_LIBRARY_${_lib}}")
endif ()
endforeach (_lib)
# period because it should be something that evaluates to true
# in find_package_handle_standard_args
set (${module}_ALL_PREREQS ".")
foreach (_dep IN ITEMS ${deps})
separate_arguments (_${module}_args UNIX_COMMAND ${_dep})
if (_${module}_args)
# keep REQUIRED in the arguments only if we were required ourself
# "required-ness" is not transitive as far as CMake is concerned
# (i.e. if an optional package requests a package to be required,
# the build will fail if it's not found)
string (REPLACE "REQUIRED" "${_${module}_required}" _args_req "${_${module}_args}")
find_and_append_package_to (${module} ${_args_req} ${_${module}_quiet})
list (GET _${module}_args 0 _name_only)
string (TOUPPER "${_name_only}" _NAME_ONLY)
string (REPLACE "-" "_" _NAME_ONLY "${_NAME_ONLY}")
# check manually if it was found if REQUIRED; otherwise poison the
# dependency list which is checked later (so that it will fail)
if (("${_${module}_args}" MATCHES "REQUIRED") AND NOT (${_name_only}_FOUND OR ${_NAME_ONLY}_FOUND))
list (APPEND ${module}_ALL_PREREQS "${_name_only}-NOTFOUND")
endif ()
else ()
message (WARNING "Empty dependency in find module for ${module} (check for trailing semi-colon)")
endif ()
endforeach (_dep)
# since find_and_append_package_to is a macro, this variable have
# probably been overwritten (due to its common name); it is now
# this module's last dependency instead of the name of the module
# itself, so it must be restored
string (TOUPPER "${module}" MODULE_UPPER)
string (REPLACE "-" "_" MODULE "${MODULE_UPPER}")
# compile with this option to avoid avalanche of warnings
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}")
foreach (_def IN ITEMS ${defs})
list (APPEND ${module}_DEFINITIONS "-D${_def}")
endforeach (_def)
# tidy the lists before returning them
remove_dup_deps (${module})
# these defines are used in dune/${module} headers, and should be put
# in config.h when we include those
foreach (_var IN ITEMS ${conf})
# massage the name to remove source code formatting
string (REGEX REPLACE "^[\n\t\ ]+" "" _var "${_var}")
string (REGEX REPLACE "[\n\t\ ]+$" "" _var "${_var}")
list (APPEND ${module}_CONFIG_VARS ${_var})
endforeach (_var)
# these are the defines that should be set when compiling
# without config.h
config_cmd_line (${module}_CMD_CONFIG ${module}_CONFIG_VARS)
# check that we can compile a small test-program
include (CMakePushCheckState)
cmake_push_check_state ()
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_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})
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
cmake_pop_check_state ()
# write status message in the same manner as everyone else
include (FindPackageHandleStandardArgs)
if ("${lib}" STREQUAL "")
set (_lib_var "")
set (_and_lib_var)
else ("${lib}" STREQUAL "")
foreach (_lib IN ITEMS ${lib})
if ("${lib}" MATCHES "^${_lib}")
set (_lib_var "${module}_LIBRARY")
set (_and_lib_var AND ${_lib_var})
else ()
list (APPEND _lib_var "${module}_LIBRARY_${_lib}")
set (_and_lib_var ${_and_lib_var} AND "${module}_LIBRARY_${_lib}")
endif ()
endforeach (_lib)
endif ("${lib}" STREQUAL "")
# if the search is going to fail, then write these variables to
# the console as well as a diagnostics
if ((NOT (${module}_INCLUDE_DIR ${_and_lib_var} AND HAVE_${MODULE}))
AND (_${module}_required OR NOT _${module}_quiet))
if (DEFINED ${module}_DIR)
message (STATUS "${module}_DIR = ${${module}_DIR}")
elseif (DEFINED ${module}_ROOT)
message (STATUS "${module}_ROOT = ${${module}_ROOT}")
elseif (DEFINED ${MODULE}_ROOT)
message (STATUS "${MODULE}_ROOT = ${${MODULE}_ROOT}")
endif (DEFINED ${module}_DIR)
endif ((NOT (${module}_INCLUDE_DIR ${_and_lib_var} AND HAVE_${MODULE}))
AND (_${module}_required OR NOT _${module}_quiet))
if ("${${module}_ALL_PREREQS}" MATCHES "-NOTFOUND")
message (STATUS "${module} prereqs: ${${module}_ALL_PREREQS}")
endif ()
find_package_handle_standard_args (
${module}
DEFAULT_MSG
${module}_INCLUDE_DIR ${_lib_var} HAVE_${MODULE} ${module}_ALL_PREREQS
)
# allow the user to override these from user interface
mark_as_advanced (${module}_INCLUDE_DIR)
mark_as_advanced (${module}_LIBRARY)
# some genius that coded the FindPackageHandleStandardArgs figured out
# that the module name should be in uppercase (?!)
set (${module}_FOUND "${${MODULE_UPPER}_FOUND}")
set (${MODULE}_FOUND "${${MODULE_UPPER}_FOUND}")
# print everything out if we're asked to
if (${module}_DEBUG)
debug_find_vars (${module})
endif (${module}_DEBUG)
endmacro (find_opm_package module deps header lib defs prog conf)
# print all variables defined by the above macro
function (debug_find_vars module)
message (STATUS "${module}_FOUND = ${${module}_FOUND}")
message (STATUS "${module}_INCLUDE_DIRS = ${${module}_INCLUDE_DIRS}")
message (STATUS "${module}_LIBRARIES = ${${module}_LIBRARIES}")
message (STATUS "${module}_DEFINITIONS = ${${module}_DEFINITIONS}")
message (STATUS "${module}_CONFIG_VARS = ${${module}_CONFIG_VARS}")
message (STATUS "${module}_LINKER_FLAGS = ${${module}_LINKER_FLAGS}")
string (TOUPPER ${module} MODULE)
string (REPLACE "-" "_" MODULE ${MODULE})
message (STATUS "HAVE_${MODULE} = ${HAVE_${MODULE}}")
endfunction (debug_find_vars module)
# generate a command-line that can be used to pass variables before
# config.h is available (such as probe tests). varname is the *name*
# of the variable to receive the result, defs is a list of the *names*
# which should be passed
function (config_cmd_line varname defs)
# process each variable
foreach (_var IN LISTS ${defs})
# only generate an entry if the define was actually set
if ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
# add command-line option to define this variable
list (APPEND _cmdline "-D${_var}=${${_var}}")
endif ((DEFINED ${_var}) AND (NOT "${${_var}}" STREQUAL ""))
endforeach (_var)
# return the resulting command-line options for defining vars
set (${varname} "${_cmdline}" PARENT_SCOPE)
endfunction (config_cmd_line)

View File

@ -0,0 +1,152 @@
# - Helper routines for opm-core like projects
include (LibtoolArchives) # linker_cmdline
# convert a list back to a command-line string
function (unseparate_args var_name prefix value)
separate_arguments (value)
foreach (item IN LISTS value)
set (prefixed_item "${prefix}${item}")
if (${var_name})
set (${var_name} "${${var_name}} ${prefixed_item}")
else (${var_name})
set (${var_name} "${prefixed_item}")
endif (${var_name})
endforeach (item)
set (${var_name} "${${var_name}}" PARENT_SCOPE)
endfunction (unseparate_args var_name prefix value)
# wrapper to set variables in pkg-config file
function (configure_pc_file name source dest prefix libdir includedir)
# escape set of standard strings
unseparate_args (includes "-I" "${${name}_INCLUDE_DIRS}")
unseparate_args (defs "" "${${name}_DEFINITIONS}")
linker_cmdline (STRING INTO libs FROM ${${name}_LIBRARIES})
# necessary to make these variables visible to configure_file
set (name "${${name}_NAME}")
set (description "${${name}_DESCRIPTION}")
set (major "${${name}_VERSION_MAJOR}")
set (minor "${${name}_VERSION_MINOR}")
set (target "${${name}_LIBRARY}")
linker_cmdline (STRING INTO target from ${target})
configure_file (${source} ${dest} @ONLY)
endfunction (configure_pc_file name source dist prefix libdir includedir)
function (configure_cmake_file name variant version)
# declarative list of the variable names that are used in the template
# and that must be defined in the project to be exported
set (variable_suffices
DESCRIPTION
VERSION
DEFINITIONS
INCLUDE_DIRS
LIBRARY_DIRS
LINKER_FLAGS
CONFIG_VARS
LIBRARY
LIBRARIES
TARGET
)
# set these variables temporarily (this is in a function scope) so
# they are available to the template (only)
foreach (suffix IN LISTS variable_suffices)
set (opm-project_${suffix} "${${name}_${suffix}}")
endforeach (suffix)
set (opm-project_NAME "${${name}_NAME}")
# make the file substitutions
configure_file (
${template_dir}/opm-project-config${version}.cmake.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-${variant}${version}.cmake
@ONLY
)
endfunction (configure_cmake_file name)
# installation of CMake modules to help user programs locate the library
function (opm_cmake_config name)
# assume that the template is located in cmake/Templates (cannot use
# the current directory since this is in a function and the directory
# at runtime not at definition will be used
set (template_dir "${OPM_MACROS_ROOT}/cmake/Templates")
# write configuration file to locate library
configure_cmake_file (${name} "config" "")
configure_cmake_file (${name} "config" "-version")
configure_vars (
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-config.cmake"
APPEND "${${name}_CONFIG_VARS}"
)
# config-mode .pc file; use this to find the build tree
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}.pc
${PROJECT_BINARY_DIR}
${CMAKE_LIBRARY_OUTPUT_DIRECTORY}
${PROJECT_SOURCE_DIR}
)
# replace the build directory with the target directory in the
# variables that contains build paths
string (REPLACE
"${PROJECT_SOURCE_DIR}"
"${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}"
${name}_INCLUDE_DIRS
"${${name}_INCLUDE_DIRS}"
)
string (REPLACE
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
${name}_LIBRARY
"${${name}_LIBRARY}"
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}"
)
# create a config mode file which targets the install directory instead
# of the build directory (using the same input template)
configure_cmake_file (${name} "install" "")
configure_vars (
FILE CMAKE "${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake"
APPEND "${${name}_CONFIG_VARS}"
)
# this file gets copied to the final installation directory
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.cmake
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
RENAME ${${name}_NAME}-config.cmake
)
# assume that there exists a version file already
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-config-version.cmake
DESTINATION share/cmake${${name}_VER_DIR}/${${name}_NAME}
)
# find-mode .pc file; use this to locate system installation
configure_pc_file (
${name}
${template_dir}/opm-project.pc.in
${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
${CMAKE_INSTALL_PREFIX}
${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${name}_VER_DIR}
${CMAKE_INSTALL_PREFIX}/include${${name}_VER_DIR}
)
# put this in the right system location; if we have binaries then it
# should go in the arch-specific lib/ directory, otherwise use the
# common/noarch lib/ directory (these targets come from UseMultiArch)
if (${name}_TARGET)
set (_pkg_dir ${CMAKE_INSTALL_LIBDIR})
else ()
set (_pkg_dir ${LIBDIR_MULTIARCH_UNAWARE})
endif ()
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${_pkg_dir}/pkgconfig${${name}_VER_DIR}/
RENAME ${${name}_NAME}.pc
)
endfunction (opm_cmake_config name)

View File

@ -0,0 +1,159 @@
# - Build satellites that are dependent of main library
#
# Enumerate all source code in a "satellite" directory such as tests/,
# compile each of them and optionally set them as a test for CTest to
# run. They will be linked to the main library created by the project.
#
# The following suffices must be defined for the opm prefix passed as
# parameter:
#
# _LINKER_FLAGS Necessary flags to link with this library
# _TARGET CMake target which creates the library
# _LIBRARIES Other dependencies that must also be linked
# Synopsis:
# opm_compile_satellites (opm satellite excl_all test_regexp)
#
# Parameters:
# opm Prefix of the variable which contain information
# about the library these satellites depends on, e.g.
# pass "opm-core" if opm-core_TARGET is the name of
# the target the builds this library. Variables with
# suffixes _TARGET and _LIBRARIES must exist.
#
# satellite Prefix of variable which contain the names of the
# files, e.g. pass "tests" if the files are in the
# variable tests_SOURCES. Variables with suffixes
# _DATAFILES, _SOURCES and _DIR should exist. This
# name is also used as name of the target that builds
# all these files.
#
# excl_all EXCLUDE_FROM_ALL if these targets should not be built by
# default, otherwise empty string.
#
# test_regexp Regular expression which picks the name of a test
# out of the filename, or blank if no test should be
# setup.
#
# Example:
# opm_compile_satellites (opm-core test "" "^test_([^/]*)$")
#
macro (opm_compile_satellites opm satellite excl_all test_regexp)
# if we are going to build the tests always, then make sure that
# the datafiles are present too
if (NOT (${excl_all} MATCHES "EXCLUDE_FROM_ALL"))
set (_incl_all "ALL")
else (NOT (${excl_all} MATCHES "EXCLUDE_FROM_ALL"))
set (_incl_all "")
endif (NOT (${excl_all} MATCHES "EXCLUDE_FROM_ALL"))
# if a set of datafiles has been setup, pull those in
add_custom_target (${satellite} ${_incl_all})
if (${satellite}_DATAFILES)
add_dependencies (${satellite} ${${satellite}_DATAFILES})
endif (${satellite}_DATAFILES)
# compile each of these separately
foreach (_sat_FILE IN LISTS ${satellite}_SOURCES)
get_filename_component (_sat_NAME "${_sat_FILE}" NAME_WE)
add_executable (${_sat_NAME} ${excl_all} ${_sat_FILE})
add_dependencies (${satellite} ${_sat_NAME})
set_target_properties (${_sat_NAME} PROPERTIES
LINK_FLAGS "${${opm}_LINKER_FLAGS_STR}"
)
# are we building a test? luckily, the testing framework doesn't
# require anything else, so we don't have to figure out where it
# should go in the library list
if (NOT "${test_regexp}" STREQUAL "")
set (_test_lib "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}")
else (NOT "${test_regexp}" STREQUAL "")
set (_test_lib "")
endif (NOT "${test_regexp}" STREQUAL "")
target_link_libraries (${_sat_NAME} ${${opm}_TARGET} ${${opm}_LIBRARIES} ${_test_lib})
if (STRIP_DEBUGGING_SYMBOLS)
strip_debug_symbols (${_sat_NAME} _sat_DEBUG)
list (APPEND ${satellite}_DEBUG ${_sat_DEBUG})
endif()
# variable with regular expression doubles as a flag for
# whether tests should be setup or not
if (NOT "${test_regexp}" STREQUAL "")
foreach (_regexp IN ITEMS ${test_regexp})
if ("${_sat_NAME}" MATCHES "${_regexp}")
string (REGEX REPLACE "${_regexp}" "\\1" _sat_FANCY "${_sat_NAME}")
endif ("${_sat_NAME}" MATCHES "${_regexp}")
endforeach (_regexp)
get_target_property (_sat_LOC ${_sat_NAME} LOCATION)
if (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (
NAME ${_sat_FANCY}
COMMAND ${CMAKE_COMMAND} -E chdir "${PROJECT_BINARY_DIR}/${${satellite}_DIR}" ${_sat_LOC}
)
else (CMAKE_VERSION VERSION_LESS "2.8.4")
add_test (${_sat_FANCY} ${_sat_LOC})
# run the test in the directory where the data files are
set_tests_properties (${_sat_FANCY} PROPERTIES
WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/${${satellite}_DIR}
)
endif (CMAKE_VERSION VERSION_LESS "2.8.4")
endif(NOT "${test_regexp}" STREQUAL "")
# if this program on the list of files that should be distributed?
# we check by the name of the source file
list (FIND ${satellite}_SOURCES_DIST "${_sat_FILE}" _is_util)
if (NOT (_is_util EQUAL -1))
install (TARGETS ${_sat_NAME} RUNTIME
DESTINATION bin${${opm}_VER_DIR}/
)
endif (NOT (_is_util EQUAL -1))
endforeach (_sat_FILE)
endmacro (opm_compile_satellites opm prefix)
# Synopsis:
# opm_data (satellite target dirname files)
#
# provides these output variables:
#
# ${satellite}_INPUT_FILES List of all files that are copied
# ${satellite}_DATAFILES Name of target which copies these files
#
# Example:
#
# opm_data (tests datafiles "tests/")
#
macro (opm_data satellite target dirname)
# even if there are no datafiles, create the directory so the
# satellite programs have a homedir to run in
execute_process (
COMMAND ${CMAKE_COMMAND} -E make_directory ${dirname}
)
# if ever huge test datafiles are necessary, then change this
# into "create_symlink" (on UNIX only, apparently)
set (make_avail "copy")
# provide datafiles as inputs for the tests, by copying them
# to a tests/ directory in the output tree (if different)
set (${satellite}_INPUT_FILES)
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
foreach (input_datafile IN LISTS ${satellite}_DATA)
file (RELATIVE_PATH rel_datafile "${PROJECT_SOURCE_DIR}" ${input_datafile})
set (output_datafile "${PROJECT_BINARY_DIR}/${rel_datafile}")
add_custom_command (
OUTPUT ${output_datafile}
COMMAND ${CMAKE_COMMAND}
ARGS -E ${make_avail} ${input_datafile} ${output_datafile}
DEPENDS ${input_datafile}
VERBATIM
)
list (APPEND ${satellite}_INPUT_FILES "${output_datafile}")
endforeach (input_datafile)
endif(NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# setup a target which does all the copying
set (${satellite}_DATAFILES "${target}")
add_custom_target (${${satellite}_DATAFILES}
DEPENDS ${${satellite}_INPUT_FILES}
COMMENT "Making \"${satellite}\" data available in output tree"
)
endmacro (opm_data satellite target dirname files)

View File

@ -0,0 +1,108 @@
# - Get compiler version
# probe the GCC version, returns empty string if GCC is not compiler
function (get_gcc_version language ver_name)
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
# exec_program is deprecated, but execute_process does't work :-(
exec_program (${CMAKE_${language}_COMPILER}
ARGS ${CMAKE_${language}_COMPILER_ARG1} -dumpversion
OUTPUT_VARIABLE _version
)
set (${ver_name} ${_version} PARENT_SCOPE)
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
set (${ver_name} "" PARENT_SCOPE)
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
endfunction (get_gcc_version ver_name)
# less reliable, but includes the patch number
function (get_gcc_patch language ver_name)
if(CMAKE_${language}_COMPILER_ID STREQUAL GNU)
# exec_program is deprecated, but execute_process does't work :-(
exec_program (${CMAKE_${language}_COMPILER}
ARGS ${CMAKE_${language}_COMPILER_ARG1} --version
OUTPUT_VARIABLE _version
)
# split multi-line string into list
if (WIN32)
string (REPLACE "\r\n" ";" _version "${_version}")
else (WIN32)
string (REPLACE "\n" ";" _version "${_version}")
endif (WIN32)
# only keep first line
list (GET _version 0 _version)
# extract version number from it (this is the fragile part)
string (REGEX REPLACE "^[^\\(]+(\\([^\\)]*\\))?[\ \t]*([0-9]+\\.[0-9]+\\.[0-9]+)(.*\\(.*\\))?" "\\2" _version "${_version}")
# return this to the caller
set (${ver_name} ${_version} PARENT_SCOPE)
else (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
set (${ver_name} "" PARENT_SCOPE)
endif (CMAKE_${language}_COMPILER_ID STREQUAL GNU)
endfunction (get_gcc_patch language ver_name)
function (compiler_info)
if (CMAKE_COMPILER_IS_GNUCXX)
get_gcc_patch (CXX version)
message (STATUS "GNU C++ compiler version: ${version}")
endif (CMAKE_COMPILER_IS_GNUCXX)
endfunction (compiler_info)
function (get_ld_version ver_name)
# run linker to get the version number. interestingly, this option works
# (for our purposes) on all major platforms (Linux, Mac OS X and Windows);
# it returns the program version although it may have ended in error
exec_program (${CMAKE_LINKER}
ARGS "-v"
OUTPUT_VARIABLE _version
)
# keep only first line, even on Mac OS X there is no line end
list (GET _version 0 _version)
# format of the version string is platform-specific
if (NOT WIN32)
if (APPLE)
string (REGEX REPLACE ".*, from Apple (.*\)" "\\1" _version "${_version}")
else (APPLE)
# assuming some GNU toolchain now
string (REGEX REPLACE "GNU ([a-zA-Z0-9_]*) (version|\\(.*\\)) ([^\\ ]*).*" "\\1 \\3" _version "${_version}")
endif (APPLE)
endif (NOT WIN32)
# return the string to the caller
set (${ver_name} "${_version}" PARENT_SCOPE)
endfunction (get_ld_version ver_name)
function (linker_info)
get_ld_version (version)
message (STATUS "Linker: ${version}")
endfunction (linker_info)
# sets CXX_COMPAT_GCC if we have either GCC or Clang
macro (is_compiler_gcc_compatible)
# is the C++ compiler clang++?
string (TOUPPER "${CMAKE_CXX_COMPILER_ID}" _comp_id)
if (_comp_id MATCHES "CLANG")
set (CMAKE_COMPILER_IS_CLANGXX TRUE)
else ()
set (CMAKE_COMPILER_IS_CLANGXX FALSE)
endif ()
# is the C++ compiler g++ or clang++?
if (CMAKE_COMPILER_IS_GNUCXX OR CMAKE_COMPILER_IS_CLANGXX)
set (CXX_COMPAT_GCC TRUE)
else ()
set (CXX_COMPAT_GCC FALSE)
endif ()
# is the C compiler clang?
string (TOUPPER "${CMAKE_C_COMPILER_ID}" _comp_id)
if (_comp_id MATCHES "CLANG")
set (CMAKE_COMPILER_IS_CLANG TRUE)
else ()
set (CMAKE_COMPILER_IS_CLANG FALSE)
endif ()
# is the C compiler gcc or clang?
if (CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_CLANG)
set (C_COMPAT_GCC TRUE)
else ()
set (C_COMPAT_GCC FALSE)
endif ()
endmacro (is_compiler_gcc_compatible)

View File

@ -0,0 +1,132 @@
# - Generate debug symbols in a separate file
#
# (1) Include this file in your CMakeLists.txt; it will setup everything
# to compile WITH debug symbols in any case.
#
# (2) Run the strip_debug_symbols function on every target that you want
# to strip.
# Copyright (C) 2012 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
# only debugging using the GNU toolchain is supported for now
if (CXX_COMPAT_GCC)
# default debug level, if not specified by the user
set_default_option (CXX _dbg_flag "-ggdb3" "(^|\ )-g")
# add debug symbols to *all* targets if the build mode is either "Debug" or "RelWithDebInfo"
if (_dbg_flag)
message (STATUS "Generating debug symbols: ${_dbg_flag}")
add_options (ALL_LANGUAGES "Debug;RelWithDebInfo" "${_dbg_flag}")
endif (_dbg_flag)
# extracting the debug info is done by a separate utility in the GNU
# toolchain. check that this is actually installed.
message (STATUS "Looking for strip utility")
if (APPLE)
# MacOS X has a duo of utilities; we need both
find_program (OBJCOPY strip)
find_program (DSYMUTIL dsymutil)
mark_as_advanced (DSYMUTIL)
if (NOT DSYMUTIL)
set (OBJCOPY dsymutil-NOTFOUND)
endif (NOT DSYMUTIL)
else (APPLE)
find_program (OBJCOPY
objcopy
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
)
endif (APPLE)
mark_as_advanced (OBJCOPY)
if (OBJCOPY)
message (STATUS "Looking for strip utility - found")
else (OBJCOPY)
message (WARNING "Looking for strip utility - not found")
endif (OBJCOPY)
endif ()
# command to separate the debug information from the executable into
# its own file; this must be called for each target; optionally takes
# the name of a variable to receive the list of .debug files
function (strip_debug_symbols targets)
if (CXX_COMPAT_GCC AND OBJCOPY)
foreach (target IN LISTS targets)
# libraries must retain the symbols in order to link to them, but
# everything can be stripped in an executable
get_target_property (_kind ${target} TYPE)
# don't strip static libraries
if ("${_kind}" STREQUAL "STATIC_LIBRARY")
return ()
endif ("${_kind}" STREQUAL "STATIC_LIBRARY")
# don't strip public symbols in shared objects
if ("${_kind}" STREQUAL "EXECUTABLE")
set (_strip_args "--strip-all")
else ("${_kind}" STREQUAL "EXECUTABLE")
set (_strip_args "--strip-debug")
endif ("${_kind}" STREQUAL "EXECUTABLE")
# add_custom_command doesn't support generator expressions in the
# working_directory argument (sic; that's what you get when you do
# ad hoc programming all the time), so we need to extract the
# location up front (the location on the other hand should not be
# used for libraries as it does not include the soversion -- sic
# again)
get_target_property (_full ${target} LOCATION)
get_filename_component (_dir ${_full} PATH)
if (NOT (("${_dir}" STREQUAL "") OR ("${_dir}" MATCHES ".*/$")))
set (_dir "${_dir}/")
endif (NOT (("${_dir}" STREQUAL "") OR ("${_dir}" MATCHES ".*/$")))
get_filename_component (_name ${_full} NAME_WE)
get_filename_component (_ext ${_full} EXT)
# only libraries have soversion property attached
get_target_property (_target_soversion ${target} SOVERSION)
get_target_property (_target_version ${target} VERSION)
if (_target_soversion)
# MacOS X puts the version number before the extension
if (APPLE)
set (_target_file_name "${_name}.${_target_version}${_ext}")
else (APPLE)
set (_target_file_name "${_name}${_ext}.${_target_version}")
endif (APPLE)
else (_target_soversion)
set (_target_file_name "${_name}${_ext}")
endif (_target_soversion)
set (_target_file "${_dir}${_target_file_name}")
# do without generator expressions (which doesn't work everywhere)
if (APPLE)
set (_debug_ext ".dSYM")
add_custom_command (TARGET ${target}
POST_BUILD
WORKING_DIRECTORY ${_dir}
COMMAND ${DSYMUTIL} ARGS --out=${_target_file}${_debug_ext} ${_target_file}
COMMAND ${OBJCOPY} ARGS -S ${_target_file}
VERBATIM
)
else (APPLE)
set (_debug_ext ".debug")
add_custom_command (TARGET ${target}
POST_BUILD
WORKING_DIRECTORY ${_dir}
COMMAND ${OBJCOPY} ARGS --only-keep-debug ${_target_file} ${_target_file}${_debug_ext}
COMMAND ${OBJCOPY} ARGS ${_strip_args} ${_target_file}
COMMAND ${OBJCOPY} ARGS --add-gnu-debuglink=${_target_file_name}${_debug_ext} ${_target_file}
VERBATIM
)
endif (APPLE)
# add this .debug file to the list
file (RELATIVE_PATH _this_debug_file "${PROJECT_BINARY_DIR}" "${_target_file}${_debug_ext}")
set (_debug_files ${_debug_files} ${_this_debug_file})
endforeach (target)
# if optional debug list was requested, then copy to output parameter
if (ARGV1)
set (${ARGV1} ${_debug_files} PARENT_SCOPE)
endif (ARGV1)
endif ()
endfunction (strip_debug_symbols targets)

View File

@ -0,0 +1,152 @@
# - Find version of a DUNE package
#
# Synopsis:
#
# find_dune_version (suite module)
#
# where:
# suite Name of the suite; this should always be "dune"
# module Name of the module, e.g. "common"
#
# Finds the content of DUNE_${MODULE}_VERSION_{MAJOR,MINOR,REVISION}
# from the installation.
#
# Add these variables to ${project}_CONFIG_IMPL_VARS in CMakeLists.txt
# if you need these in the code.
include (UseMultiArch)
function (find_dune_version suite module)
# the _ROOT variable may or may not be set, but the include
# variable should always be; get the prefix from the header path
# if we have a multilib installation where the package maintainer
# have installed it in e.g. /usr/include/dune-2.2/dune/istl, then
# stash this extra indirection and add it back later in lib/
set (_inc_path "${${suite}-${module}_INCLUDE_DIR}")
file (TO_CMAKE_PATH _inc_path "${_inc_path}")
set (_multilib_regexp "(.*)/include(/${suite}[^/]+)?")
if (_inc_path MATCHES "${_multilib_regexp}")
set (_orig_inc "${_inc_path}")
string (REGEX REPLACE "${_multilib_regexp}" "\\1" _inc_path "${_orig_inc}")
# only get the second group if it is really there (there is
# probably a better way to do this in CMake)
if ("${_inc_path}/include" STREQUAL "${_orig_inc}")
set (_multilib "")
else ()
string (REGEX REPLACE "${_multilib_regexp}" "\\2" _multilib "${_orig_inc}")
endif ()
else ()
set (_multilib "")
endif ()
# some modules does not have a library, use the directory of the
# header files to find what would be the library dir.
# note that when we refer to a build tree, then the libraries always
# go into lib/, but we don't care about that because in that case,
# dune.module isn't in the lib/ directory anyway but must be retrieved
# from the source. hence, we only have to worry about the library
# directory of a system installation here.
if (NOT ${suite}-${module}_LIBRARY)
# this suffix is gotten from UseMultiArch.cmake
set (_lib_path "${_inc_path}/${CMAKE_INSTALL_LIBDIR}")
else ()
get_filename_component (_lib_path "${${suite}-${module}_LIBRARY}" PATH)
endif ()
# if we have a source tree, dune.module is available there
set (_dune_mod "${_inc_path}/dune.module")
if (NOT EXISTS "${_dune_mod}")
set (_last_dune_mod_src "${_dune_mod}")
set (_dune_mod "")
endif ()
if (NOT _dune_mod)
# look for the build tree; if we found the library, then the
# dune.module file should be in a sub-directory
get_filename_component (_immediate "${_lib_path}" NAME)
if ("${_immediate}" STREQUAL ".libs")
# remove autotools internal path
get_filename_component (_lib_path "${_lib_path}" PATH)
endif ()
get_filename_component (_immediate "${_lib_path}" NAME)
if ("${_immediate}" STREQUAL "${CMAKE_LIBRARY_ARCHITECTURE}")
# remove multi-arch part of the library path to get parent
get_filename_component (_lib_path "${_lib_path}" PATH)
endif ()
get_filename_component (_immediate "${_lib_path}" NAME)
if (("${_immediate}" STREQUAL "${CMAKE_INSTALL_LIBDIR}")
OR ("${_immediate}" STREQUAL "lib")
OR ("${_immediate}" STREQUAL "${LIBDIR_MULTIARCH_UNAWARE}"))
# remove library part of the path; this also undo the suffix
# we added if we used the library as a standin
get_filename_component (_lib_path "${_lib_path}" PATH)
endif ()
# from this point on, _lib_path does not contain an architecture-
# specific component anymore; dune.module is always put in straight
# noarch lib/ since it does not contain any paths to binaries
set (_suffix "${_multilib}/dunecontrol/${suite}-${module}/dune.module")
set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_suffix}")
if (NOT EXISTS "${_dune_mod}")
set (_last_dune_mod_bld "${_dune_mod}")
# one more try, if we have a private install, then it doesn't use
# e.g. lib64 but always lib (!)
if ("${LIBDIR_MULTIARCH_UNAWARE}" STREQUAL "lib")
set (_dune_mod "")
else ()
set (_dune_mod "${_lib_path}/lib${_suffix}")
if (NOT EXISTS "${_dune_mod}")
set (_last_dune_mod_pri "${_dune_mod}")
# use the name itself as a flag for whether it was found or not
set (_dune_mod "")
endif ()
endif ()
endif ()
endif ()
# if it is not available, it may make havoc having empty defines in the source
# code later, so we bail out early
if (NOT _dune_mod)
if (${suite}-${module}_FOUND)
set (_searched_paths "\"${_last_dune_mod_src}\"")
if (NOT ("${_last_dune_mod_bld}" STREQUAL ""))
set (_searched_paths "either ${_searched_paths} or \"${_last_dune_mod_bld}\"")
endif ()
if (NOT ("${_last_dune_mod_pri}" STREQUAL ""))
set (_searched_paths "${_searched_paths} or \"${_last_dune_mod_pri}\"")
endif ()
message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module} (looking for ${_searched_paths})")
else ()
return ()
endif ()
endif ()
# parse the file for the Version: field
set (_ver_regexp "[ ]*Version:[ ]*([0-9]+)\\.([0-9]+)(.*)")
file (STRINGS "${_dune_mod}" _ver_field REGEX "${_ver_regexp}")
string (REGEX REPLACE "${_ver_regexp}" "\\1" _major "${_ver_field}")
string (REGEX REPLACE "${_ver_regexp}" "\\2" _minor "${_ver_field}")
string (REGEX REPLACE "${_ver_regexp}" "\\3" _revision "${_ver_field}")
# revision may or may not be there
set (_rev_regexp "\\.([0-9]+).*")
if (_revision MATCHES "${_rev_regexp}")
string (REGEX REPLACE "${_rev_regexp}" "\\1" _revision "${_revision}")
else ()
set (_revision "0")
endif ()
# generate variable for what we have found
string (TOUPPER "${suite}" _SUITE)
string (TOUPPER "${module}" _MODULE)
string (REPLACE "-" "_" _MODULE "${_MODULE}")
if ((NOT DEFINED ${_SUITE}_${_MODULE}_VERSION_MAJOR) AND
(NOT DEFINED ${_SUITE}_${_MODULE}_VERSION_MINOR) AND
(NOT DEFINED ${_SUITE}_${_MODULE}_VERSION_REVISION))
set (${_SUITE}_${_MODULE}_VERSION_MAJOR "${_major}" PARENT_SCOPE)
set (${_SUITE}_${_MODULE}_VERSION_MINOR "${_minor}" PARENT_SCOPE)
set (${_SUITE}_${_MODULE}_VERSION_REVISION "${_revision}" PARENT_SCOPE)
endif ()
# print the version number we detected in the configuration log
message (STATUS "Version ${_major}.${_minor}.${_revision} of ${suite}-${module} from ${_dune_mod}")
endfunction (find_dune_version suite module)

View File

@ -0,0 +1,37 @@
if (NOT ${Boost_UNIT_TEST_FRAMEWORK_FOUND})
find_package (Boost 1.44.0 COMPONENTS unit_test_framework QUIET)
endif ()
if (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# setup to do a test compile
include (CMakePushCheckState)
cmake_push_check_state ()
include (CheckCXXSourceCompiles)
list (APPEND CMAKE_REQUIRED_INCLUDES ${Boost_INCLUDE_DIRS})
list (APPEND CMAKE_REQUIRED_LIBRARIES ${Boost_LIBRARIES})
check_cxx_source_compiles("
#define BOOST_TEST_DYN_LINK
#define BOOST_TEST_MODULE DYNLINK_TEST
#include <boost/test/unit_test.hpp>
int f(int x) { return 2 * x; }
BOOST_AUTO_TEST_CASE(DynlinkConfigureTest) {
BOOST_CHECK_MESSAGE(f(2) == 4,
\"Apparently, multiplication doesn't \"
\"work: f(2) = \" << f(2));
}" HAVE_DYNAMIC_BOOST_TEST)
cmake_pop_check_state ()
else (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# no Boost, no compile
set (HAVE_DYNAMIC_BOOST_TEST 0)
endif (${Boost_UNIT_TEST_FRAMEWORK_FOUND})
# save this for later
set (HAVE_DYNAMIC_BOOST_TEST "${HAVE_DYNAMIC_BOOST_TEST}"
CACHE BOOL "Whether Boost::Test is dynamically linked or not"
)
# include in config.h
list (APPEND TESTING_CONFIG_VARS "HAVE_DYNAMIC_BOOST_TEST")

View File

@ -0,0 +1,11 @@
# - Try to build faster depending on the compiler
# faster builds by using a pipe instead of temp files
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
if (CXX_COMPAT_GCC)
add_options (ALL_LANGUAGES ALL_BUILDS "-pipe")
endif ()

View File

@ -0,0 +1,90 @@
# - Provide C wrappers for Fortran code
#
# Synopsis:
# define_fc_func (APPEND config.h IF HAVE_BLAS)
function (define_fc_func verb file)
# check that we are being called correctly
if (NOT (("${verb}" STREQUAL "APPEND") OR
("${verb}" STREQUAL "WRITE")))
message (FATAL_ERROR
"Unknown verb \"${verb}\" passed as first argument."
)
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 (needed)
# if this option is enabled, we skip detecting the Fortran externals
# using a real compiler (which may not be the same that compiled the
# library) and just write a macro that uses a single underscore (which
# is the assumption that FindLAPACK operates on anyway)
option (USE_UNDERSCORING "Assume that Fortran routines have underscore suffix" OFF)
if (USE_UNDERSCORING)
message (STATUS "Assuming Fortran externals have underscore suffix")
set (_str "#define FC_FUNC(name,NAME) name##_\n")
else (USE_UNDERSCORING)
# 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)
# write a small config file that contains the proper convention for
# calling Fortran from C
include (FortranCInterface)
fortrancinterface_header (${_tmp_hdr})
# read the definition back in from the file
file (STRINGS
${_tmp_hdr}
_str
REGEX "^#define FortranCInterface_GLOBAL\\(name,NAME\\) .*$"
)
# massage it to look like the one AC_FC_WRAPPERS provide
string (REPLACE "FortranCInterface_GLOBAL" "FC_FUNC" _str ${_str})
endif (USE_UNDERSCORING)
# write this definition to the end of our own configuration file
file (${verb} ${file}
"\n/* Define to a macro mangling the given C identifier (in lower and upper
case), which must not contain underscores, for linking with Fortran. */\n"
${_str}
"\n"
)
else (needed)
message (STATUS "Fortran/C interface not activated")
endif (needed)
endfunction (define_fc_func)

View File

@ -0,0 +1,35 @@
# - Multiarch support in object code library directories
#
# This module sets the following variable
# CMAKE_INSTALL_LIBDIR to lib, lib64 or lib/x86_64-linux-gnu
# depending on the platform; use this path
# for platform-specific binaries.
#
# Note that it will override the results of GNUInstallDirs if included after
# that module.
# default if we need to put something in the library directory for a
# component that is *not* multiarch-aware
set (LIBDIR_MULTIARCH_UNAWARE "lib")
# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# Debian or Ubuntu?
if (EXISTS "/etc/debian_version")
set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
else (EXISTS "/etc/debian_version")
# 64-bit system?
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_def "lib64")
set (LIBDIR_MULTIARCH_UNAWARE "${_libdir_def}")
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_def "lib")
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
endif (EXISTS "/etc/debian_version")
else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set (_libdir_def "lib")
endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# let the user override if somewhere else is desirable
set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries")
mark_as_advanced (CMAKE_INSTALL_LIBDIR)

View File

@ -0,0 +1,50 @@
# - Use only needed imports from libraries
#
# Add the -Wl,--as-needed flag to the default linker flags on Linux
# in order to get only the minimal set of dependencies.
function (prepend var_name value)
# only add the prefix if it is not already at the beginning. this
# prevents the same string to be added at the same place every time
# we check for reconfiguration (e.g. "--as-needed" below)
string (LENGTH "${value}" _val_len)
string (LENGTH "${${var_name}}" _var_len)
if (NOT (${_var_len} LESS ${_val_len}))
string (SUBSTRING "${${var_name}}" 0 ${_val_len} _var_pre)
else (NOT (${_var_len} LESS ${_val_len}))
set (_var_pre)
endif (NOT (${_var_len} LESS ${_val_len}))
if (NOT ("${_var_pre}" STREQUAL "${value}"))
if (${var_name})
set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE)
else (${var_name})
set (${var_name} "${value}")
endif (${var_name})
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 AND ONLY_NEEDED_LIBRARIES)
# these are the modules whose probes will turn up incompatible
# flags on some systems
set (_maybe_underlinked
SuiteSparse
)
# check if any modules actually reported problems (by setting an
# appropriate linker flag)
set (_underlinked FALSE)
foreach (_module IN LISTS _maybe_underlinked)
if ("${${_module}_LINKER_FLAGS}" MATCHES "-Wl,--no-as-needed")
set (_underlinked TRUE)
endif ("${${_module}_LINKER_FLAGS}" MATCHES "-Wl,--no-as-needed")
endforeach (_module)
# if we didn't have any problems, then go ahead and add
if (NOT _underlinked)
prepend (CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed")
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 AND ONLY_NEEDED_LIBRARIES)

View File

@ -0,0 +1,70 @@
# - Use OpenMP features
#
# Synopsis:
#
# find_openmp (module)
#
# where:
#
# module Name of the module to which OpenMP libraries
# etc. should be added, e.g. "opm-core".
#
# Note: Compiler flags are always added globally, to avoid ABI
# incompatibility problems.
#
# It is assumed that the following variables are available
#
# ${module}_QUIET Verbosity level of the parent's find module
# ${module}_LIBRARIES List of libraries to which OpenMP will be added
#
# Example:
# find_openmp (opm-core)
# remove_dup_deps (opm-core)
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
macro (find_openmp opm)
# default is that OpenMP is not considered to be there; if we set this
# to a blank definition, it may be added but it cannot be removed if
# it propagates to other projects (someone declares it to be part of
# _CONFIG_VARS)
set (HAVE_OPENMP)
# user code can be conservative by setting USE_OPENMP_DEFAULT
if (NOT DEFINED USE_OPENMP_DEFAULT)
set (USE_OPENMP_DEFAULT ON)
endif (NOT DEFINED USE_OPENMP_DEFAULT)
option (USE_OPENMP "Enable OpenMP for parallelization" ${USE_OPENMP_DEFAULT})
if (USE_OPENMP)
# enabling OpenMP is supposedly enough to make the compiler link with
# the appropriate libraries
find_package (OpenMP ${${opm}_QUIET})
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
if (OPENMP_FOUND)
add_options (C ALL_BUILDS "${OpenMP_C_FLAGS}")
add_options (CXX ALL_BUILDS "${OpenMP_CXX_FLAGS}")
set (HAVE_OPENMP 1)
endif (OPENMP_FOUND)
# threading library (search for this *after* OpenMP
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads ${${opm}_QUIET})
if (CMAKE_USE_PTHREADS_INIT)
list (APPEND ${opm}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif (CMAKE_USE_PTHREADS_INIT)
else (USE_OPENMP)
message (STATUS "OpenMP: disabled")
# if we don't have OpenMP support, then don't show warnings that these
# pragmas are unknown
if (CXX_COMPAT_GCC)
add_options (ALL_LANGUAGES ALL_BUILDS "-Wno-unknown-pragmas")
elseif (MSVC)
add_options (ALL_LANGUAGES ALL_BUILDS "-wd4068")
endif()
endif (USE_OPENMP)
endmacro (find_openmp opm)

View File

@ -0,0 +1,64 @@
# - Turn on optimizations based on build type
include(TestCXXAcceptsFlag)
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
# mapping from profile name (in CMAKE_BUILD_TYPE) to variable part
set (_prof_DEBUG "Debug")
set (_prof_RELEASE "Release;RelWithDebInfo;MinSizeRel")
# if we are building a debug target, then disable all optimizations
# otherwise, turn them on. indicate to the code what we have done
# so it can turn on assertions etc.
if (CXX_COMPAT_GCC)
# extra flags passed for optimization
set (_opt_flags "")
# link-time (a.k.a. global) optimizations
# disabled due to widespread bugs in the linker plugin
option (WHOLE_PROG_OPTIM "Whole program optimization (lto)" OFF)
if (WHOLE_PROG_OPTIM)
check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS)
if (HAVE_LINK_OPTS)
list (APPEND _opt_flags "-flto")
endif (HAVE_LINK_OPTS)
endif (WHOLE_PROG_OPTIM)
# native instruction set tuning
option (WITH_NATIVE "Use native instruction set" ON)
if (WITH_NATIVE)
check_cxx_accepts_flag ("-mtune=native" HAVE_MTUNE)
if (HAVE_MTUNE)
list (APPEND _opt_flags "-mtune=native")
endif (HAVE_MTUNE)
endif (WITH_NATIVE)
# default optimization flags, if not set by user
set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O")
set_default_option (CXX _opt_rel "-O2" "(^|\ )-O")
# use these options for debug builds - no optimizations
add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG")
# use these options for release builds - full optimization
add_options (ALL_LANGUAGES "${_prof_RELEASE}" ${_opt_rel} "-DNDEBUG" ${_opt_flags})
else ()
# default information from system
foreach (lang IN ITEMS C CXX Fortran)
if (lang STREQUAL "Fortran")
set (_lang F)
else (lang STREQUAL "Fortran")
set (_lang ${lang})
endif (lang STREQUAL "Fortran")
foreach (profile IN ITEMS DEBUG RELEASE)
if (NOT CMAKE_${lang}_FLAGS_${profile})
add_options (${lang} "${_prof_${profile}}"
"$ENV{${_lang}FLAGS} ${CMAKE_${lang}_FLAGS_${profile}_INIT}")
endif (NOT CMAKE_${lang}_FLAGS_${profile})
endforeach (profile)
endforeach (lang)
endif ()

View File

@ -0,0 +1,171 @@
# - Use precompiled headers
#
# precompile_header takes these parameters
#
# language Language in which the header is written; C or CXX.
#
# type Type of target being build, SHARED_LIBRARY, STATIC_LIBRARY
# or EXECUTABLE.
#
# header Relative path within the source tree to the header
# that contains the list of includes to be precompiled.
# This header should not be added to the installation,
# as it will be specific for this project.
#
# target Name of target to be created. All targets that
# use the precompiled header should depend on this target
# so that it is built before them. A variable with this
# name will also be created which contains the file name.
#
# flags_name Name of variable to receive the flags that should be
# added to the command-line.
#
# Example:
# get_target_property (type opmcore TYPE)
# precompile_header (CXX ${type}
# HEADER "opm/core/opm-core-pch.hpp"
# TARGET opmcore_CXX_pch
# FLAGS opmcore_PRECOMP_CXX_FLAGS
# )
# set_source_files_properties (${opmcore_CXX_SOURCES} PROPERTIES
# OBJECT_DEPENDS "${opmcore_CXX_pch}"
# COMPILE_FLAGS "${opmcore_PRECOMP_CXX_FLAGS}"
# )
# get compiler version
include (UseCompVer)
is_compiler_gcc_compatible ()
# reconstruct the compiler command line; this does NOT include the
# DEFINE_SYMBOL that is added for shared libraries. type is the TYPE
# target property.
# see larsch's PrecompiledHeader.cmake: <https://gist.github.com/573926>
# and <https://github.com/loaden/qtcreator/blob/wip/cmake/cmake/PrecompiledHeader.cmake>
function (compiler_cmdline language type cmd_name args_name)
# get the compiler for this particular language
set (${cmd_name} "${CMAKE_${language}_COMPILER}" PARENT_SCOPE)
# in case someone has overridden the compiler (e.g. ccache)
set (_args "${CMAKE_${language}_COMPILER_ARG1}")
# macro definitions
get_directory_property (_defs DEFINITIONS)
list (APPEND _args "${_defs}")
# global flags (such as -std=c++11); notice that there are both
# release-dependent and non-release-dependent ones
string (TOUPPER "CMAKE_${language}_FLAGS" _flags)
list (APPEND _args "${${_flags}}")
string (TOUPPER "CMAKE_${language}_FLAGS_${CMAKE_BUILD_TYPE}" _flags)
list (APPEND _args "${${_flags}}")
# assume that we are always generating position-independent code
# when compiling for a shared library
if (type STREQUAL "SHARED_LIBRARY")
list (APPEND _args "${CMAKE_SHARED_LIBRARY_${language}_FLAGS}")
endif (type STREQUAL "SHARED_LIBRARY")
# directories included
get_directory_property (_dirs INCLUDE_DIRECTORIES)
foreach (_dir ${_dirs})
list (APPEND _args "-I${_dir}")
endforeach (_dir)
# make arguments a real list, and write to output variable
separate_arguments (_args)
set (${args_name} "${_args}" PARENT_SCOPE)
endfunction (compiler_cmdline language type cmd_name args_name)
function (precompile_header
language type hdr_kw header tgt_kw target flgs_kw flags_name)
# check "syntax"
if (NOT hdr_kw STREQUAL "HEADER")
message (FATAL "Third token to precompile_header shoulde be \"HEADER\"")
endif (NOT hdr_kw STREQUAL "HEADER")
if (NOT tgt_kw STREQUAL "TARGET")
message (FATAL "Fifth token to precompile_header should be \"TARGET\"")
endif (NOT tgt_kw STREQUAL "TARGET")
if (NOT flgs_kw STREQUAL "FLAGS")
message (FATAL "Seventh token to precompile_header should be \"FLAGS\"")
endif (NOT flgs_kw STREQUAL "FLAGS")
# check language
if (language STREQUAL "CXX")
set (gcc_lang "c++-header")
elseif (language STREQUAL "C")
set (gcc_lang "c-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 or clang
if (CXX_COMPAT_GCC)
if (CMAKE_COMPILER_IS_GNUCXX)
# genuine GCC; must test version
get_gcc_version (${language} GCC_VERSION)
if (GCC_VERSION VERSION_EQUAL 3.4 OR GCC_VERSION VERSION_GREATER 3.4)
set (_do_pch TRUE)
else ()
set (_do_pch FALSE)
endif ()
elseif (CMAKE_COMPILER_IS_CLANGXX)
# any Clang version that is new enough to compile us can do this
set (_do_pch TRUE)
else ()
set (_do_pch FALSE)
endif ()
if (_do_pch)
# command-line used to compile modules in this kind of target
compiler_cmdline (${language} ${type} _cmd _args)
# gcc will include any configurations which are in a directory
# with the same name as the header included
set (_pch_dir "CMakeFiles/pch")
set (_pch_file "${_pch_dir}/${header}.gch/${target}")
# make sure that output directory exists
get_filename_component (_outdir "${PROJECT_BINARY_DIR}/${_pch_file}" PATH)
file (MAKE_DIRECTORY ${_outdir})
# we need to generate the precompiled header in the output tree, but
# at the same time prevent the compiler to pick up the header from the
# source tree. getting the order of the include paths right is fragile
# in CMake. by copying the header, we can put the precompile dump
# right next to it and have the compiler pick it up there
add_custom_command (
OUTPUT "${_pch_dir}/${header}"
COMMAND ${CMAKE_COMMAND}
ARGS -E copy "${PROJECT_SOURCE_DIR}/${header}" "${_pch_dir}/${header}"
DEPENDS "${PROJECT_SOURCE_DIR}/${header}"
)
# add a makefile rule to create the precompiled header
add_custom_command (
OUTPUT ${PROJECT_BINARY_DIR}/${_pch_file}
COMMAND ${_cmd}
ARGS ${_args} "-o" "${_pch_file}" "-x" "${gcc_lang}" "-c" "${_pch_dir}/${header}"
DEPENDS "${_pch_dir}/${header}"
COMMENT "Precompiling headers ${_pch_file}"
)
# create a phony target that is always built, but which only checks
# if the header file is OK (i.e. the header only gets rebuilt if
# necessary)
add_custom_target (${target} ALL
DEPENDS ${PROJECT_BINARY_DIR}/${_pch_file}
)
# these flags need to be added to the target
set (${target} "${_pch_file}" PARENT_SCOPE)
set (${flags_name} "-Winvalid-pch -include ${_pch_dir}/${header}" PARENT_SCOPE)
endif ()
endif ()
endfunction (precompile_header
language type header tgt_kw target flgs_kw flags_name)

View File

@ -0,0 +1,198 @@
# - Print CMake and OS distribution version
#
function (system_info)
message (STATUS "CMake version: ${CMAKE_VERSION}")
if (CMAKE_SYSTEM MATCHES "Linux")
distro_name (DISTRO_NAME)
message (STATUS "Linux distribution: ${DISTRO_NAME}")
elseif (CMAKE_SYSTEM MATCHES "Darwin")
sw_vers (OS_VERSION)
message (STATUS "${OS_VERSION}")
else (CMAKE_SYSTEM MATCHES "Linux")
message (STATUS "Operating system: ${CMAKE_SYSTEM}")
endif (CMAKE_SYSTEM MATCHES "Linux")
target_architecture (TARGET_CPU)
message (STATUS "Target architecture: ${TARGET_CPU}")
endfunction (system_info)
function (sw_vers varname)
# query operating system for information
exec_program (sw_vers OUTPUT_VARIABLE _vers)
# split multi-line into various fields
string (REPLACE "\n" ";" _vers "${_vers}")
string (REPLACE ":" ";" _vers "${_vers}")
# get the various fields
list (GET _vers 1 _prod_name)
list (GET _vers 3 _prod_vers)
list (GET _vers 5 _prod_build)
# remove extraneous whitespace
string (STRIP "${_prod_name}" _prod_name)
string (STRIP "${_prod_vers}" _prod_vers)
string (STRIP "${_prod_build}" _prod_build)
# assemble result variable
set (${varname} "${_prod_name} version: ${_prod_vers} (${_prod_build})" PARENT_SCOPE)
endfunction (sw_vers varname)
# probe various system files that may be found
function (distro_name varname)
file (GLOB has_os_release /etc/os-release)
file (GLOB has_lsb_release /etc/lsb-release)
file (GLOB has_sys_release /etc/system-release)
file (GLOB has_redhat_release /etc/redhat-release)
set (_descr)
# start with /etc/os-release,
# see <http://0pointer.de/blog/projects/os-release.html>
if (NOT has_os_release STREQUAL "")
read_release (PRETTY_NAME FROM /etc/os-release INTO _descr)
# previous "standard", used on older Ubuntu and Debian
elseif (NOT has_lsb_release STREQUAL "")
read_release (DISTRIB_DESCRIPTION FROM /etc/lsb-release INTO _descr)
endif (NOT has_os_release STREQUAL "")
# RHEL/CentOS etc. has just a text-file
if (NOT _descr)
if (NOT has_sys_release STREQUAL "")
file (READ /etc/system-release _descr)
elseif (NOT has_redhat_release STREQUAL "")
file (READ /etc/redhat-release _descr)
else (NOT has_sys_release STREQUAL "")
# no yet known release file found
set (_descr "unknown")
endif (NOT has_sys_release STREQUAL "")
endif (NOT _descr)
# return from function (into appropriate variable)
string (STRIP "${_descr}" _descr)
set (${varname} "${_descr}" PARENT_SCOPE)
endfunction (distro_name varname)
# read property from the newer /etc/os-release
function (read_release valuename FROM filename INTO varname)
file (STRINGS ${filename} _distrib
REGEX "^${valuename}="
)
string (REGEX REPLACE
"^${valuename}=\"?\(.*\)" "\\1" ${varname} "${_distrib}"
)
# remove trailing quote that got globbed by the wildcard (greedy match)
string (REGEX REPLACE
"\"$" "" ${varname} "${${varname}}"
)
set (${varname} "${${varname}}" PARENT_SCOPE)
endfunction (read_release valuename FROM filename INTO varname)
# the following code is adapted from commit f7467762 of the code at
# <https://github.com/petroules/solar-cmake/blob/master/TargetArch.cmake>
# which is Copyright (c) 2012 Petroules Corporation, and which at the
# time of download (2013-04-07 12:30 CET) is made available with a BSD license.
#
# it attempts to compile a program which detects the architecture from the
# preprocessor symbols and communicate this back to us through an error message(!)
function (target_architecture output_var)
# OS X is capable of building for *several* architectures at once in
# the Mach-O binary, and there is a variable that tells us which those
# are, but they may be in any order, so they must be normalized
if (APPLE AND CMAKE_OSX_ARCHITECTURES)
# detect each of the possible candidates as a separate flag
set (osx_arch_list i386 x86_64)
foreach (osx_arch IN ITEMS ${CMAKE_OSX_ARCHITECTURES})
foreach (candidate IN LISTS osx_arch_list)
if ("${osx_arch}" STREQUAL "${candidate}")
set (osx_arch_${candidate} TRUE)
endif ("${osx_arch}" STREQUAL "${candidate}")
endforeach (candidate)
endforeach (osx_arch)
# add all architectures back in normalized order
foreach (candidate IN LISTS osx_arch_list)
if (osx_arch_${candidate})
list (APPEND ARCH ${candidate})
endif (osx_arch_${candidate})
endforeach (candidate)
else (APPLE AND CMAKE_OSX_ARCHITECTURES)
# use the preprocessor defines to determine which target architectures
# that are available
set (arch_c_src "
#if defined(__arm__) || defined(__TARGET_ARCH_ARM)
# if defined(__ARM_ARCH_7__) \\
|| defined(__ARM_ARCH_7A__) \\
|| defined(__ARM_ARCH_7R__) \\
|| defined(__ARM_ARCH_7M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7)
# error cmake_ARCH armv7
# elif defined(__ARM_ARCH_6__) \\
|| defined(__ARM_ARCH_6J__) \\
|| defined(__ARM_ARCH_6T2__) \\
|| defined(__ARM_ARCH_6Z__) \\
|| defined(__ARM_ARCH_6K__) \\
|| defined(__ARM_ARCH_6ZK__) \\
|| defined(__ARM_ARCH_6M__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6)
# error cmake_ARCH armv6
# elif defined(__ARM_ARCH_5TEJ__) \\
|| (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5)
# error cmake_ARCH armv5
# else
# error cmake_ARCH arm
# endif
#elif defined(__i386) \\
|| defined(__i386__) \\
|| defined(_M_IX86)
# error cmake_ARCH i386
#elif defined(__x86_64) \\
|| defined(__x86_64__) \\
|| defined(__amd64) \\
|| defined(_M_X64)
# error cmake_ARCH x86_64
#elif defined(__ia64) \\
|| defined(__ia64__) \\
|| defined(_M_IA64)
# error cmake_ARCH ia64
#elif defined(__ppc__) \\
|| defined(__ppc) \\
|| defined(__powerpc__) \\
|| defined(_ARCH_COM) \\
|| defined(_ARCH_PWR) \\
|| defined(_ARCH_PPC) \\
|| defined(_M_MPPC) \\
|| defined(_M_PPC)
# if defined(__ppc64__) \\
|| defined(__powerpc64__) \\
|| defined(__64BIT__)
# error cmake_ARCH ppc64
# else
# error cmake_ARCH ppc
# endif
#else
# error cmake_ARCH unknown
#endif
")
# write a temporary program that can be compiled to get the result
set (tmp_dir "${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeTmp")
set (arch_c "${tmp_dir}/arch.c")
file (WRITE "${arch_c}" "${arch_c_src}")
try_compile (
compile_result_unused
"${tmp_dir}"
"${arch_c}"
CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}
OUTPUT_VARIABLE ARCH
)
# parse the architecture name from the compiler output
string (REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}")
# get rid of the value marker leaving just the architecture name
string (REPLACE "cmake_ARCH " "" ARCH "${ARCH}")
# if we are compiling with an unknown architecture this variable should
# already be set to "unknown" but in the case that it's empty (i.e. due
# to a typo in the code), then set it to unknown
if (NOT ARCH)
set (ARCH "unknown")
endif()
endif()
set (${output_var} "${ARCH}" PARENT_SCOPE)
endfunction()

View File

@ -0,0 +1,102 @@
# - Get version control information from source tree
#
# Sets the following variables
#
# VCS_SYSTEM Currently, this will only be "git", or empty if
# no source code control system is found.
#
# VCS_SHA1 Hash code of the last commit. If this is empty,
# then no source code repository was found.
#
# VCS_DECOR Characters that denotes any local modifications:
# "*" - Unstaged local changes
# "+" - Staged, but not committed, local changes
# "%" - Untracked local files
function (vcs_info)
# if we haven't located git yet, then do it now
if (NOT GIT_FOUND)
find_package (Git)
endif (NOT GIT_FOUND)
# if git is not installed (unpacked tarball), then just state that
# the version practically is unknown
set (VCS_DECOR "")
if (GIT_FOUND)
set (VCS_SYSTEM "git")
# assume that we have a .git subdirectory under the source directory;
# if we have a bare repository, then we won't be able to build in there
# and we won't be able to identify the git dir to use from only a work
# tree, so we handle that like a regular unpacked tarball
# exec_program is used because execute_process is buggy on common
# platforms (notable CMake 2.8.7 in Ubuntu Precise 12.04)
# get hash code
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS rev-parse --short --verify HEAD
OUTPUT_VARIABLE VCS_SHA1
RETURN_VALUE has_sha
)
# exec_program mashes together output and error
if (NOT ${has_sha} EQUAL 0)
set (VCS_SHA1 "")
endif (NOT ${has_sha} EQUAL 0)
# only proceed if we actually found a source tree in there
if (VCS_SHA1)
# check for unstaged local changes
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff --no-ext-diff --quiet --exit-code
RETURN_VALUE dirty
OUTPUT_VARIABLE _dummy
)
if (NOT ${dirty} EQUAL 0)
list (APPEND VCS_DECOR "*")
endif (NOT ${dirty} EQUAL 0)
# check for staged local changes
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff-index --no-ext-diff --cached --quiet --exit-code HEAD --
RETURN_VALUE staged
OUTPUT_VARIABLE _dummy
)
if (NOT ${staged} EQUAL 0)
list (APPEND VCS_DECOR "+")
endif (NOT ${staged} EQUAL 0)
# check for untracked files
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS ls-files --others --exclude-standard
OUTPUT_VARIABLE untracked
)
if (untracked)
list (APPEND VCS_DECOR "%")
endif (untracked)
# convert list to regular string
string (REPLACE ";" "" VCS_DECOR "${VCS_DECOR}")
endif (VCS_SHA1)
else (GIT_FOUND)
set (VCS_SYSTEM "")
set (VCS_SHA1 "")
set (VCS_DECOR "")
endif (GIT_FOUND)
# diagnostic output
if (VCS_SYSTEM AND VCS_SHA1)
message (STATUS "Source code repository: ${VCS_SYSTEM} ${VCS_SHA1}${VCS_DECOR}")
else (VCS_SYSTEM AND VCS_SHA1)
message (STATUS "Source code repository: not found!")
endif (VCS_SYSTEM AND VCS_SHA1)
# export to parent context
set (VCS_SYSTEM "${VCS_SYSTEM}" PARENT_SCOPE)
set (VCS_SHA1 "${VCS_SHA1}" PARENT_SCOPE)
set (VCS_DECOR "${VCS_DECOR}" PARENT_SCOPE)
endfunction (vcs_info)

View File

@ -0,0 +1,92 @@
# - Write version information into the source code
#
# Add an unconditional target to the Makefile which checks the current
# SHA of the source directory and write to a header file if and *only*
# if this has changed (thus we avoid unnecessary rebuilds). By having
# this in the Makefile, we get updated version information even though
# we haven't done any reconfiguring.
#
# The time it takes to probe the VCS for this information and write it
# to the miniature file in negligable.
#
# If the build type is Debug, then we only write a static version
# information as it gets tiresome to rebuild the project everytime one
# makes changes to any of the unit tests.
string (TOUPPER "${CMAKE_BUILD_TYPE}" cmake_build_type_upper_)
if (cmake_build_type_upper_ MATCHES DEBUG)
file (WRITE "${PROJECT_BINARY_DIR}/project-version.h"
"#define PROJECT_VERSION \"${${project}_LABEL} (debug)\"\n"
)
else ()
if (NOT GIT_FOUND)
find_package (Git)
endif ()
# if git is *still* not found means it is not present on the
# system, so there is "no" way we can update the SHA. notice
# that this is a slightly different version of the label than
# above.
if (NOT GIT_FOUND)
file (WRITE "${PROJECT_BINARY_DIR}/project-version.h"
"#define PROJECT_VERSION \"${${project}_LABEL}\"\n"
)
else ()
add_custom_target (update-version ALL
COMMAND ${CMAKE_COMMAND}
-DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY}
-DGIT_EXECUTABLE=${GIT_EXECUTABLE}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
-DPROJECT_LABEL=${${project}_LABEL}
-P ${OPM_MACROS_ROOT}/cmake/Scripts/WriteVerSHA.cmake
COMMENT "Updating version information"
)
# the target above gets built every time thanks to the "ALL" modifier,
# but it must also be done before the main library so it can pick up
# any changes it does.
if (${project}_TARGET)
add_dependencies (${${project}_TARGET} update-version)
endif ()
endif ()
endif ()
# safety precaution: check that we don't have version number mismatch.
# first get the name of the module (e.g. "core")
set (_module_regexp "([^-]+)-(.*)")
string (REGEX REPLACE "${_module_regexp}" "\\1" _suite_name "${project}")
string (REGEX REPLACE "${_module_regexp}" "\\2" _module_name "${project}")
# if we have a version number it must be in this file, e.g. opm/core/version.h
set (_rel_ver_h "${${project}_DIR}/${_module_name}/version.h")
set (_version_h "${PROJECT_SOURCE_DIR}/${_rel_ver_h}")
# not all modules have version files, so only check if they do
if (EXISTS "${_version_h}")
# uppercase versions which is used in the file
string (TOUPPER "${_suite_name}" _suite_upper)
string (TOUPPER "${_module_name}" _module_upper)
# scan the files for version define for major version
set (_major_regexp "#define[ ]+${_suite_upper}_${_module_upper}_VERSION_MAJOR[ ]+([0-9]*)")
file (STRINGS "${_version_h}" _version_h_major REGEX "${_major_regexp}")
string (REGEX REPLACE "${_major_regexp}" "\\1" _version_h_major "${_version_h_major}")
# exactly the same, but minor version (making a macro is more lines...)
set (_minor_regexp "#define[ ]+${_suite_upper}_${_module_upper}_VERSION_MINOR[ ]+([0-9]*)")
file (STRINGS "${_version_h}" _version_h_minor REGEX "${_minor_regexp}")
string (REGEX REPLACE "${_minor_regexp}" "\\1" _version_h_minor "${_version_h_minor}")
# compare what we got from the file with what we have defined here
if (NOT (("${_version_h_major}" EQUAL "${${project}_VERSION_MAJOR}")
AND ("${_version_h_minor}" EQUAL "${${project}_VERSION_MINOR}")))
set (_proj_ver "${${project}_VERSION_MAJOR}.${${project}_VERSION_MINOR}")
set (_file_ver "${_version_h_major}.${_version_h_minor}")
message (AUTHOR_WARNING
"Version in build system (dune.module) is \"${_proj_ver}\", "
"but version in source (${_rel_ver_h}) is \"${_file_ver}\""
)
endif ()
endif ()

View File

@ -0,0 +1,19 @@
# - Turn on warnings when compiling
include (AddOptions)
include (UseCompVer)
is_compiler_gcc_compatible ()
if (CXX_COMPAT_GCC)
# default warnings flags, if not set by user
set_default_option (CXX _warn_flag "-Wall" "(^|\ )-W")
if (_warn_flag)
message (STATUS "All warnings enabled: ${_warn_flag}")
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)
add_definitions(-DSILENCE_EXTERNAL_WARNINGS)
endif()

View File

@ -0,0 +1,138 @@
# CMAKE_PARSE_ARGUMENTS(<prefix> <options> <one_value_keywords> <multi_value_keywords> args...)
#
# CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions for
# parsing the arguments given to that macro or function.
# It processes the arguments and defines a set of variables which hold the
# values of the respective options.
#
# The <options> argument contains all options for the respective macro,
# i.e. keywords which can be used when calling the macro without any value
# following, like e.g. the OPTIONAL keyword of the install() command.
#
# The <one_value_keywords> argument contains all keywords for this macro
# which are followed by one value, like e.g. DESTINATION keyword of the
# install() command.
#
# The <multi_value_keywords> argument contains all keywords for this macro
# which can be followed by more than one value, like e.g. the TARGETS or
# FILES keywords of the install() command.
#
# When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the
# keywords listed in <options>, <one_value_keywords> and
# <multi_value_keywords> a variable composed of the given <prefix>
# followed by "_" and the name of the respective keyword.
# These variables will then hold the respective value from the argument list.
# For the <options> keywords this will be TRUE or FALSE.
#
# All remaining arguments are collected in a variable
# <prefix>_UNPARSED_ARGUMENTS, this can be checked afterwards to see whether
# your macro was called with unrecognized parameters.
#
# As an example here a my_install() macro, which takes similar arguments as the
# real install() command:
#
# function(MY_INSTALL)
# set(options OPTIONAL FAST)
# set(oneValueArgs DESTINATION RENAME)
# set(multiValueArgs TARGETS CONFIGURATIONS)
# cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN} )
# ...
#
# Assume my_install() has been called like this:
# my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub)
#
# After the cmake_parse_arguments() call the macro will have set the following
# variables:
# MY_INSTALL_OPTIONAL = TRUE
# MY_INSTALL_FAST = FALSE (this option was not used when calling my_install()
# MY_INSTALL_DESTINATION = "bin"
# MY_INSTALL_RENAME = "" (was not used)
# MY_INSTALL_TARGETS = "foo;bar"
# MY_INSTALL_CONFIGURATIONS = "" (was not used)
# MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL"
#
# You can the continue and process these variables.
#
# Keywords terminate lists of values, e.g. if directly after a one_value_keyword
# another recognized keyword follows, this is interpreted as the beginning of
# the new option.
# E.g. my_install(TARGETS foo DESTINATION OPTIONAL) would result in
# MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION would
# be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor.
#=============================================================================
# Copyright 2010 Alexander Neundorf <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
if(__CMAKE_PARSE_ARGUMENTS_INCLUDED)
return()
endif()
set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE)
function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames)
# first set all result variables to empty/FALSE
foreach(arg_name ${_singleArgNames} ${_multiArgNames})
set(${prefix}_${arg_name})
endforeach(arg_name)
foreach(option ${_optionNames})
set(${prefix}_${option} FALSE)
endforeach(option)
set(${prefix}_UNPARSED_ARGUMENTS)
set(insideValues FALSE)
set(currentArgName)
# now iterate over all arguments and fill the result variables
foreach(currentArg ${ARGN})
list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword
list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword
if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1)
if(insideValues)
if("${insideValues}" STREQUAL "SINGLE")
set(${prefix}_${currentArgName} ${currentArg})
set(insideValues FALSE)
elseif("${insideValues}" STREQUAL "MULTI")
list(APPEND ${prefix}_${currentArgName} ${currentArg})
endif()
else(insideValues)
list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg})
endif(insideValues)
else()
if(NOT ${optionIndex} EQUAL -1)
set(${prefix}_${currentArg} TRUE)
set(insideValues FALSE)
elseif(NOT ${singleArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "SINGLE")
elseif(NOT ${multiArgIndex} EQUAL -1)
set(currentArgName ${currentArg})
set(${prefix}_${currentArgName})
set(insideValues "MULTI")
endif()
endif()
endforeach(currentArg)
# propagate the result variables to the caller:
foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames})
set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE)
endforeach(arg_name)
set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE)
endfunction(CMAKE_PARSE_ARGUMENTS _options _singleArgs _multiArgs)

View File

@ -0,0 +1,47 @@
# The module defines the following variables:
# GIT_EXECUTABLE - path to git command line client
# GIT_FOUND - true if the command line client was found
# Example usage:
# find_package(Git)
# if(GIT_FOUND)
# message("git found: ${GIT_EXECUTABLE}")
# endif()
#=============================================================================
# Copyright 2010 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
# Look for 'git' or 'eg' (easy git)
#
set(git_names git eg)
# Prefer .cmd variants on Windows unless running in a Makefile
# in the MSYS shell.
#
if(WIN32)
if(NOT CMAKE_GENERATOR MATCHES "MSYS")
set(git_names git.cmd git eg.cmd eg)
endif()
endif()
find_program(GIT_EXECUTABLE
NAMES ${git_names}
PATH_SUFFIXES Git/cmd Git/bin
DOC "git command line client"
)
mark_as_advanced(GIT_EXECUTABLE)
# Handle the QUIETLY and REQUIRED arguments and set GIT_FOUND to TRUE if
# all listed variables are TRUE
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Git DEFAULT_MSG GIT_EXECUTABLE)

View File

@ -0,0 +1,61 @@
# This module defines two macros:
# CMAKE_PUSH_CHECK_STATE()
# and
# CMAKE_POP_CHECK_STATE()
# These two macros can be used to save and restore the state of the variables
# CMAKE_REQUIRED_FLAGS, CMAKE_REQUIRED_DEFINITIONS, CMAKE_REQUIRED_LIBRARIES
# and CMAKE_REQUIRED_INCLUDES used by the various Check-files coming with CMake,
# like e.g. check_function_exists() etc.
# The variable contents are pushed on a stack, pushing multiple times is supported.
# This is useful e.g. when executing such tests in a Find-module, where they have to be set,
# but after the Find-module has been executed they should have the same value
# as they had before.
#
# Usage:
# cmake_push_check_state()
# set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} -DSOME_MORE_DEF)
# check_function_exists(...)
# cmake_pop_check_state()
#=============================================================================
# Copyright 2006-2011 Alexander Neundorf, <neundorf@kde.org>
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
MACRO(CMAKE_PUSH_CHECK_STATE)
IF(NOT DEFINED _CMAKE_PUSH_CHECK_STATE_COUNTER)
SET(_CMAKE_PUSH_CHECK_STATE_COUNTER 0)
ENDIF()
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}+1")
SET(_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_INCLUDES})
SET(_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_DEFINITIONS})
SET(_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_LIBRARIES})
SET(_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER} ${CMAKE_REQUIRED_FLAGS})
ENDMACRO(CMAKE_PUSH_CHECK_STATE)
MACRO(CMAKE_POP_CHECK_STATE)
# don't pop more than we pushed
IF("${_CMAKE_PUSH_CHECK_STATE_COUNTER}" GREATER "0")
SET(CMAKE_REQUIRED_INCLUDES ${_CMAKE_REQUIRED_INCLUDES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_DEFINITIONS ${_CMAKE_REQUIRED_DEFINITIONS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_LIBRARIES ${_CMAKE_REQUIRED_LIBRARIES_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
SET(CMAKE_REQUIRED_FLAGS ${_CMAKE_REQUIRED_FLAGS_SAVE_${_CMAKE_PUSH_CHECK_STATE_COUNTER}})
MATH(EXPR _CMAKE_PUSH_CHECK_STATE_COUNTER "${_CMAKE_PUSH_CHECK_STATE_COUNTER}-1")
ENDIF()
ENDMACRO(CMAKE_POP_CHECK_STATE)

View File

@ -0,0 +1,624 @@
# - Find BLAS library
# This module finds an installed fortran library that implements the BLAS
# linear-algebra interface (see http://www.netlib.org/blas/).
# The list of libraries searched for is taken
# from the autoconf macro file, acx_blas.m4 (distributed at
# http://ac-archive.sourceforge.net/ac-archive/acx_blas.html).
#
# This module sets the following variables:
# BLAS_FOUND - set to true if a library implementing the BLAS interface
# is found
# BLAS_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L).
# BLAS_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use BLAS
# BLAS95_LIBRARIES - uncached list of libraries (using full path name)
# to link against to use BLAS95 interface
# BLAS95_FOUND - set to true if a library implementing the BLAS f95 interface
# is found
# BLA_STATIC if set on this determines what kind of linkage we do (static)
# BLA_VENDOR if set checks only the specified vendor, if not set checks
# all the possibilities
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
##########
### List of vendors (BLA_VENDOR) valid in this module
## Goto,ATLAS PhiPACK,CXML,DXML,SunPerf,SCSL,SGIMATH,IBMESSL,Intel10_32 (intel mkl v10 32 bit),Intel10_64lp (intel mkl v10 64 bit,lp thread model, lp64 model),
## Intel( older versions of mkl 32 and 64 bit), ACML,ACML_MP,ACML_GPU,Apple, NAS, Generic
# C/CXX should be enabled to use Intel mkl
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
include(CheckFunctionExists)
include(CheckFortranFunctionExists)
set(_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
# Check the language being used
get_property( _LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES )
if( _LANGUAGES_ MATCHES Fortran )
set( _CHECK_FORTRAN TRUE )
elseif( (_LANGUAGES_ MATCHES C) OR (_LANGUAGES_ MATCHES CXX) )
set( _CHECK_FORTRAN FALSE )
else()
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR "FindBLAS requires Fortran, C, or C++ to be enabled.")
else(BLAS_FIND_REQUIRED)
message(STATUS "Looking for BLAS... - NOT found (Unsupported languages)")
return()
endif(BLAS_FIND_REQUIRED)
endif( )
macro(Check_Fortran_Libraries LIBRARIES _prefix _name _flags _list _thread)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library
# combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
# have been found. Otherwise, LIBRARIES is set to FALSE.
# N.B. _prefix is the prefix applied to the names of all cached variables that
# are generated internally and marked advanced by this macro.
set(_libdir ${ARGN})
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
if (NOT _libdir)
if (WIN32)
set(_libdir ENV LIB)
elseif (APPLE)
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
else ()
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
endif ()
endif ()
foreach(_library ${_list})
set(_combined_name ${_combined_name}_${_library})
if(_libraries_work)
if (BLA_STATIC)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ( WIN32 )
if (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (APPLE)
else (BLA_STATIC)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
endif (BLA_STATIC)
find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS ${_libdir}
)
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
endif(_libraries_work)
endforeach(_library ${_list})
if(_libraries_work)
# Test this combination of libraries.
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_threads})
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
if (_CHECK_FORTRAN)
check_fortran_function_exists("${_name}" ${_prefix}${_combined_name}_WORKS)
else()
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
endif()
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
endif(_libraries_work)
if(NOT _libraries_work)
set(${LIBRARIES} FALSE)
endif(NOT _libraries_work)
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endmacro(Check_Fortran_Libraries)
set(BLAS_LINKER_FLAGS)
set(BLAS_LIBRARIES)
set(BLAS95_LIBRARIES)
if ($ENV{BLA_VENDOR} MATCHES ".+")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ($ENV{BLA_VENDOR} MATCHES ".+")
if(NOT BLA_VENDOR)
set(BLA_VENDOR "All")
endif(NOT BLA_VENDOR)
endif ($ENV{BLA_VENDOR} MATCHES ".+")
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# gotoblas (http://www.tacc.utexas.edu/tacc-projects/gotoblas2)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"goto2"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
# BLAS in ATLAS library? (http://math-atlas.sourceforge.net/)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"f77blas;atlas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "ATLAS" OR BLA_VENDOR STREQUAL "All")
# BLAS in PhiPACK libraries? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"sgemm;dgemm;blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "PhiPACK" OR BLA_VENDOR STREQUAL "All")
# BLAS in Alpha CXML library?
if (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"cxml"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "CXML" OR BLA_VENDOR STREQUAL "All")
# BLAS in Alpha DXML library? (now called CXML, see above)
if (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"dxml"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "DXML" OR BLA_VENDOR STREQUAL "All")
# BLAS in Sun Performance library?
if (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
"-xlic_lib=sunperf"
"sunperf;sunmath"
""
)
if(BLAS_LIBRARIES)
set(BLAS_LINKER_FLAGS "-xlic_lib=sunperf")
endif(BLAS_LIBRARIES)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SunPerf" OR BLA_VENDOR STREQUAL "All")
# BLAS in SCSL library? (SGI/Cray Scientific Library)
if (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"scsl"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SCSL" OR BLA_VENDOR STREQUAL "All")
# BLAS in SGIMATH library?
if (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"complib.sgimath"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "SGIMATH" OR BLA_VENDOR STREQUAL "All")
# BLAS in IBM ESSL library? (requires generic BLAS lib, too)
if (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"essl;blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "IBMESSL" OR BLA_VENDOR STREQUAL "All")
#BLAS in acml library?
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if( ((BLA_VENDOR STREQUAL "ACML") AND (NOT BLAS_ACML_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_MP") AND (NOT BLAS_ACML_MP_LIB_DIRS)) OR
((BLA_VENDOR STREQUAL "ACML_GPU") AND (NOT BLAS_ACML_GPU_LIB_DIRS))
)
# try to find acml in "standard" paths
if( WIN32 )
file( GLOB _ACML_ROOT "C:/AMD/acml*/ACML-EULA.txt" )
else()
file( GLOB _ACML_ROOT "/opt/acml*/ACML-EULA.txt" )
endif()
if( WIN32 )
file( GLOB _ACML_GPU_ROOT "C:/AMD/acml*/GPGPUexamples" )
else()
file( GLOB _ACML_GPU_ROOT "/opt/acml*/GPGPUexamples" )
endif()
list(GET _ACML_ROOT 0 _ACML_ROOT)
list(GET _ACML_GPU_ROOT 0 _ACML_GPU_ROOT)
if( _ACML_ROOT )
get_filename_component( _ACML_ROOT ${_ACML_ROOT} PATH )
if( SIZEOF_INTEGER EQUAL 8 )
set( _ACML_PATH_SUFFIX "_int64" )
else()
set( _ACML_PATH_SUFFIX "" )
endif()
if( CMAKE_Fortran_COMPILER_ID STREQUAL "Intel" )
set( _ACML_COMPILER32 "ifort32" )
set( _ACML_COMPILER64 "ifort64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "SunPro" )
set( _ACML_COMPILER32 "sun32" )
set( _ACML_COMPILER64 "sun64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "PGI" )
set( _ACML_COMPILER32 "pgi32" )
if( WIN32 )
set( _ACML_COMPILER64 "win64" )
else()
set( _ACML_COMPILER64 "pgi64" )
endif()
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "Open64" )
# 32 bit builds not supported on Open64 but for code simplicity
# We'll just use the same directory twice
set( _ACML_COMPILER32 "open64_64" )
set( _ACML_COMPILER64 "open64_64" )
elseif( CMAKE_Fortran_COMPILER_ID STREQUAL "NAG" )
set( _ACML_COMPILER32 "nag32" )
set( _ACML_COMPILER64 "nag64" )
else() #if( CMAKE_Fortran_COMPILER_ID STREQUAL "GNU" )
set( _ACML_COMPILER32 "gfortran32" )
set( _ACML_COMPILER64 "gfortran64" )
endif()
if( BLA_VENDOR STREQUAL "ACML_MP" )
set(_ACML_MP_LIB_DIRS
"${_ACML_ROOT}/${_ACML_COMPILER32}_mp${_ACML_PATH_SUFFIX}/lib"
"${_ACML_ROOT}/${_ACML_COMPILER64}_mp${_ACML_PATH_SUFFIX}/lib" )
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
set(_ACML_LIB_DIRS
"${_ACML_ROOT}/${_ACML_COMPILER32}${_ACML_PATH_SUFFIX}/lib"
"${_ACML_ROOT}/${_ACML_COMPILER64}${_ACML_PATH_SUFFIX}/lib" )
endif()
endif()
elseif(BLAS_${BLA_VENDOR}_LIB_DIRS)
set(_${BLA_VENDOR}_LIB_DIRS ${BLAS_${BLA_VENDOR}_LIB_DIRS})
endif()
if( BLA_VENDOR STREQUAL "ACML_MP" )
foreach( BLAS_ACML_MP_LIB_DIRS ${_ACML_MP_LIB_DIRS})
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml_mp;acml_mv" "" ${BLAS_ACML_MP_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
elseif( BLA_VENDOR STREQUAL "ACML_GPU" )
foreach( BLAS_ACML_GPU_LIB_DIRS ${_ACML_GPU_LIB_DIRS})
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml;acml_mv;CALBLAS" "" ${BLAS_ACML_GPU_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
else() #if( _BLAS_VENDOR STREQUAL "ACML" )
foreach( BLAS_ACML_LIB_DIRS ${_ACML_LIB_DIRS} )
check_fortran_libraries (
BLAS_LIBRARIES
BLAS
sgemm
"" "acml;acml_mv" "" ${BLAS_ACML_LIB_DIRS}
)
if( BLAS_LIBRARIES )
break()
endif()
endforeach()
endif()
# Either acml or acml_mp should be in LD_LIBRARY_PATH but not both
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml;acml_mv"
""
)
endif(NOT BLAS_LIBRARIES)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml_mp;acml_mv"
""
)
endif(NOT BLAS_LIBRARIES)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"acml;acml_mv;CALBLAS"
""
)
endif(NOT BLAS_LIBRARIES)
endif () # ACML
# Apple BLAS library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"Accelerate"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT BLAS_LIBRARIES )
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
dgemm
""
"vecLib"
""
)
endif ( NOT BLAS_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic BLAS library?
if (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"blas"
""
)
endif(NOT BLAS_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Generic" OR BLA_VENDOR STREQUAL "All")
#BLAS in intel mkl 10 library? (em64t 64bit)
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (NOT WIN32)
set(LM "-lm")
endif ()
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
if(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
find_package(Threads)
else(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
find_package(Threads REQUIRED)
endif(BLAS_FIND_QUIETLY OR NOT BLAS_FIND_REQUIRED)
if (WIN32)
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel_c;mkl_intel_thread;mkl_core;libguide40"
""
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
SGEMM
""
"mkl_c_dll;mkl_intel_thread_dll;mkl_core_dll;libguide40"
""
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
else(WIN32)
if (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_intel;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT}"
"${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
endif (BLA_VENDOR STREQUAL "Intel10_32" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(NOT BLAS95_LIBRARIES)
check_fortran_libraries(
BLAS95_LIBRARIES
BLAS
sgemm
""
"mkl_blas95;mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS95_LIBRARIES)
else(BLA_F95)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_intel_lp64;mkl_intel_thread;mkl_core;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif(BLA_F95)
endif (BLA_VENDOR STREQUAL "Intel10_64lp" OR BLA_VENDOR STREQUAL "All")
endif (WIN32)
#older vesions of intel mkl libs
# BLAS in intel mkl library? (shared)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
#BLAS in intel mkl library? (static, 32bit)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_ia32;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
#BLAS in intel mkl library? (static, em64t 64bit)
if(NOT BLAS_LIBRARIES)
check_fortran_libraries(
BLAS_LIBRARIES
BLAS
sgemm
""
"mkl_em64t;guide"
"${CMAKE_THREAD_LIBS_INIT};${LM}"
)
endif(NOT BLAS_LIBRARIES)
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
endif (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if(BLA_F95)
if(BLAS95_LIBRARIES)
set(BLAS95_FOUND TRUE)
else(BLAS95_LIBRARIES)
set(BLAS95_FOUND FALSE)
endif(BLAS95_LIBRARIES)
if(NOT BLAS_FIND_QUIETLY)
if(BLAS95_FOUND)
message(STATUS "A library with BLAS95 API found.")
else(BLAS95_FOUND)
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with BLAS95 API not found. Please specify library location.")
else(BLAS_FIND_REQUIRED)
message(STATUS
"A library with BLAS95 API not found. Please specify library location.")
endif(BLAS_FIND_REQUIRED)
endif(BLAS95_FOUND)
endif(NOT BLAS_FIND_QUIETLY)
set(BLAS_FOUND TRUE)
set(BLAS_LIBRARIES "${BLAS95_LIBRARIES}")
else(BLA_F95)
if(BLAS_LIBRARIES)
set(BLAS_FOUND TRUE)
else(BLAS_LIBRARIES)
set(BLAS_FOUND FALSE)
endif(BLAS_LIBRARIES)
if(NOT BLAS_FIND_QUIETLY)
if(BLAS_FOUND)
message(STATUS "A library with BLAS API found.")
else(BLAS_FOUND)
if(BLAS_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with BLAS API not found. Please specify library location."
)
else(BLAS_FIND_REQUIRED)
message(STATUS
"A library with BLAS API not found. Please specify library location."
)
endif(BLAS_FIND_REQUIRED)
endif(BLAS_FOUND)
endif(NOT BLAS_FIND_QUIETLY)
endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_blas_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})

View File

@ -0,0 +1,307 @@
# - Find LAPACK library
# This module finds an installed fortran library that implements the LAPACK
# linear-algebra interface (see http://www.netlib.org/lapack/).
#
# The approach follows that taken for the autoconf macro file, acx_lapack.m4
# (distributed at http://ac-archive.sourceforge.net/ac-archive/acx_lapack.html).
#
# This module sets the following variables:
# LAPACK_FOUND - set to true if a library implementing the LAPACK interface
# is found
# LAPACK_LINKER_FLAGS - uncached list of required linker flags (excluding -l
# and -L).
# LAPACK_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK
# LAPACK95_LIBRARIES - uncached list of libraries (using full path name) to
# link against to use LAPACK95
# LAPACK95_FOUND - set to true if a library implementing the LAPACK f95
# interface is found
# BLA_STATIC if set on this determines what kind of linkage we do (static)
# BLA_VENDOR if set checks only the specified vendor, if not set checks
# all the possibilities
# BLA_F95 if set on tries to find the f95 interfaces for BLAS/LAPACK
### List of vendors (BLA_VENDOR) valid in this module
## Intel(mkl), ACML,Apple, NAS, Generic
#=============================================================================
# Copyright 2007-2009 Kitware, Inc.
#
# Distributed under the OSI-approved BSD License (the "License");
# see accompanying file Copyright.txt for details.
#
# This software is distributed WITHOUT ANY WARRANTY; without even the
# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
# See the License for more information.
#=============================================================================
# (To distribute this file outside of CMake, substitute the full
# License text for the above reference.)
set(_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES})
get_property(_LANGUAGES_ GLOBAL PROPERTY ENABLED_LANGUAGES)
if (NOT _LANGUAGES_ MATCHES Fortran)
include(CheckFunctionExists)
else (NOT _LANGUAGES_ MATCHES Fortran)
include(CheckFortranFunctionExists)
endif (NOT _LANGUAGES_ MATCHES Fortran)
set(LAPACK_FOUND FALSE)
set(LAPACK95_FOUND FALSE)
# TODO: move this stuff to separate module
macro(Check_Lapack_Libraries LIBRARIES _prefix _name _flags _list _blas _threads)
# This macro checks for the existence of the combination of fortran libraries
# given by _list. If the combination is found, this macro checks (using the
# Check_Fortran_Function_Exists macro) whether can link against that library
# combination using the name of a routine given by _name using the linker
# flags given by _flags. If the combination of libraries is found and passes
# the link test, LIBRARIES is set to the list of complete library paths that
# have been found. Otherwise, LIBRARIES is set to FALSE.
# N.B. _prefix is the prefix applied to the names of all cached variables that
# are generated internally and marked advanced by this macro.
set(_libraries_work TRUE)
set(${LIBRARIES})
set(_combined_name)
if (NOT _libdir)
if (WIN32)
set(_libdir ENV LIB)
elseif (APPLE)
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV DYLD_LIBRARY_PATH)
else ()
set(_libdir /usr/local/lib /usr/lib /usr/local/lib64 /usr/lib64 ENV LD_LIBRARY_PATH)
endif ()
endif ()
foreach(_library ${_list})
set(_combined_name ${_combined_name}_${_library})
if(_libraries_work)
if (BLA_STATIC)
if (WIN32)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif ( WIN32 )
if (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .lib ${CMAKE_FIND_LIBRARY_SUFFIXES})
else (APPLE)
set(CMAKE_FIND_LIBRARY_SUFFIXES .a ${CMAKE_FIND_LIBRARY_SUFFIXES})
endif (APPLE)
else (BLA_STATIC)
if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
# for ubuntu's libblas3gf and liblapack3gf packages
set(CMAKE_FIND_LIBRARY_SUFFIXES ${CMAKE_FIND_LIBRARY_SUFFIXES} .so.3gf)
endif ()
endif (BLA_STATIC)
find_library(${_prefix}_${_library}_LIBRARY
NAMES ${_library}
PATHS ${_libdir}
)
mark_as_advanced(${_prefix}_${_library}_LIBRARY)
set(${LIBRARIES} ${${LIBRARIES}} ${${_prefix}_${_library}_LIBRARY})
set(_libraries_work ${${_prefix}_${_library}_LIBRARY})
endif(_libraries_work)
endforeach(_library ${_list})
if(_libraries_work)
# Test this combination of libraries.
if(UNIX AND BLA_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${_flags} "-Wl,--start-group" ${${LIBRARIES}} ${_blas} "-Wl,--end-group" ${_threads})
else(UNIX AND BLA_STATIC)
set(CMAKE_REQUIRED_LIBRARIES ${_flags} ${${LIBRARIES}} ${_blas} ${_threads})
endif(UNIX AND BLA_STATIC)
# message("DEBUG: CMAKE_REQUIRED_LIBRARIES = ${CMAKE_REQUIRED_LIBRARIES}")
if (NOT _LANGUAGES_ MATCHES Fortran)
check_function_exists("${_name}_" ${_prefix}${_combined_name}_WORKS)
else (NOT _LANGUAGES_ MATCHES Fortran)
check_fortran_function_exists(${_name} ${_prefix}${_combined_name}_WORKS)
endif (NOT _LANGUAGES_ MATCHES Fortran)
set(CMAKE_REQUIRED_LIBRARIES)
mark_as_advanced(${_prefix}${_combined_name}_WORKS)
set(_libraries_work ${${_prefix}${_combined_name}_WORKS})
#message("DEBUG: ${LIBRARIES} = ${${LIBRARIES}}")
endif(_libraries_work)
if(_libraries_work)
set(${LIBRARIES} ${${LIBRARIES}} ${_blas} ${_threads})
else(_libraries_work)
set(${LIBRARIES} FALSE)
endif(_libraries_work)
endmacro(Check_Lapack_Libraries)
set(LAPACK_LINKER_FLAGS)
set(LAPACK_LIBRARIES)
set(LAPACK95_LIBRARIES)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(BLAS REQUIRED)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if(BLAS_FOUND)
set(LAPACK_LINKER_FLAGS ${BLAS_LINKER_FLAGS})
if ($ENV{BLA_VENDOR} MATCHES ".+")
set(BLA_VENDOR $ENV{BLA_VENDOR})
else ($ENV{BLA_VENDOR} MATCHES ".+")
if(NOT BLA_VENDOR)
set(BLA_VENDOR "All")
endif(NOT BLA_VENDOR)
endif ($ENV{BLA_VENDOR} MATCHES ".+")
if (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"goto2"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Goto" OR BLA_VENDOR STREQUAL "All")
#acml lapack
if (BLA_VENDOR MATCHES "ACML.*" OR BLA_VENDOR STREQUAL "All")
if (BLAS_LIBRARIES MATCHES ".+acml.+")
set (LAPACK_LIBRARIES ${BLAS_LIBRARIES})
endif ()
endif ()
# Apple LAPACK library?
if (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"Accelerate"
"${BLAS_LIBRARIES}"
""
)
endif(NOT LAPACK_LIBRARIES)
endif (BLA_VENDOR STREQUAL "Apple" OR BLA_VENDOR STREQUAL "All")
if (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"vecLib"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif (BLA_VENDOR STREQUAL "NAS" OR BLA_VENDOR STREQUAL "All")
# Generic LAPACK library?
if (BLA_VENDOR STREQUAL "Generic" OR
BLA_VENDOR STREQUAL "ATLAS" OR
BLA_VENDOR STREQUAL "All")
if ( NOT LAPACK_LIBRARIES )
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"lapack"
"${BLAS_LIBRARIES}"
""
)
endif ( NOT LAPACK_LIBRARIES )
endif ()
#intel lapack
if (BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
if (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
if(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_PACKAGE(Threads)
else(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
find_package(Threads REQUIRED)
endif(LAPACK_FIND_QUIETLY OR NOT LAPACK_FIND_REQUIRED)
if (BLA_F95)
if(NOT LAPACK95_LIBRARIES)
check_lapack_libraries(
LAPACK95_LIBRARIES
LAPACK
cheev
""
"mkl_lapack95"
"${BLAS95_LIBRARIES}"
"${CMAKE_THREAD_LIBS_INIT}"
)
endif(NOT LAPACK95_LIBRARIES)
else(BLA_F95)
if(NOT LAPACK_LIBRARIES)
check_lapack_libraries(
LAPACK_LIBRARIES
LAPACK
cheev
""
"mkl_lapack"
"${BLAS_LIBRARIES}"
"${CMAKE_THREAD_LIBS_INIT}"
)
endif(NOT LAPACK_LIBRARIES)
endif(BLA_F95)
endif (_LANGUAGES_ MATCHES C OR _LANGUAGES_ MATCHES CXX)
endif(BLA_VENDOR MATCHES "Intel*" OR BLA_VENDOR STREQUAL "All")
else(BLAS_FOUND)
message(STATUS "LAPACK requires BLAS")
endif(BLAS_FOUND)
if(BLA_F95)
if(LAPACK95_LIBRARIES)
set(LAPACK95_FOUND TRUE)
else(LAPACK95_LIBRARIES)
set(LAPACK95_FOUND FALSE)
endif(LAPACK95_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY)
if(LAPACK95_FOUND)
message(STATUS "A library with LAPACK95 API found.")
else(LAPACK95_FOUND)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with LAPACK95 API not found. Please specify library location."
)
else(LAPACK_FIND_REQUIRED)
message(STATUS
"A library with LAPACK95 API not found. Please specify library location."
)
endif(LAPACK_FIND_REQUIRED)
endif(LAPACK95_FOUND)
endif(NOT LAPACK_FIND_QUIETLY)
set(LAPACK_FOUND "${LAPACK95_FOUND}")
set(LAPACK_LIBRARIES "${LAPACK95_LIBRARIES}")
else(BLA_F95)
if(LAPACK_LIBRARIES)
set(LAPACK_FOUND TRUE)
else(LAPACK_LIBRARIES)
set(LAPACK_FOUND FALSE)
endif(LAPACK_LIBRARIES)
if(NOT LAPACK_FIND_QUIETLY)
if(LAPACK_FOUND)
message(STATUS "A library with LAPACK API found.")
else(LAPACK_FOUND)
if(LAPACK_FIND_REQUIRED)
message(FATAL_ERROR
"A required library with LAPACK API not found. Please specify library location."
)
else(LAPACK_FIND_REQUIRED)
message(STATUS
"A library with LAPACK API not found. Please specify library location."
)
endif(LAPACK_FIND_REQUIRED)
endif(LAPACK_FOUND)
endif(NOT LAPACK_FIND_QUIETLY)
endif(BLA_F95)
set(CMAKE_FIND_LIBRARY_SUFFIXES ${_lapack_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES})

View File

@ -0,0 +1,29 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (dune-cornerpoint_CONFIG_VAR
DUNE_GRID_VERSION_MAJOR
DUNE_GRID_VERSION_MINOR
DUNE_GRID_VERSION_REVISION
DUNE_COMMON_VERSION_MAJOR
DUNE_COMMON_VERSION_MINOR
DUNE_COMMON_VERSION_REVISION
)
# dependencies
set (dune-cornerpoint_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# DUNE dependency
"dune-common REQUIRED;
dune-grid REQUIRED;
dune-geometry REQUIRED"
# OPM dependency
"opm-core REQUIRED"
)

View File

@ -0,0 +1,34 @@
# -*- 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:
# this avoids an annoying deprecation warning on DUNE 2.4 (which we
# are not interested in anyway)
set(DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING 1)
# defines that must be present in config.h for our headers
set (ewoms_CONFIG_VAR
HAVE_QUAD
HAVE_VALGRIND
DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
)
# dependencies
set (ewoms_DEPS
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# DUNE prerequisites
"dune-common REQUIRED"
"dune-localfunctions REQUIRED"
"dune-geometry REQUIRED"
"dune-grid REQUIRED"
"dune-istl REQUIRED"
"opm-core REQUIRED"
"opm-material REQUIRED"
"opm-parser"
"dune-alugrid"
"dune-cornerpoint"
# valgrind client requests
"Valgrind"
# quadruple precision floating point calculations
"Quadmath"
)

View File

@ -0,0 +1,25 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-autodiff_CONFIG_VAR
HAVE_DUNE_CORNERPOINT
)
# dependencies
set (opm-autodiff_DEPS
# Compile with C99 support if available
"C99"
# Compile with C++0x/11 support if available
"CXX11Features"
# Various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# DUNE prerequisites
"dune-common REQUIRED;
dune-istl REQUIRED;
dune-cornerpoint;
opm-core REQUIRED"
# Eigen
"Eigen3 3.2.0"
)

View File

@ -0,0 +1,18 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-benchmarks_CONFIG_VAR
)
# dependencies
set (opm-benchmarks_DEPS
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# OPM dependency
"opm-core"
"opm-upscaling"
)

View File

@ -0,0 +1,42 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-core_CONFIG_VAR
HAVE_ERT
HAVE_SUITESPARSE_UMFPACK_H
HAVE_DUNE_ISTL
HAVE_MPI
HAVE_PETSC
)
# dependencies
set (opm-core_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# matrix library
"BLAS REQUIRED"
"LAPACK REQUIRED"
# Tim Davis' SuiteSparse archive
"SuiteSparse COMPONENTS umfpack"
# solver
"SuperLU"
# xml processing (for config parsing)
"TinyXML"
# Ensembles-based Reservoir Tools (ERT)
"ERT REQUIRED"
# Look for MPI support
"MPI"
# PETSc numerical backend
"PETSc"
# DUNE dependency
"dune-common"
"dune-istl"
# Parser library for ECL-type simulation models
"opm-parser REQUIRED"
)

View File

@ -0,0 +1,21 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-material_CONFIG_VAR
HAVE_MPI
HAVE_VALGRIND
HAVE_FINAL
)
# dependencies
set (opm-material_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features REQUIRED"
# prerequisite OPM modules
"opm-core REQUIRED"
# DUNE dependency
"dune-common REQUIRED"
)

View File

@ -0,0 +1,21 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-polymer_CONFIG_VAR
)
# dependencies
set (opm-polymer_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# Ensembles-based Reservoir Tools
"ERT"
# OPM dependency
"opm-core"
)

View File

@ -0,0 +1,24 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-porsol_CONFIG_VAR
)
# dependencies
set (opm-porsol_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# DUNE dependency
"dune-common REQUIRED;
dune-istl REQUIRED;
dune-grid REQUIRED;
opm-core REQUIRED;
opm-material REQUIRED;
dune-cornerpoint REQUIRED"
)

View File

@ -0,0 +1,31 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-upscaling_CONFIG_VAR
HAVE_SUPERLU
)
# dependencies
set (opm-upscaling_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# matrix library
"BLAS REQUIRED"
"LAPACK REQUIRED"
# solver
"SuperLU"
# DUNE dependency
"dune-common REQUIRED;
dune-istl REQUIRED;
dune-geometry REQUIRED;
dune-grid REQUIRED;
opm-core REQUIRED;
dune-cornerpoint REQUIRED;
opm-porsol REQUIRED"
)

View File

@ -0,0 +1,19 @@
# -*- 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:
# defines that must be present in config.h for our headers
set (opm-verteq_CONFIG_VAR
)
# dependencies
set (opm-verteq_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.44.0
COMPONENTS date_time filesystem system iostreams unit_test_framework REQUIRED"
# OPM dependency
"opm-core"
)

739
cmake/OPM-CMake.md Normal file
View File

@ -0,0 +1,739 @@
OPM Build System
================
This is the documentation for the build system used in various OPM modules.
In the following, `xxx` is used as a placeholder for the project name (e.g.
"core").
Unlike traditional CMake files which is highly imperative, OPM projects
sets up declarative lists of prerequisites and content and rely on convention
and pre-made modules to do the build. Its goal is to replace but be
compatible with the old autotools-based system.
## Terminology
In the build system to following abstract locations are referred to:
<table><thead><tr><th>Location<th>Description<tbody>
<tr>
<td> Source tree
<td>
This is where the source files are located. Usually this directory is created
by a `git clone`. You edit files in this directory. The build system on the
other hand will never touch these files; they could be read-only for that
matter. It should be located on a disk that is backed up. The source trees
for various OPM modules should be siblings to eachother.
<tr>
<td> Build tree
<td>
This is where you do `make` (or `ninja`), and the compiler/linker will put
its output here. It may be the same directory as the source tree (which is
then called an "in-tree build"). However, it is recommended that you keep
it separate. Do `make clean && make distclean` to remove all files that
are created by the build (if you put it in the source directory).
You don't need to backup these files (since they can be generated from the
source); instead this directory should be located somewhere with fast
write access. The build trees for various OPM modules should be siblings
(unless they are subdirectories in their source trees).
<tr>
<td> Installation tree
<td>
This is where the build system will put all the final libraries and headers
when running `make install`.
You can specify another location for the installation tree by setting the
CMake variable `CMAKE_INSTALL_PREFIX` on the command line (or use `--prefix=`
with the configure script). Notice that the portion of this path which
will become the new filesystem root should be specified with the environment
variable `DESTDIR`.
</table>
## Use Cases
This section lists some common use cases for adding new code to a project
with respect to the build system, and lists the steps that must be undertaken
to do the necessary modifications.
### Adding a Translation Unit
1. Put the file in a sub-directory of `opm/xxx`.
2. Add the file name to the `MAIN_SOURCE_FILES` list in `CMakeLists_files.txt`.
Please keep this list sorted.
3. If you are adding new interfaces that will be used by client code, add the
header to the `PUBLIC_HEADER_FILES`. Note that any `_impl` headers containing
template implementations must also be included.
### Adding a Prerequisite
1. Add the name of the prerequisite module to the `opm-xxx_DEPS` list in the file
`cmake/Modules/opm-xxx-prereqs.cmake`, where xxx is a placeholder for the module
name of your CMake project.
2. If you need any CMake configuration defines available in your public _headers_,
add these to the `opm-xxx_CONFIG_VAR` list in the same file. Please refrain
from this practice as it imposes a requirement on the clients of your code to
gather the same configuration information and make it available in the units
which uses your headers.
### Adding a Unit Test
1. Put the source code in a single translation unit in directory `tests`. The
name of this unit should start with `test_`.
2. Put any datafiles this code rely on in the same directory. The code should
assume that such datafiles are available in the current directory the program
is running from. The code should not write to these files, but rather make
a copy if it needs to modify them.
3. Add the file name to the `TEST_SOURCE_FILES` list in `CMakeLists_files.txt`.
4. Add the datafiles to the `TEST_DATA_FILES` list in the same files. The
files will be copied from the source tree into the target tree.
### Adding a New Utility Program
1. Put the source code of the utility in the `examples` directory.
2. Add the name of the translation unit to the `PROGRAM_SOURCE_FILES` list
in `CMakeLists_files.txt`.
### Creating a New Module
1. Copy the directory `cmake/` and all sub-directories from opm-core. This
directory contains the common build system, and should ideally be identical
across OPM projects. Also copy the file `configure` in the project root.
2. Create project-specific files using those from another project as a template.
The list of project specific files is in the section
[Modules Reference](#project-specific-files) below.
3. Create a new file `cmake/Modules/opm-xxx-prereqs.cmake`, using one of the
existing ones as a template.
4. Optionally, create a new file `cmake/Modules/Findopm-xxx.cmake`, using one
of the existing ones as a template.
## Options
These options regulate the behaviour of the build system. In addition to these
options, you can also set standard CMake options, or options for the
prerequisites, which is not documented here. If you run the configure script
with the `--help` option, it will print a text of what the options are called
when using the autotools-compatible wrapper.
<table><thead><tr><th>Option<th>Description<tbody>
<tr>
<td> BUILD_EXAMPLES
<td>
Include the examples when doing a build. Whenever you change something
in the library, however small, all the examples will also be rebuilt.
Default is ON.
<tr>
<td> BUILD_TESTING
<td>
Include the unit tests when doing a build. Whenever you change something
in the library, however small, all the unit tests will also be rebuilt.
Default is ON.
<tr>
<td> PRECOMPILE_HEADERS
<td>
Precompile common headers into a binary blob which is loaded on further
compilations. If your compiler supports this, it usually reduces build
time. It does not affect the running time of the code. Default is OFF.
<tr>
<td> SIBLING_SEARCH
<td>
Search for OPM/DUNE prerequisites in sibling directories of the build
tree. Default is ON.
<tr>
<td> SUITESPARSE_USE_STATIC
<td>
Link SuiteSparse/UMFPack statically. Using this option will enable you
to build an executable which has no external dependencies. The default
is to use shared libraries if those are available.
<tr>
<td> SYSTEM_DEBUG
<td>
Put debug symbols in the system debug directory (`/usr/lib/debug`) as
this seems to be the only place which is searched by default by GDB.
Default is OFF, as it requires that you have write access to that
directory. Note that if you are doing a system installation (set
CMAKE_INSTALL_PREFIX=/usr), then the libraries will be put in this
location irregardless of this option.
<tr>
<td> USE_MPI
<td>
Enable the code to use MPI for parallelization. Default is OFF.
Note: It is important that OPM and DUNE modules is either all
compiled with MPI support or that none is. The build system will
attempt to recognize inconsistencies.
<tr>
<td> USE_OPENMP
<td>
Enable the code to use OpenMP for parallelization. Default is ON.
<tr>
<td> USE_RUNPATH
<td>
Remember the directories from where the prerequisites were found
when building. Default is ON, which enables you to run without
setting PATH all over the place in your build directories. When
creating an installation package, this should be set off.
<tr>
<td> USE_UNDERSCORING
<td>
Assume that Fortran externals have an underscore suffix instead
of checking this with an actual compiler. If you set this option,
you can use Fortran libraries (notably BLAS and LAPACK) without
having a Fortran compiler installed. The default is OFF.
<tr>
<td> USE_VERSIONED_DIR
<td>
Put libraries in a directory which includes the label of the project,
e.g. `/usr/lib/opm-core/2013.10`. Default is OFF.
<tr>
<td> WITH_NATIVE
<td>
Optimize for the instruction set of the build machine. This is
a good idea if you are building the library on the same machine
as you will be using the library. Default is ON.
<tr>
<td> WHOLE_PROG_OPTIM
<td>
Perform an extra round of optimization when linking the program.
(Usually the compiler only optimizes within the translation unit).
If your compiler supports this, it usually leads to a faster runtime.
Default is OFF.
</table>
## Modules Reference
### Project-specific Files
All of these files are in the project root.
<table><thead><tr><th>File<th>Description<tbody>
<tr>
<td> CMakeLists.txt
<td>
Project-specific customizations to the build, such as filtering out source
files based on the availability of prerequisites, or adding configuration
variables only the implementation depends on.
Prefer to do customizations in the hooks available to this file rather than
adding ad-hoc code to the build system itself, to keep the `cmake/` directory
unified across projects.
<tr>
<td> CMakeLists_files.txt
<td>
List of all compilation modules in the project, test cases and public
headers that should be installed in the distribution package. The contents
of these lists are distributed to project-specific variables by the build
system.
<tr>
<td> CTestConfig.cmake
<td>
Settings for submitting result of tests to CDash. The default is setup
to submit to [the official CDash panel](http://www.opm-project.org/CDash/)
and does not need to be changed if your module has a panel there.
<tr>
<td> dune.module
<td>
Information about the project such as name, release label, link version
and maintainer. Also specify dependencies to other OPM/DUNE-projects so
that dunecontrol can build in correct order. (Note that the full list of
dependencies is taken from opm-xxx-prereqs.cmake and not from here).
Since this file must be present before the build starts (for dunecontrol),
the version information is kept here.
</table>
### Project Modules
These modules contains the dependency information for this project, so
the build system can set up the prerequisite list correctly and probe
for other modules automatically. (This replaces hard-coded calls to
find_library in the CMakeLists.txt file).
<table><thead><tr><th>File (.cmake)<th>Description<tbody>
<tr>
<td> xxx-prereqs
<td>
List prerequisite modules and defines used in public headers. Each module
must have such a "declaration", and this must be made available to every
other projects as well (which is why this is located in `cmake/Modules`).
<tr>
<td> Findxxx
<td>
CMake modules which locates module `xxx` in the system directories. As
the `opm-xxx-config.cmake` is made available together with the libraries
and headers, these modules are not really needed (for OPM modules).
</table>
### Generated Files
These files are generated by the build system and exists in the _build_ tree,
not in the source tree. They are documented here to make developers aware of
their role in the build system.
<table><thead><tr><th>File<th>Description<tbody>
<tr>
<td> config.h
<td>
Settings variables which the build system has configured and make available
to the source code. This file is **not** installed amongst the headers, so
you should never include this in a public header, even if you need the value
in one of these variables. Instead, you must rely on the client code to
configure this variable for you.
<tr>
<td> opm-xxx.pc
<td>
pkg-config information file to locate the **build** tree. This is used by
the autotools build files, but can also be handy when manually building
small test programs for which you don't generate an own build system.
<tr>
<td> opm-xxx-config.cmake
<td>
CMake information file to locate the **build** tree. This file is imported
when this project is set up as a prerequisite.
<tr>
<td> opm-xxx-install.pc
<td>
pkg-config information file to locate the **installation** tree. It is
the same as `opm-xxx.pc` except that the paths are switched. When the
project is installed, this file is installed instead (under `lib/pkgconfig`
relative to the installation root). This directory should hence be put
in the search path to pkg-config to use the installed package. Before
installation, this file is worthless and should not be included, because
it does not refer to the build tree at all. (Be careful not to mix
the build and the installation tree).
Notice that the build system will forward a bunch of public definitions
which should be available to compile code referring to this library.
<tr>
<td> opm-xxx-install.cmake
<td>
CMake information file to locate the **installation** tree. It is the
same as `opm-xxx-config.cmake` except that the paths are switched. When
the project is installed, this file is installed instead (under `share/cmake`
relative to the installation root).
<tr>
<td> opm-xxx-config-version.cmake
<td>
CMake wants to include this into the build _before_ it is determined whether
the library was found successfully (depending on the version number perhaps),
so this information is put in its own file. Since it is the same for the
build tree and the installation tree, it is shared in both those locations.
</table>
### Utility Modules
These modules consists of useful routines which is not OPM-specific and
that could be used in any projects. They don't depend on any other parts
of the build system.
<table><thead><tr><th>File (.cmake)<th>Description<tbody><tr>
<td> AddOptions
<td>
Functions to add options to compiler command line (e.g. 'CXXFLAGS').
This macro can add options to more than one language and/or configuration
at a time, and also automatically removes duplicates.
<tr>
<td> ConfigVars
<td>
Functions to write values of selected variables to `config.h`. The
advantage of using this compared to a template file, is that other
modules can add their own variables to be written (a project doesn't
need to know which variables a prerequisite wants to have in config.h).
<tr>
<td> DuneCompat
<td>
Modify `Makefile` so dunecontrol can infer source directory from it.
dunecontrol infers the source location of prerequisites from textual
analysis of the Makefile in their build tree. (dunecontrol cannot build
with Ninja anyway, so that is not a problem).
<tr>
<td> Duplicates
<td>
Functions to remove duplicate values from a list of libraries, which
must always be done from the beginning in order to link correctly.
<tr>
<td> LibtoolArchives
<td>
Write .la file which will make libtool find our library. This enables
users of our library to use libtool even if we did not do so ourselves.
</table>
### Build System Modules
These are the modules which comprises the OPM-specific parts of the
build system. The overall flow through the stages of the build is best
captured by reading through the `OpmLibMain.cmake` module.
<table><thead><tr><th>File (.cmake)<th>Description<tbody>
<tr>
<td> configure
<td>
Wrapper script which emulates an autotools front-end, making the build
system usable with dunecontrol. There is one in the project root directory
which just forwards everything to the main script in `cmake/Scripts`.
<tr>
<td> OpmAliases
<td>
Copy variables which are probed by our find modules to the names which
are expected by DUNE.
<tr>
<td> OpmCompile
<td>
Set up a compilation target for the library itself. It is assumed that
each OPM project build exactly one library file containing all its code.
The files and compiler options are passed through the project variables
(see the section [Variables Reference](#variables-reference) below).
<tr>
<td> OpmDefaults
<td>
If optimization and debugging settings are not given on the command line,
supply a set of reasonable defaults for the detected platform and
compiler.
<tr>
<td> OpmDistClean
<td>
Add a target (`make distclean`) to the build system which can remove the
build files themselves from the build directory tree.
<tr>
<td> OpmDoc
<td>
Add target for building documentation, primarily Doxygen class reference
from the code.
<tr>
<td> OpmFiles
<td>
Load list of files from `CMakeLists_files.txt` and put into the applicable
variables.
<tr>
<td> OpmGrid
<td>
Adds the grid type selection code to config.h which is needed by dune-grid
if you want to set up a default grid. This is currently not needed by any
OPM project, and is provided only for porting client projects which previously
used this functionality from the autotools version.
<tr>
<td> OpmInit
<td>
Read the version information and project name from `dune.module`.
<tr>
<td> OpmInstall
<td>
Setup installation of the main library, public headers and debug symbols.
<tr>
<td> OpmKnown
<td>
Marks as "used" all configuration variables which is used only by some of
the OPM projects, so they don't generate warnings in the rest of them.
<tr>
<td> OpmLibMain
<td>
Driver module for the build process. First reads the list of prerequisites
and options, then set up the compiles and installations.
<tr>
<td> OpmProject
<td>
Set up pkg-config and CMake information files (see [Generated Files]
(#generated-files)) for this project, based on configuration.
<tr>
<td> OpmSatellites
<td>
Build test programs and examples for a library that is bundled in the project.
</table>
### Wrapper Modules
These modules wrap the CMake `find_library` function and adds the information
retrieved from the imported prerequisite to module-specific variables, so that
these can be added to the build in batch afterwards.
<table><thead><tr><th>File (.cmake)<th>Description<tbody>
<tr>
<td> OpmFind
<td>
Wrapper around `find_package`. Searches in various locations relative to this
project as well as in the system directories for a CMake module which can
locate the package. If it is found, adds the project variables (see
[Variables Reference](#variables-reference)) for this project into this one,
for instance include and library directories are added to the compile and link
command-line for this project.
<tr>
<td> OpmPackage
<td>
Typical way of finding an OPM package; searches for the header and library,
and tries to compile a test program. This is the general implementation of
a CMake find module, and is used to locate those of the prerequisites that
fits the pattern.
</table>
### Configuration Modules
These are modules for altering the compiler and/or linker option in some way,
or get information from the system. They are not tied to the OPM projects.
<table><thead><tr><th>File (.cmake)<th>Description<tbody>
<tr>
<td> UseCompVer
<td>
Get the version of GCC that is used to compile the project. This is used in
other modules to enable features that are known to exist/work only in certain
versions of GCC.
<tr>
<td> UseDebugSymbols
<td>
Set up the compile to generate debug symbols for the code. This is done also
if a release build was requested, to be able to do post-mortem debugging of
production code. (The debug symbols does not inhibit optimization).
<tr>
<td> UseDuneVer
<td>
Retrieve the version of DUNE which is available.
<tr>
<td> UseDynamicBoost
<td>
Determine if Boost is linked statically or dynamically (shared). This is
necessary to know for the unit tests.
<tr>
<td> UseFastBuilds
<td>
Enable certain techniques which is known to speed up the build itself.
<tr>
<td> UseFortranWrappers
<td>
Provide a macro for declaration of external symbols which is located in
Fortran libraries. It is not necessary to have a Fortran compiler present
to use this macro.
<tr>
<td> UseMultiArch
<td>
Check if the system uses the multi-arch scheme for organizing libraries
(currently derivatives of Debian do this).
<tr>
<td> UseOnlyNeeded
<td>
Only link to libraries which is actually used by the project. Some
platforms provide "under-linked" libraries (they need other libraries
but doesn't state so explicitly, but rather imply that the executable
must link to these itself), and this is also handled.
<tr>
<td> UseOpenMP
<td>
Add OpenMP features to the build. Since OpenMP is activated by pragmas
in the code, compiler options instead of libraries are needed.
<tr>
<td> UseOptimization
<td>
Compile with more extensive optimization that what is the default in
CMake.
<tr>
<td> UsePrecompHeaders
<td>
Set up precompiled headers if the project has a `opm/xxx/opm-xxx-pch.hpp`
header. Due to problems across various compilers, this is currently an
opt-in feature.
<tr>
<td> UseSystemInfo
<td>
Retrieve information about the system the build is performed on. This is
printed in the configuration log and can be helpful to troubleshoot
problems from error reports.
<tr>
<td> UseVCSInfo
<td>
Retrieve information about which Git revision is compiled. This is useful
to figure out which version an error report refers to.
<tr>
<td> UseVersion
<td>
Add version information for this project into the library binary, making
it available for query at runtime.
<tr>
<td> UseWarnings
<td>
Enable a more extensive set of warnings to be reported by the compiler
than what is the default in CMake.
</table>
## Variables Reference
The build system will setup variables with names of the pattern `xxx_YYY`
where xxx is the project name (here including the suite; e.g. "opm-core")
and yyy is the suffix in the list below. The project name is used verbatim,
i.e. there is no translation of dashes and case ("opm-core" and not "OPM_CORE").
<table><thead><tr><th>Suffix<th>Description<tbody>
<tr>
<td> _DEFINITIONS
<td>
Macro defines (of the type `-DFOO`) that needs to be added to the compile
of translation units contained in this library. This also includes defines
that must be present to headers which is included by this library.
<tr>
<td> _CONFIG_VARS
<td>
Defines which should be present in `config.h` of the project which
includes this library (client code). Only the names of the variables
are listed here; the actual values must be found by the configuration
script of the client.
<tr>
<td> _CONFIG_IMPL_VARS
<td>
Defines which should be present in `config.h` but is only used by
the internal code of the project itself. Use this list to get
defines without imposing a requirement on client code to also probe
for values.
<tr>
<td> _INCLUDE_DIR
<td>
Directory where the public headers of this project are stored.
<tr>
<td> _INCLUDE_DIRS
<td>
List of include directories that must be on the compiler search
path to compile code which uses this project. In addition to the
headers of this project itself, it also includes the transitive
closure of paths for all prerequisites as well.
<tr>
<td> _LABEL
<td>
Currently for OPM projects, this follows a pattern of `YYYY.MM`
where YYYY is the year of the release and MM is the month. This
gives information to humans about how up to date this instance
of the library is (but doesn't provide a way to check for
compatibility, which is why the VERSION alternatives exist).
<tr>
<td> _LIBRARY
<td>
Name and path of the binary to link with.
<tr>
<td> _LIBRARIES
<td>
Full list of the library of both this project, and all its
prerequisites, that need to be included in the link. I.e. the
client code should only include the transitive list from its
immediate prerequisites and not know about the full dependency
graph.
<tr>
<td> _LIBRARY_DIRS
<td>
Directories that should be added to the linker search path when
including this library.
<tr>
<td> _LINKER_FLAGS
<td>
Flags that must be added to the link when including this library.
<tr>
<td> _SOURCES
<td>
List of source files contained in this project. This enables libraries
to be distributed in source form (e.g. CJSON and TinyXML) and linked
directly into the project.
<tr>
<td> _TARGET
<td>
Name of the library which is generated by this project. CMake and
autotools do not like library names which contains dashes, so they
are stripped out. By using a macro for this we are guaranteed uniform
translation.
<tr>
<td> _VERSION
<td>
Textual concatenation of all components of the version number (see below)
with a dot inbetween. This form of version number can be compared using
CMake VERSION_{LESS|EQUAL|GREATER} operators.
<tr>
<td> _VERSION_MAJOR
<td>
Major version of the library. If the major versions doesn't match, then
compatibility with existing code cannot be reckoned.
<tr>
<td> _VERSION_MINOR
<td>
Minor version of the library. Libraries with newer minor version can
have more features, but should be able to run old code.
<tr>
<td> _VERSION_REVISION
<td>
Micro version of the library. This number is generally incremented
whenever bugfixes or performance improvements are made.
</table>

View File

@ -0,0 +1,99 @@
find_package(Git REQUIRED)
macro(sanity_check message)
if(status_code)
message(FATAL_ERROR "${message}")
endif()
endmacro()
# Check that there are no changes in working-tree
execute_process(COMMAND ${GIT_EXECUTABLE} diff --quiet
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
sanity_check("Cannot run with working tree changes. Commit, stash or drop them.")
# Setup base of tests
set(check_base $ENV{CHECK_BASE})
if(NOT check_base)
set(check_base origin/master)
endif()
# Setup end of tests
set(check_head $ENV{CHECK_HEAD})
if(NOT check_head)
set(check_head HEAD)
endif()
# Setup target to build
set(check_target $ENV{CHECK_TARGET})
if(NOT check_target)
set(check_target all;test)
endif()
# Build threads
set(build_threads $ENV{CHECK_THREADS})
if(NOT build_threads)
if(UNIX)
if(APPLE)
execute_process(COMMAND sysctl hw.ncpu
OUTPUT_VARIABLE build_threads)
string(REPLACE " " ";" build_threads_list ${build_threads)
list(GET build_threads_list 1 build_threads)
else()
find_program(NPROC_COMMAND nproc)
if(NPROC_COMMAND)
execute_process(COMMAND ${NPROC_COMMAND}
OUTPUT_VARIABLE build_threads)
string(REGEX REPLACE "(\r?\n)+$" "" build_threads "${build_threads}")
endif()
endif()
endif()
endif()
# If for some reason we could not find the info - e.g. centos5 where nproc is missing
if(NOT build_threads)
set(build_threads 1)
endif()
# Record current HEAD
execute_process(COMMAND ${GIT_EXECUTABLE} rev-parse --abbrev-ref HEAD
OUTPUT_VARIABLE current_branch
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(REGEX REPLACE "(\r?\n)+$" "" current_branch "${current_branch}")
# Grab revision list
execute_process(COMMAND ${GIT_EXECUTABLE} rev-list ${check_base}..${check_head} --reverse
OUTPUT_VARIABLE rev_list
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
string(REPLACE "\n" ";" rev_list ${rev_list})
foreach(rev ${rev_list})
# Checkout
message("Testing revision ${rev}")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${rev}
RESULT_VARIABLE status_code
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
sanity_check("Failed to checkout ${rev}")
# Build
foreach(tgt ${check_target})
if(build_threads GREATER 2)
execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${tgt}" "--use-stderr" "--" "-j${build_threads}"
RESULT_VARIABLE status_code)
else()
execute_process(COMMAND ${CMAKE_COMMAND} "--build" "${CMAKE_BINARY_DIR}" "--target" "${tgt}" "--use-stderr"
RESULT_VARIABLE status_code)
endif()
sanity_check("Failed to build target '${tgt}'")
endforeach()
if(status_code)
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})
endif()
sanity_check("Failed to build target for revision ${rev}")
endforeach()
message("Everything checks out fine")
execute_process(COMMAND ${GIT_EXECUTABLE} checkout ${current_branch}
WORKING_DIRECTORY ${PROJECT_SOURCE_DIR})

View File

@ -0,0 +1,25 @@
# - Emulate a rule to patch the Makefile, adding a line to the source
# tree and write a marker file indicating it is done.
set (base_dir ".")
set (marker_file "${base_dir}/CMakeFiles/marker")
set (makefile "${base_dir}/Makefile")
# if the Makefile has changed, then update it
if ("${makefile}" IS_NEWER_THAN "${marker_file}")
# only add the string once, so it does not return multiple
# results for the command line (will lead to syntax error)
file (STRINGS "${makefile}" abs_top_srcdir_FOUND
REGEX "^abs_top_srcdir = "
)
if (NOT abs_top_srcdir_FOUND)
file (APPEND "${makefile}"
"abs_top_srcdir = ${CMAKE_HOME_DIRECTORY}\n"
)
endif (NOT abs_top_srcdir_FOUND)
# touch the marker so that we won't update the Makefile again
execute_process (COMMAND
${CMAKE_COMMAND} -E touch "${marker_file}"
)
endif ("${makefile}" IS_NEWER_THAN "${marker_file}")

View File

@ -0,0 +1,15 @@
# - Remove a directory if and only if it contains no files
#
# Pass the name of the directory as the DIR variable
if (DIR)
# check if empty
file (GLOB_RECURSE files "${DIR}/*")
# remove only if
if (NOT files)
execute_process (COMMAND
${CMAKE_COMMAND} -E remove_directory "${DIR}"
)
endif (NOT files)
endif (DIR)

View File

@ -0,0 +1,63 @@
# - This script must be passed the following information
#
# GIT_EXECUTABLE Path to the Git executable
# PROJECT_SOURCE_DIR Path to the source directory
# PROJECT_BINARY_DIR Path to the build directory
# PROJECT_LABEL String that identifies the minor
# version of the project, e.g. "2013.03"
#
# get hash code
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS rev-parse --short --verify HEAD
OUTPUT_VARIABLE sha1
RETURN_VALUE has_sha
)
# exec_program unfortunately mashes together both output
# and error streams, so we must use the return code to make
# sure that we only get the output
if (NOT ${has_sha} EQUAL 0)
set (sha1 "")
endif ()
# check for local changes
if (sha1)
# unstaged
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff --no-ext-diff --quiet --exit-code
RETURN_VALUE dirty
OUTPUT_VARIABLE _dummy
)
# staged
exec_program (
${GIT_EXECUTABLE} ${PROJECT_SOURCE_DIR}
ARGS diff-index --no-ext-diff --cached --quiet --exit-code HEAD --
RETURN_VALUE staged
OUTPUT_VARIABLE _dummy
)
# if we found any changes, then append an asterisk to
# the SHA1 so we know that it cannot be trusted
if (dirty OR staged)
set (sha1 "${sha1}*")
endif ()
# make a formatted version that can be appended to the label
set (sha1 " (${sha1})")
endif ()
# write the content to a temporary file in a C compatible format
file (WRITE "${PROJECT_BINARY_DIR}/project-version.tmp"
"#define PROJECT_VERSION \"${PROJECT_LABEL}${sha1}\"\n"
)
# only commit this to source code if it actually changed. here
# we use execute_process instead of exec_program to avoid having
# it printed on the console every time
execute_process (COMMAND
${CMAKE_COMMAND} -E copy_if_different "${PROJECT_BINARY_DIR}/project-version.tmp" "${PROJECT_BINARY_DIR}/project-version.h"
)

551
cmake/Scripts/configure vendored Executable file
View File

@ -0,0 +1,551 @@
#!/bin/bash
# where is the source tree located by default relative to here
srcdir=$(dirname "$(dirname "$(dirname "$0")")")
# display help text
usage () {
cat <<EOF
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]. Note: set DESTDIR=PATH when doing
\`make install' to install to a different sysroot.
Optional Features:
--disable-FEATURE do not include FEATURE
--disable-gxx11check do not try flag -std=c++11 to enable C++11 features
--enable-shared build a shared library [default=yes]
--enable-static build a static library [default=no]. Note: only one
of the options shared and static may be built.
--enable-debug build a non-optimized version of the library
[default=no]
--disable-runpath do not use RUNPATH in installed library [default=yes]
--enable-lto use whole program optimization [default=no]
--enable-strip-debug separate the executable code and the debugging symbols [default=no]
--disable-tests do not compile and enable unit tests [default=yes]
--disable-examples do not compile example programs [default=yes]
--disable-pch do not use precompiled headers (if buggy compiler)
--disable-silent-rules print every compilation statement as executed
--enable-system-debug put .debug files in global GDB debug dir
[default=yes if prefix=/usr, no otherwise]
--enable-parallel process in parallel using MPI [default=no]
--enable-openmp activate experimental support for OpenMP
--disable-option-checking ignore unrecognized --enable/--with options
--enable-underscoring assume Fortran routines have _ suffix [default=no]
--enable-ninja use Ninja build generator [default=no]
(automatically implies --enable-underscoring)
--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
--with-dune=PATH specify parent of all DUNE modules not specified
--with-dune-MODULE=PATH use given DUNE module from a specified location
--with-opm=PATH specify parent of all OPM modules not specified
--with-opm-MODULE=PATH use given OPM module from a specified location
--with-superlu=PATH user defined path to SuperLU library
--with-umfpack=PATH use UMFPACK/SuiteSparse from a specified location
--with-ert=PATH Use ERT libraries
--with-tinyxml=PATH use TinyXML library from a specified location
(Note: if not found, then a bundled library will
be used)
--with-cmake=PROGRAM use this program instead of \`cmake' to configure
--with-buildname=TEXT description passed to the CDash configuration
--with-site=TEXT site passed to the CDash configuration
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
CXX C++ compiler command
CXXFLAGS C++ compiler flags
CXXCPP C++ preprocessor
F77 Fortran 77 compiler command
FFLAGS Fortran 77 compiler flags
FC Fortran compiler command
FCFLAGS Fortran compiler flags
CMAKE_COMMAND Executable used to run cmake scripts
Use these variables to override the choices made by \`configure' or to help
it to find libraries and programs with nonstandard names/locations.
EOF
}
# report an error regarding the arguments
invalid_arg () {
cat <<EOF
configure: error: unrecognized option: \`$1'
Try \`$0 --help' for more information
EOF
}
# notify the user that this argument is not known
unknown_arg () {
cat <<EOF
configure: warning: unrecognized option: \`$1'
EOF
}
# warn only if option checking is enabled
invalid_opt () {
if [ "${option_check}" = "yes" ]; then
unknown_arg "$@"
fi
}
# default values
prefix=/usr/local
#c_compiler=" -DCMAKE_C_COMPILER=cc"
c_compiler=
c_opts=
#cxx_compiler=" -DCMAKE_CXX_COMPILER=c++"
cxx_compiler=
cxx_opts=
#fort_compiler=" -DCMAKE_Fortran_COMPILER=fc"
fort_compiler=
fort_opts=
#buildtype=" -DCMAKE_BUILD_TYPE=Debug"
buildtype=
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
pch_use=
#use_openmp=" -DUSE_OPENMP=OFF"
use_openmp=
use_mpi=
#silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF"
silent_rules=
#debug_loc=" -DSYSTEM_DEBUG=OFF"
debug_loc=
#use_lto=" -DWHOLE_PROG_OPTIM=OFF"
use_lto=
#strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=OFF"
strip_debug=
#use_runpath=" -DUSE_RUNPATH=OFF"
use_runpath=
#use_tests=" -DBUILD_TESTING=ON"
use_tests=
#use_samples=" -DBUILD_EXAMPLES=ON"
use_samples=
#use_ninja="-G\"Unix Makefiles\" "
use_ninja=
#use_underscoring=" -DUSE_UNDERSCORING=OFF"
use_underscoring=
# boost_root=""
boost_root=
boost_libdir=
boost_opts=
# configuration that is passed on to CTest/CDash
buildname=
site=
# if set, this prevents the previous CMake cache from being deleted
config_cache=
# default is to warn for unknown options, but this can be disabled
option_check=yes
# this variable will get feature options
FEATURES=
# this array will get all variable assignments from command-line
VARS=()
# command that launches cmake; look for 2.8 if available
if [ "${CMAKE_COMMAND}" = "" ]; then
if [ -x "$(command -v cmake28)" ]; then
CMAKE_COMMAND=cmake28
else
CMAKE_COMMAND=cmake
fi
fi
# helper routine
uppercase () {
echo "$@" | tr "a-z-" "A-Z_"
}
for OPT in "$@"; do
case "$OPT" in
--*)
OPTARG=${OPT#--}
# OPTARG now contains everything after double dashes
case "${OPTARG}" in
config-cache|cache-file=*)
# prevent the previous CMake cache from being deleted. The
# second option is only here for Dune/autotools compatibility
config_cache="1"
;;
src-dir=*)
# allow the user to use these build macros for another
# project (so source-dir is not relative to us)
srcdir=${OPTARG#*=}
;;
prefix=*)
# remove prefix consisting of everything up to equal sign
prefix=${OPTARG#*=}
;;
help)
usage
exit 0
;;
with-*)
# get the name of the package; everything before equal sign
pkgname=${OPTARG%=*}
pkgname=${pkgname#with-}
# get the location of the package; everyhing after equal sign
test -n "${OPTARG#with-${pkgname}}" && pkgloc=${OPTARG#*=} || pkgloc=""
# the parameter to this option is an executable program, so
# skip the directory test in that case. if we match any of
# these special options, then stop further processing (the
# argument is not a directory anyway)
case "${pkgname}" in
cmake)
CMAKE_COMMAND="${pkgloc}"
continue
;;
buildname)
buildname=" -DBUILDNAME=\"${pkgloc}\""
continue
;;
site)
site=" -DSITE=\"${pkgloc}\""
continue
;;
esac
# tilde expansion; quote safely before running eval on it
eval pkgloc=$(printf "%q" "${pkgloc}")
# expand to full path since CMake changes to source directory (!)
# this also normalize the path name wrt. not having a trailing slash
test -d "${pkgloc}" && pkgloc=$(sh -c "cd \"${pkgloc}\"; pwd")
# special aliases
case "${pkgname}" in
umfpack)
pkgname="SuiteSparse"
;;
tinyxml)
pkgname="TinyXML"
;;
esac
# packages need different suffix for their root (sic)
case "${pkgname}" in
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
rootvar=""
;;
mpi |\
mpi-prefix)
# specifying path implies use of package
use_mpi=" -DUSE_MPI=ON"
# only set prefix if specified, i.e. setting doubles as flag
test -n "${pkgloc}" && rootvar="_MPI_PREFIX_PATH" || rootvar=""
;;
boost)
# special handling of this package, see further below
boost_root="${pkgloc}"
rootvar=""
;;
boost-libdir)
boost_libdir="${pkgloc}"
rootvar=""
;;
alugrid |\
eigen3 |\
ert |\
metis |\
superlu |\
SuiteSparse |\
TinyXML |\
ug |\
opm |\
opm-* |\
dune |\
dune-* |\
zlib)
rootvar="$(uppercase ${pkgname})_ROOT"
rootvar="${rootvar/-/_}"
;;
*)
invalid_opt --with-${pkgname}
rootvar=""
;;
esac
# add this to the list of existing features
test -n "${rootvar}" && \
FEATURES="${FEATURES} \"-D${rootvar}=${pkgloc}\""
;;
without-* | \
disable-*)
# get the name of the package
pkgname=$OPTARG
pkgname=${pkgname#disable-}
pkgname=${pkgname#without-}
# casing is of course different
case "${pkgname}" in
option-checking)
option_check=no
# special flag: don't disable any particular package
pkgname=""
;;
debug)
buildtype=" -DCMAKE_BUILD_TYPE=Release"
# special flag: don't disable any particular package
pkgname=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
pkgname=""
;;
runpath)
use_runpath=" -DUSE_RUNPATH=OFF"
pkgname=""
;;
silent-rules)
silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON"
pkgname=""
;;
system-debug)
debug_loc=" -DSYSTEM_DEBUG=OFF"
pkgname=""
;;
wpo |\
lto )
use_lto=" -DWHOLE_PROG_OPTIM=OFF"
pkgname=""
;;
strip-debug )
strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=OFF"
pkgname=""
;;
openmp)
use_openmp=" -DUSE_OPENMP=OFF"
pkgname=""
;;
mpi | \
parallel)
use_mpi=" -DUSE_MPI=OFF"
pkgname=""
;;
tests)
use_tests=" -DBUILD_TESTING=OFF"
pkgname=""
;;
examples)
use_samples=" -DBUILD_EXAMPLES=OFF"
pkgname=""
;;
ninja)
# just for symmetry with the --enable-ninja option
use_ninja=""
pkgname=""
;;
ert |\
superlu)
pkgname="$(uppercase ${pkgname})"
;;
openmp)
pkgname="OpenMP"
;;
gxx11check)
pkgname="CXX11Features"
;;
umfpack)
pkgname="SuiteSparse"
;;
tinyxml)
pkgname="TinyXML"
;;
*)
invalid_opt --disable-${pkgname}
pkgname=""
;;
esac
# only disable packages if the flag refers to a proper one
test -n "${pkgname}" && \
FEATURES="${FEATURES} -DCMAKE_DISABLE_FIND_PACKAGE_${pkgname}=TRUE"
;;
enable-*)
# what kind of library are we building; shared or static?
kind=${OPTARG#enable-}
case "${kind}" in
system-debug)
debug_loc=" -DSYSTEM_DEBUG=ON"
# special flag; don't set shared/static
shared=""
;;
openmp)
use_openmp=" -DUSE_OPENMP=ON"
# special flag; don't set shared/static
shared=""
;;
mpi | \
parallel)
use_mpi=" -DUSE_MPI=ON"
# special flag; don't set shared/static
shared=""
;;
debug)
buildtype=" -DCMAKE_BUILD_TYPE=Debug"
shared=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
shared=""
;;
runpath)
use_runpath=" -DUSE_RUNPATH=ON"
shared=""
;;
lto)
use_lto=" -DWHOLE_PROG_OPTIM=ON"
shared=""
;;
strip-debug )
strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=ON"
pkgname=""
;;
tests)
use_tests=" -DBUILD_TESTING=ON"
pkgname=""
;;
examples)
use_samples=" -DBUILD_EXAMPLES=ON"
pkgname=""
;;
underscoring)
use_underscoring=" -DUSE_UNDERSCORING=ON"
pkgname=""
;;
ninja)
# Ninja doesn't support using the Fortran compiler, so
# we'll have to resort to making this assumption
use_underscoring=" -DUSE_UNDERSCORING=ON"
use_ninja="-GNinja "
pkgname=""
;;
# this flag is just for compatibility with the deprecation
# flag in DUNE, so we can build without warnings
fieldvector-size-is-method)
shared=""
;;
shared)
shared="ON"
;;
static)
shared="OFF"
;;
*)
invalid_opt "--enable-${kind}"
shared=""
;;
esac
test -n "${shared}" && \
FEATURES="${FEATURES} -DBUILD_SHARED_LIBS:BOOL=${shared}"
# once we have added this, reset so we don't add again for next opt
shared=""
;;
*)
# remove everything *after* the equal sign
arg=${OPTARG%=*}
invalid_arg "--$arg"
exit 1
;;
esac
;;
[A-Za-z0-9_]*=*)
# collect for further processing later
VARS+=("$OPT")
;;
*)
invalid_arg "$OPT"
exit 1
;;
esac
done
# remove all arguments processed by getopts
shift $((OPTIND-1))
# special handling of Boost: if --with-boost-libdir has been used,
# then the --with-boost turns into specifying the header directory
# and not the search root. this mirrors the functionality in the
# Autotools ax_boost_base.m4. necessary because FindBoost in CMake
# uses two different variables if you want to specify them separately
if [ -n "${boost_libdir}" ]; then
boost_opts=" -DBOOST_LIBRARYDIR=\"${boost_libdir}\""
if [ -n "${boost_root}" ]; then
boost_opts="${boost_opts} -DBOOST_INCLUDEDIR=\"${boost_root}\""
fi
else
if [ -n "${boost_root}" ]; then
boost_opts=" -DBOOST_ROOT=\"${boost_root}\""
else
boost_opts=""
fi
fi
# notice the usage of a quoted array: each element will be returned
# even with spaces.
for a in "${VARS[@]}"; do
case "$a" in
ACLOCAL_*=*)
# remove Autotools-specific variables.
;;
CC=*)
# special processing for compiler options
a=${a#CC=}
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\""
;;
CXX=*)
a=${a#CXX=}
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\""
;;
CFLAGS=*)
a=${a#CFLAGS=}
c_opts=" -DCMAKE_C_FLAGS=\"${a/\"/\\\"}\""
;;
CXXFLAGS=*)
a=${a#CXXFLAGS=}
cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\""
;;
FC=*)
a=${a#FC=}
[ -x "$(command -v "$a")" ] && a=$(command -v "$a")
fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\""
;;
FFLAGS=*)
a=${a#FFLAGS=}
fort_opts=" -DCMAKE_Fortran_FLAGS=\"${a/\"/\\\"}\""
;;
*)
ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
;;
esac
done
# only wrap in env command if any variable were actually passed
[ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} "
# delete the previous 'CMakeFiles' directory. this prevents an endless
# loop if variables that require a full regeneration of the cache are
# set (most notably 'CXX' and 'CXX_FLAGS').
# For more details, see http://www.cmake.org/Bug/view.php?id=14119
if test "$config_cache" = ""; then
echo "--- deleting previous CMake files ---"
rm -rf CMakeFiles
rm -f CMakeCache.txt
elif test "$c_compiler$c_opts$cxx_compiler$cxx_opts$fort_compiler$fort_opts" != ""; then
echo "--- WARNING '--config-cache' option specified but a compiler was set"
echo "--- from the command line. This may lead to an infinite loop!"
fi
# pass everything on to CMake
CMDLINE="${ENVVARS}${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${strip_debug}${use_runpath}${use_tests}${use_samples}${use_underscoring}${c_compiler}${c_opts}${cxx_compiler}${cxx_opts}${fort_compiler}${fort_opts}${boost_opts}${buildname}${site} ${FEATURES}"
echo --- calling CMake ---
echo "${CMDLINE}"
eval exec "${CMDLINE}"

1705
cmake/Templates/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,185 @@
<doxygenlayout version="1.0">
<!-- Navigation index tabs for HTML output -->
<navindex>
<tab type="mainpage" visible="yes" title="OPM"/>
<tab type="pages" visible="yes" title="Tutorials" intro=""/>
<tab type="modules" visible="yes" title="" intro=""/>
<tab type="namespaces" visible="yes" title="">
<tab type="namespaces" visible="yes" title="" intro=""/>
<tab type="namespacemembers" visible="yes" title="" intro=""/>
</tab>
<tab type="classes" visible="yes" title="">
<tab type="classes" visible="yes" title="" intro=""/>
<tab type="classindex" visible="$ALPHABETICAL_INDEX" title=""/>
<tab type="hierarchy" visible="yes" title="" intro=""/>
<tab type="classmembers" visible="yes" title="" intro=""/>
</tab>
<tab type="files" visible="yes" title="">
<tab type="files" visible="yes" title="" intro=""/>
<tab type="globals" visible="yes" title="" intro=""/>
</tab>
<tab type="dirs" visible="yes" title="" intro=""/>
<tab type="examples" visible="yes" title="" intro=""/>
</navindex>
<!-- Layout definition for a class page -->
<class>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<inheritancegraph visible="$CLASS_GRAPH"/>
<collaborationgraph visible="$COLLABORATION_GRAPH"/>
<allmemberslink visible="yes"/>
<memberdecl>
<nestedclasses visible="yes" title=""/>
<publictypes title=""/>
<publicslots title=""/>
<signals title=""/>
<publicmethods title=""/>
<publicstaticmethods title=""/>
<publicattributes title=""/>
<publicstaticattributes title=""/>
<protectedtypes title=""/>
<protectedslots title=""/>
<protectedmethods title=""/>
<protectedstaticmethods title=""/>
<protectedattributes title=""/>
<protectedstaticattributes title=""/>
<packagetypes title=""/>
<packagemethods title=""/>
<packagestaticmethods title=""/>
<packageattributes title=""/>
<packagestaticattributes title=""/>
<properties title=""/>
<events title=""/>
<privatetypes title=""/>
<privateslots title=""/>
<privatemethods title=""/>
<privatestaticmethods title=""/>
<privateattributes title=""/>
<privatestaticattributes title=""/>
<friends title=""/>
<related title="" subtitle=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<constructors title=""/>
<functions title=""/>
<related title=""/>
<variables title=""/>
<properties title=""/>
<events title=""/>
</memberdef>
<usedfiles visible="$SHOW_USED_FILES"/>
<authorsection visible="yes"/>
</class>
<!-- Layout definition for a namespace page -->
<namespace>
<briefdescription visible="yes"/>
<memberdecl>
<nestednamespaces visible="yes" title=""/>
<classes visible="yes" title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection visible="yes"/>
</namespace>
<!-- Layout definition for a file page -->
<file>
<briefdescription visible="yes"/>
<includes visible="$SHOW_INCLUDE_FILES"/>
<includegraph visible="$INCLUDE_GRAPH"/>
<includedbygraph visible="$INCLUDED_BY_GRAPH"/>
<sourcelink visible="yes"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<functions title=""/>
<variables title=""/>
</memberdef>
<authorsection/>
</file>
<!-- Layout definition for a group page -->
<group>
<briefdescription visible="yes"/>
<groupgraph visible="$GROUP_GRAPHS"/>
<memberdecl>
<classes visible="yes" title=""/>
<namespaces visible="yes" title=""/>
<dirs visible="yes" title=""/>
<nestedgroups visible="yes" title=""/>
<files visible="yes" title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
<membergroups visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
<memberdef>
<pagedocs/>
<inlineclasses title=""/>
<defines title=""/>
<typedefs title=""/>
<enums title=""/>
<enumvalues title=""/>
<functions title=""/>
<variables title=""/>
<signals title=""/>
<publicslots title=""/>
<protectedslots title=""/>
<privateslots title=""/>
<events title=""/>
<properties title=""/>
<friends title=""/>
</memberdef>
<authorsection visible="yes"/>
</group>
<!-- Layout definition for a directory page -->
<directory>
<briefdescription visible="yes"/>
<directorygraph visible="yes"/>
<memberdecl>
<dirs visible="yes"/>
<files visible="yes"/>
</memberdecl>
<detaileddescription title=""/>
</directory>
</doxygenlayout>

41
cmake/Templates/la.in Normal file
View File

@ -0,0 +1,41 @@
# lib@target@.la - a libtool library file
# Generated by libtool (GNU libtool) @ltversion@
#
# Please DO NOT delete this file!
# It is necessary for linking the library.
# The name that we can dlopen(3).
dlname='@dlname@'
# Names of this library.
library_names='@library_names@'
# The name of the static archive.
old_library='@old_library@'
# Linker flags that can not go in dependency_libs.
inherited_linker_flags='@inherited_linker_flags@'
# Libraries that this one depends upon.
dependency_libs='@dependency_libs@'
# Names of additional weak libraries provided by this library
weak_library_names=''
# Version information for lib@target@.
current=@current@
age=@age@
revision=0
# Is this an already installed library?
installed=no
# Should we warn about portability when linking against -modules?
shouldnotlink=no
# Files to dlopen/dlpreopen
dlopen=''
dlpreopen=''
# Directory that this library needs to be installed in:
libdir='@libdir@'

View File

@ -0,0 +1,28 @@
# - CMake version file for @opm-project_NAME@
#
# Determine if requested version matches exactly or is compatible with
# the installed package. It sets the following variables:
#
# PACKAGE_VERSION Full provided version string
# PACKAGE_VERSION_COMPATIBLE True if version is compatible
# PACKAGE_VERSION_EXACT True if version is exact match
# This file is used by find_package to see if the installed version of a
# package can be used by the client, before the main -config.cmake file
# is loaded.
# see <http://www.cmake.org/Wiki/CMake/Tutorials/Packaging#Package_Version_Files>
# this is the version that is installed
set (PACKAGE_VERSION @opm-project_VERSION@)
# if we wanted this exact version, then everything's fine
if (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
set (PACKAGE_VERSION_EXACT TRUE)
endif (PACKAGE_VERSION VERSION_EQUAL PACKAGE_FIND_VERSION)
# in general, we assume that there is going to be API breakage between
# released versions; this will hopefully change in the future
## compatible versions
#if (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)
# set (PACKAGE_VERSION_COMPATIBLE TRUE)
#endif (NOT PACKAGE_VERSION VERSION_LESS PACKAGE_FIND_VERSION)

View File

@ -0,0 +1,66 @@
# - @opm-project_DESCRIPTION@ config mode
#
# Defines the following variables:
# @opm-project_NAME@_FOUND - true
# @opm-project_NAME@_VERSION - version of the @opm-project_NAME@ library found, e.g. 0.2
# @opm-project_NAME@_DEFINITIONS - defines to be made on the command line
# @opm-project_NAME@_INCLUDE_DIRS - header directories with which to compile
# @opm-project_NAME@_LINKER_FLAGS - flags that must be passed to the linker
# @opm-project_NAME@_LIBRARIES - names of the libraries with which to link
# @opm-project_NAME@_LIBRARY_DIRS - directories in which the libraries are situated
#
# You should put lines like this in your CMakeLists.txt
# set (@opm-project_NAME@_DIR "${PROJECT_BINARY_DIR}/../@opm-project_NAME@" CACHE LOCATION "Build tree of @opm-project_NAME@")
# find_package (@opm-project_NAME@)
# configure_vars (
# FILE CXX "${PROJECT_BINARY_DIR}/config.h"
# WRITE ${@opm-project_NAME@_CONFIG_VARS}
# )
# <http://www.vtk.org/Wiki/CMake/Tutorials/How_to_create_a_ProjectConfig.cmake_file>
# propagate these properties from one build system to the other
set (@opm-project_NAME@_VERSION "@opm-project_VERSION@")
set (@opm-project_NAME@_DEFINITIONS "@opm-project_DEFINITIONS@")
set (@opm-project_NAME@_INCLUDE_DIRS "@opm-project_INCLUDE_DIRS@")
set (@opm-project_NAME@_LIBRARY_DIRS "@CMAKE_LIBRARY_OUTPUT_DIRECTORY@")
set (@opm-project_NAME@_LINKER_FLAGS "@opm-project_LINKER_FLAGS@")
set (@opm-project_NAME@_CONFIG_VARS "@opm-project_CONFIG_VARS@")
# libraries come from the build tree where this file was generated
set (@opm-project_NAME@_LIBRARY "@opm-project_LIBRARY@")
set (@opm-project_NAME@_LIBRARIES ${@opm-project_NAME@_LIBRARY} "@opm-project_LIBRARIES@")
mark_as_advanced (@opm-project_NAME@_LIBRARY)
# not all projects have targets; conditionally add this part
if (NOT "@opm-project_TARGET@" STREQUAL "")
# add the library as a target, so that other things in the project including
# this file may depend on it and get rebuild if this library changes.
add_library (@opm-project_TARGET@ UNKNOWN IMPORTED)
set_property (TARGET @opm-project_TARGET@ PROPERTY IMPORTED_LOCATION "${@opm-project_NAME@_LIBRARY}")
endif (NOT "@opm-project_TARGET@" STREQUAL "")
# ensure that we build with support for C++11 to preserve ABI
string (REPLACE "@CXX_STD0X_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (REPLACE "@CXX_STDLIB_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
set (CMAKE_CXX_FLAGS "@CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ ${CMAKE_CXX_FLAGS}")
# same as above, but for C99
string (REPLACE "@C_STD99_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
set (CMAKE_C_FLAG "@C_STD99_FLAGS@ ${CMAKE_C_FLAGS}")
# build with OpenMP if that was found
if (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
string (REPLACE "@OpenMP_C_FLAGS@" "" CMAKE_C_FLAGS "${CMAKE_C_FLAGS}")
string (STRIP "${CMAKE_C_FLAGS}" CMAKE_C_FLAGS)
set (CMAKE_C_FLAG "@OpenMP_C_FLAGS@ ${CMAKE_C_FLAGS}")
endif (NOT "@OpenMP_C_FLAGS@" STREQUAL "")
if (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
string (REPLACE "@OpenMP_CXX_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
set (CMAKE_C_FLAG "@OpenMP_CXX_FLAGS@ ${CMAKE_CXX_FLAGS}")
endif (NOT "@OpenMP_CXX_FLAGS@" STREQUAL "")
# this is the contents of config.h as far as our probes can tell:

View File

@ -0,0 +1,13 @@
prefix=@prefix@
libdir=@libdir@
includedir=@includedir@
CXX=@CMAKE_CXX_COMPILER@ @CXX_STD0X_FLAGS@@CXX_SPACE@@CXX_STDLIB_FLAGS@ @OpenMP_CXX_FLAGS@
CC=@CMAKE_C_COMPILER@ @C_STD99_FLAGS@ @OpenMP_C_FLAGS@
DEPENDENCIES=
Name: @name@
Description: @description@ @major@.@minor@
Version: @major@.@minor@
URL: http://opm-project.org
Libs: @target@ @libs@
Cflags: @includes@ @defs@

11
cmake/Templates/style.css Normal file
View File

@ -0,0 +1,11 @@
/* Userspesific CSS for doxygen */
body, table, div, p, dl {
font-family: Lucida Grande, Verdana, Geneva, Arial, sans-serif;
font-size: 16px;
}
h1 {
font-size: 120%;
}

Some files were not shown because too many files have changed in this diff Show More