Import cmake/ from commit 5f82198c in opm-core

This commit is contained in:
Roland Kaufmann 2013-02-18 15:07:43 +01:00
parent d2d0c52176
commit 2b1c1c70b9
56 changed files with 6952 additions and 0 deletions

281
CMakeLists.txt Normal file
View File

@ -0,0 +1,281 @@
# -*- 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:
# key information about the library
set (project "opm-core")
set (${project}_NAME "${project}")
set (${project}_DESCRIPTION "Open Porous Media Initiative Core Library")
set (${project}_DIR "opm")
set (${project}_VERSION_MAJOR 1)
set (${project}_VERSION_MINOR 0)
set (doxy_dir "Documentation")
# defines that must be present in config.h for our headers
set (${project}_CONFIG_VAR
HAVE_AGMG
HAVE_DUNE_ISTL
HAVE_DYNAMIC_BOOST_TEST
HAVE_ERT
HAVE_SUITESPARSE_UMFPACK_H
HAVE_NULLPTR
HAVE_STATIC_ASSERT
)
# dependencies
set (${project}_DEPS
# compile with C99 support if available
"C99"
# compile with C++0x/11 support if available
"CXX11Features"
# various runtime library enhancements
"Boost 1.39.0
COMPONENTS date_time filesystem system 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"
# DUNE dependency
"dune-istl"
)
# C++ project
cmake_minimum_required (VERSION 2.8)
project (${${project}_NAME})
enable_language (C)
enable_language (CXX)
# additional search modules
set (${project}_MODULE_DIR "${PROJECT_SOURCE_DIR}/cmake/Modules")
list (APPEND CMAKE_MODULE_PATH ${${project}_MODULE_DIR})
# 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 ()
# include special
if (CMAKE_VERSION VERSION_LESS "2.8.7")
message (STATUS "Enabling backward compatibility modules for CMake ${CMAKE_VERSION}")
list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.7")
endif (CMAKE_VERSION VERSION_LESS "2.8.7")
# 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)
# macro to set standard variables (INCLUDE_DIRS, LIBRARIES etc.)
include (OpmFind)
find_and_append_package_list_to (${project} ${${project}_DEPS})
# 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)
# optimize full if we're not doing a debug build
include (UseOptimization)
# turn on all warnings
include (UseWarnings)
# detect if Boost is in a shared library
include (UseDynamicBoost)
# needed for Debian installation scheme
include (UseMultiArch)
# 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
opm_sources (${project})
# enumerate all testing programs in test/ directory
opm_find_tests ()
# tutorial programs are found in the tutorials/ directory
opm_find_tutorials ()
# example programs are found in the examples/ directory
opm_find_examples ()
### --- begin AGMG specific --- ###
# Algebraic Multigrid must be compiled together with our program;
# if it is not available, then remove our corresponding component
find_package (AGMG)
if (AGMG_FOUND)
list (APPEND ${project}_SOURCES ${AGMG_SOURCES})
endif (AGMG_FOUND)
### --- end AGMG specific --- ###
### --- begin opm-core specific --- ###
# these solvers are only compiled in if their dependency is found
if (NOT AGMG_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/linalg/LinearSolverAGMG.cpp
)
endif (NOT AGMG_FOUND)
if (NOT dune-istl_FOUND)
list (REMOVE_ITEM opm-core_SOURCES
${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 tutorial_SOURCES
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial2.cpp
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial3.cpp
${PROJECT_SOURCE_DIR}/${tutorial_DIR}/tutorial4.cpp
)
list (REMOVE_ITEM examples_SOURCES
${PROJECT_SOURCE_DIR}/${examples_DIR}/spu_2p.cpp
)
endif (NOT SuiteSparse_FOUND)
# these files are provided in source control, but can only compile with Matlab
# available; we are not supposed to include the TinyXML test prog. regardless
list (REMOVE_ITEM opm-core_SOURCES
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/grid/cpgpreprocess/mxgrdecl.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/grid/cpgpreprocess/processgrid.c
${PROJECT_SOURCE_DIR}/${opm-core_DIR}/core/utility/parameters/tinyxml/xmltest.cpp
)
# remove inline TinyXML if a system version was found
if (TinyXML_FOUND)
file (GLOB_RECURSE _inline_tinyxml "${opm-core_DIR}/core/utility/parameters/tinyxml/*")
foreach (_file IN LISTS _inline_tinyxml)
list (REMOVE_ITEM opm-core_SOURCES ${_file})
endforeach (_file)
endif (TinyXML_FOUND)
# anyhow remove it from the header list (so it doesn't get installed)
list (REMOVE_ITEM opm-core_HEADERS "${opm-core_DIR}/core/utility/parameters/tinyxml/tinystr.h")
list (REMOVE_ITEM opm-core_HEADERS "${opm-core_DIR}/core/utility/parameters/tinyxml/tinyxml.h")
# HAVE_ERT is used as an #ifdef, not as an #if in the source code, if it
# is not true, then it should be unset altogether
if (NOT HAVE_ERT)
set (HAVE_ERT)
list (REMOVE_ITEM examples_SOURCES
${PROJECT_SOURCE_DIR}/examples/import_rewrite.cpp
)
endif (NOT HAVE_ERT)
### --- end opm-core specific --- ###
# 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})
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h")
configure_vars (
FILE CXX ${CONFIG_H}
WRITE ${${project}_CONFIG_VARS}
)
include (UseFortranWrappers)
define_fc_func (
APPEND ${CONFIG_H}
IF HAVE_AGMG # HAVE_BLAS HAVE_LAPACK
)
# 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)
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)
# tutorial programs are found in the tutorials/ directory
opm_compile_satellites (${project} tutorial "" "")
opm_compile_satellites (${project} examples "" "")
# infrastructure for testing
enable_testing ()
include (CTest)
### --- begin opm-core specific --- ###
# 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)
cond_disable_test ("AGMG")
cond_disable_test ("ERT")
### --- end opm-core specific --- ###
# make datafiles necessary for tests available in output directory
opm_data (tests datafiles "${tests_DIR}" "*.xml")
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
# 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)
configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
### clean in-source builds ###
include (OpmDistClean)
opm_dist_clean (${project})
# smart wrapper that auto-parallelizes builds
file (COPY
GNUmakefile
DESTINATION ${PROJECT_BINARY_DIR}
)

7
CTestConfig.cmake Normal file
View File

@ -0,0 +1,7 @@
# this is included after opm-core_NAME is set
set(CTEST_PROJECT_NAME "${${project}_NAME}")
set(CTEST_NIGHTLY_START_TIME "01:00:00 UTC")
set(CTEST_DROP_METHOD "http")
set(CTEST_DROP_SITE "opm-project.org")
set(CTEST_DROP_LOCATION "/CDash/submit.php?project=${${project}_NAME}")
set(CTEST_DROP_SITE_CDASH TRUE)

43
GNUmakefile Normal file
View File

@ -0,0 +1,43 @@
# GNUmakefile is processed before Makefile, which is why we arrive here
# first; when we call the other makefile, then we must specify its real
# name with the -f parameter
# figure out the number of processors from the system, add one and round
# to nearest integer. this is the maximum number of processes we want running
# at the same time (one for each core and one stuck on I/O)
# if we are running this is a VM, then /proc won't be mounted and we revert
# to single CPU processing
CPUINFO:=/proc/cpuinfo
NUM_CPUS:=$(shell test -r $(CPUINFO) && grep -P -c '^processor\t:' $(CPUINFO) || echo 0)
PROCS:=$(shell echo "("$(NUM_CPUS)+1")"/1 | bc)
# use these utilities if they are available
IONICE:=$(shell test -x "$$(which ionice)" && echo ionice -c2 -n7)
NICE:=$(shell test -x "$$(which nice)" && echo nice)
# we do dependency management the right way; don't attempt to cache
export CCACHE_DISABLE:=1
# ignore that there may be files with these names, we are going to call
# the other make regardless
.PHONY: __everything $(MAKECMDGOALS)
# outsource the processing to the real makefile, running in parallel and
# in a nice environment so that it doesn't hog our workstation. if there
# is nothing else happening on the box, then it will run just as fast
# the leading plus makes us run this regardless of options, see
# http://www.gnu.org/software/make/manual/make.html#Instead-of-Execution
__everything:
# only put on a parallel flag if there isn't already one; otherwise we
# get the warning "-jN forced in submake: disabling jobserver mode".
# this have to happen inside the rule, because -j option is removed from
# MAKEFLAGS outside
+@$(IONICE) $(NICE) $(MAKE) --no-print-directory -f Makefile $(if $(findstring -j,$(MAKEFLAGS)),,-j $(PROCS)) $(MAKECMDGOALS)
# automatically generate all the goals we are asked to make and delegate
# processing of them to the real makefile through the dependency (since
# everything depends on the same thing, then we only call the other make
# once). the dummy command is just there to make sure that make doesn't
# show the "Nothing to do for `foo'" message after processing
$(MAKECMDGOALS): __everything
@true

View File

@ -0,0 +1,59 @@
# - 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"))
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)
# if it wasn't there, then add it at the end
if ("${_without}" STREQUAL "${${_var}}")
# don't add any extra spaces if no options yet are set
if (NOT ${${_var}} STREQUAL "")
set (${_var} "${${_var}} ${_opt}")
else (NOT ${${_var}} STREQUAL "")
set (${_var} "${_opt}")
endif (NOT ${${_var}} STREQUAL "")
set (${_var} "${${_var}}" PARENT_SCOPE)
endif ("${_without}" STREQUAL "${${_var}}")
endforeach (_opt)
endforeach (build)
endforeach (lang)
endfunction (add_options lang build)

View File

@ -0,0 +1,110 @@
# - 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
message (STATUS "Writing config file \"${filename}\"...")
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}" STREQUAL "config.h")
add_definitions (-DHAVE_CONFIG_H=1)
include_directories (BEFORE "${_config_path}")
endif ("${_config_file}" STREQUAL "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 "^/[/*]")
# 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 ""))
# integer variables (specifically 0 and 1) are written as they are,
# whereas everything else (including version numbers, which could
# be interpreted as floats) are quoted as strings
if (${_var} MATCHES "[0-9]+")
set (_quoted "${${_var}}")
else (${_var} MATCHES "[0-9]+")
set (_quoted "\"${${_var}}\"")
endif (${_var} MATCHES "[0-9]+")
# write to file using the correct syntax
if ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "set (${_var} ${_quoted})\n")
else ("${syntax}" STREQUAL "CMAKE")
file (APPEND "${filename}" "#define ${_var} ${_quoted}\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,23 @@
# - 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 ${PROJECT_SOURCE_DIR}/cmake/Scripts/DuneCompat2.cmake
COMMENT "Patching Makefile to be DUNE compatible"
)
endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")

View File

@ -0,0 +1,44 @@
# - Find Notay's Algebraic Multigrid Solver
#
# Set the path to the source directory of AGMG in the cache variable
# AGMG_ROOT.
#
# Note the difference between AGMG_DIR and AGMG_ROOT. The former will
# cause find_package to switch to config mode and search for a file
# named agmg-config.cmake, thereby bypassing this module altogether,
# whereas the latter communicates the location of the library to this
# module.
#
# When found, add the contents of AGMG_SOURCES to your own list of
# sources to compile and link for the target.
#
# Use define_fc_func from UseFortranWrappers to write FC_FUNC to your
# own config.h, and declare the function dagmg using this macro.
find_file (AGMG_SOURCES
dagmg.f90
PATHS ${AGMG_ROOT}
PATH_SUFFIXES SRC
DOC "Yvan Notay's Algebraic Multigrid Solver, Double Precision version"
NO_DEFAULT_PATH
)
# make sure that we can compile Fortran code
if (AGMG_SOURCES)
enable_language (Fortran)
endif (AGMG_SOURCES)
# set value for config.h
if (AGMG_SOURCES)
set (HAVE_AGMG 1)
else (AGMG_SOURCES)
set (HAVE_AGMG 0)
endif (AGMG_SOURCES)
# handle REQUIRED and QUIET standard options
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (AGMG
DEFAULT_MSG
AGMG_SOURCES
CMAKE_Fortran_COMPILER_SUPPORTS_F90
)

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,260 @@
#
# Module that checks for supported C++11 (former C++0x) features.
#
# Sets the follwing variable:
#
# HAVE_NULLPTR True if nullptr is available
# 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_INTEGRAL_CONSTANT True if compiler supports integral_constant
# HAVE_STATIC_ASSERT True if static_assert is available
# HAVE_VARIADIC_TEMPLATES True if variadic templates are supprt
# HAVE_VARIADIC_CONSTRUCTOR_SFINAE True if variadic constructor sfinae is supported
# HAVE_RVALUE_REFERENCES True if rvalue references are supported
# test for C++11 flags
include(TestCXXAcceptsFlag)
# 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)
# perform tests
include(CheckCXXSourceCompiles)
# nullptr
CHECK_CXX_SOURCE_COMPILES("
int main(void)
{
char* ch = nullptr;
return 0;
}
" HAVE_NULLPTR
)
# 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
)
# __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
)
# 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)

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

@ -0,0 +1,209 @@
# - 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)
# 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"
)
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"
)
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"
)
# need all of these libraries
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" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Eclipse library archive/shared object files"
)
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" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Geometry library archive/shared object files"
)
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" "lib64" "lib32" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
DOC "Path to ERT Utilities library archive/shared object files"
)
# 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_GEOMETRY}
${ERT_LIBRARY_UTIL}
)
list (APPEND ERT_LIBRARIES ${ERT_LIBRARY})
list (APPEND ERT_INCLUDE_DIRS ${ERT_INCLUDE_DIR})
# 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
# enabling OpenMP is supposedly enough to make the compiler link with
# the appropriate libraries
find_package (OpenMP ${ERT_QUIET})
list (APPEND ERT_LIBRARIES ${OpenMP_LIBRARIES})
if (OPENMP_FOUND)
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
endif (OPENMP_FOUND)
# threading library (search for this *after* OpenMP
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
find_package (Threads ${ERT_QUIET})
if (CMAKE_USE_PTHREADS_INIT)
list (APPEND ERT_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
endif (CMAKE_USE_PTHREADS_INIT)
# 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)
# 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)
if (ERT_INCLUDE_DIRS)
list (REMOVE_DUPLICATES ERT_INCLUDE_DIRS)
endif (ERT_INCLUDE_DIRS)
if (ERT_LIBRARIES)
list (REVERSE ERT_LIBRARIES)
list (REMOVE_DUPLICATES ERT_LIBRARIES)
list (REVERSE ERT_LIBRARIES)
endif (ERT_LIBRARIES)
# linker flags may not be specified at all
if (DEFINED ERT_LINKER_FLAGS)
list (REMOVE_DUPLICATES ERT_LINKER_FLAGS)
endif (DEFINED ERT_LINKER_FLAGS)
# 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) {
int sz;
sz = ecl_util_get_sizeof_ctype (ECL_INT_TYPE);
return 0;
}" HAVE_ERT)
cmake_pop_check_state ()
else (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND"))
set (HAVE_ERT 0)
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
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (ERT
DEFAULT_MSG
ERT_INCLUDE_DIR ERT_LIBRARY HAVE_ERT
)

View File

@ -0,0 +1,162 @@
#
# 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_PREFIX 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.
#
# adds SuperLU flags to the targets
function(add_dune_superlu_flags _targets)
if(SUPERLU_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} ${SUPERLU_DUNE_LIBRARIES})
get_target_property(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS
"${_props} ${SUPERLU_DUNE_COMPILE_FLAGS} -DENABLE_SUPERLU=1")
endforeach(_target ${_targets})
endif(SUPERLU_FOUND)
endfunction(add_dune_superlu_flags)
# look for BLAS
find_package(BLAS QUIET REQUIRED)
if(NOT BLAS_FOUND)
message(WARNING "SuperLU requires BLAS which was not found, skipping the test.")
return()
endif(NOT BLAS_FOUND)
# look for header files, only at positions given by the user
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATHS ${SUPERLU_PREFIX}
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
NO_DEFAULT_PATH
)
# look for header files, including default paths
find_path(SUPERLU_INCLUDE_DIR
NAMES supermatrix.h
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
)
# look for library, only at positions given by the user
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_PREFIX}
PATH_SUFFIXES "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
NO_DEFAULT_PATH
)
# look for library files, including default paths
find_library(SUPERLU_LIBRARY
NAMES "superlu_4.3" "superlu_4.2" "superlu_4.1" "superlu_4.0" "superlu_3.1" "superlu_3.0" "superlu"
PATH_SUFFIXES "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
)
# check version specific macros
include(CheckCSourceCompiles)
include(CMakePushCheckState)
cmake_push_check_state()
# we need if clauses here because variable is set variable-NOTFOUND
# if the searches above were not successful
# Without them CMake print errors like:
# "CMake Error: The following variables are used in this project, but they are set to NOTFOUND.
# Please set them or make sure they are set and tested correctly in the CMake files:"
#
if(SUPERLU_INCLUDE_DIR)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${SUPERLU_INCLUDE_DIR})
endif(SUPERLU_INCLUDE_DIR)
if(SUPERLU_LIBRARY)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${SUPERLU_LIBRARY})
endif(SUPERLU_LIBRARY)
if(BLAS_LIBRARIES)
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} ${BLAS_LIBRARIES})
endif(BLAS_LIBRARIES)
# 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 whether version is at least 4.3
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(SUPERLU_MIN_VERSION_4_3)
# 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} ${BLAS_LIBRARIES})
set(SUPERLU_DEFINITIONS "-DENABLE_SUPERLU=1")
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determing location of ${SUPERLU_WITH_VERSION} succeded:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
set(SUPERLU_DUNE_COMPILE_FLAGS "-I${SUPERLU_INCLUDE_DIRS}"
CACHE STRING "Compile flags used by DUNE when compiling SuperLU programs")
set(SUPERLU_DUNE_LIBRARIES ${SUPERLU_LIBRARIES} ${BLAS_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuperLU programs")
else(SUPERLU_FOUND)
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuperLU failed:\n"
"Include directory: ${SUPERLU_INCLUDE_DIRS}\n"
"Library directory: ${SUPERLU_LIBRARIES}\n\n")
endif(SUPERLU_FOUND)
# set HAVE_SUPERLU for config.h
if(SUPERLU_FOUND)
set(HAVE_SUPERLU 1)
else(SUPERLU_FOUND)
set(HAVE_SUPERLU 0)
endif(SUPERLU_FOUND)

View File

@ -0,0 +1,259 @@
# - 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
#
# 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)
set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES})
# search paths for the library outside of standard system paths. these are the
# paths in which the package managers on various distros put the files
list (APPEND SuiteSparse_SEARCH_PATH "/usr") # Linux
list (APPEND SuiteSparse_SEARCH_PATH "/opt/local") # MacOS X
# 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})
# 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)
# 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 suitesparseconfig
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES ".libs" "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
)
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"
)
find_library (${MODULE}_LIBRARY
NAMES ${module}
PATHS ${SuiteSparse_SEARCH_PATH}
PATH_SUFFIXES "lib/.libs" "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse"
)
# 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)
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)
endif (HAVE_UMFPACK_WITHOUT_CHOLMOD)
# test if umfpack is underlinked (CentOS 5.9), i.e. doesn't specify
# that it depends on amd. in that case, force amd to be linked
if ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
try_compile_umfpack (HAVE_UMFPACK_NOT_UNDERLINKED "-Wl,--as-needed" ${UMFPACK_EXTRA_LIBS})
if (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
list (APPEND UMFPACK_LINKER_FLAGS "-Wl,--no-as-needed")
endif (NOT HAVE_UMFPACK_NOT_UNDERLINKED)
endif ((CMAKE_CXX_PLATFORM_ID STREQUAL "Linux") AND CMAKE_COMPILER_IS_GNUCC)
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)
set (HAVE_SUITESPARSE_${MODULE}_H 0 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)
# on MacOS X the libraries are in a framework directory and an option must be
# added on the compile line to relate headers to that directory
if (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
list (APPEND SuiteSparse_DEFINITIONS "-framework Accelerate")
endif (${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
# 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,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
"")

View File

@ -0,0 +1,57 @@
# - 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
"
# 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
"HAVE_ARRAY;
HAVE_BOOST_MAKE_SHARED_HPP;
HAVE_BOOST_SHARED_PTR_HPP;
HAVE_GMP;
HAVE_MAKE_SHARED;
HAVE_MPI;
HAVE_NULLPTR;
HAVE_STATIC_ASSERT;
HAVE_TR1_TUPLE;
HAVE_TYPE_TRAITS;
HAVE_TUPLE
")
#debug_find_vars ("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 (OpmPackage)
find_opm_package (
# module name
"dune-cornerpoint"
# dependencies
"dune-common REQUIRED;
dune-grid REQUIRED;
opm-core REQUIRED
"
# header to search for
"dune/grid/CpGrid.hpp"
# library to search for
"dunecornerpoint"
# defines to be added to compilations
""
# test program
"#include <dune/grid/CpGrid.hpp>
int main (void) {
Dune::CpGrid g;
return 0;
}
"
# config variables
"")
#debug_find_vars ("dune-cornerpoint")

View File

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

View File

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

View File

@ -0,0 +1,62 @@
# - 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
# dune-common is only required if dune-istl is; the "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)
if (dune-istl_FIND_REQUIRED)
set (_require_dune_common "REQUIRED")
endif (dune-istl_FIND_REQUIRED)
include (OpmPackage)
find_opm_package (
# module name
"dune-istl"
# required dependencies
"dune-common ${_require_dune_common};
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;
SUPERLU_MIN_VERSION_4_3;
SUPERLU_POST_2005_VERSION
")
#debug_find_vars ("dune-istl")

View File

@ -0,0 +1,60 @@
# - 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 (OpmPackage)
find_opm_package (
# module name
"opm-core"
# dependencies
"C99;
CXX11Features;
Boost 1.39.0
COMPONENTS date_time filesystem system unit_test_framework REQUIRED;
BLAS REQUIRED;
LAPACK REQUIRED;
SuiteSparse COMPONENTS umfpack;
SUPERLU;
TinyXML;
ERT;
dune-istl
"
# 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
"HAVE_AGMG;
HAVE_DUNE_ISTL;
HAVE_DYNAMIC_BOOST_TEST;
HAVE_ERT;
HAVE_SUITESPARSE_UMFPACK_H;
HAVE_NULLPTR;
HAVE_STATIC_ASSERT
")
include (UseDynamicBoost)
#debug_find_vars ("opm-core")

View File

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

View File

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

View File

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

View File

@ -0,0 +1,150 @@
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}")
# 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 dependency_libs)
# 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)
set (dependency_libs ${deplib_list})
# 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 "${PROJECT_SOURCE_DIR}/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,52 @@
# - Compile main library target
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
set (${opm}_INCLUDE_DIR "${PROJECT_SOURCE_DIR}")
list (APPEND ${opm}_INCLUDE_DIRS "${${opm}_INCLUDE_DIR}")
# create this library
include_directories (${${opm}_INCLUDE_DIRS})
link_directories (${${opm}_LIBRARY_DIRS})
add_definitions (${${opm}_DEFINITIONS})
add_library (${${opm}_TARGET} ${${opm}_LIBRARY_TYPE} ${${opm}_SOURCES})
set (${opm}_VERSION "${${opm}_VERSION_MAJOR}.${${opm}_VERSION_MINOR}")
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})
# queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
# pre-compile common headers; this is setup *after* the library to pick
# up extra options set there
if (PRECOMPILE_HEADERS)
get_target_property (_type ${${opm}_TARGET} TYPE)
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
get_target_property (${opm}_LIBRARY ${${opm}_TARGET} LOCATION)
endmacro (opm_compile opm)

View File

@ -0,0 +1,49 @@
# - Default settings for the build
include (UseCompVer)
macro (opm_defaults opm)
# build debug by default
if (NOT CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE)
set (CMAKE_BUILD_TYPE "Debug")
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)
set (_shared_def ${BUILD_SHARED_LIBS})
else (DEFINED BUILD_SHARED_LIBS)
set (_shared_def OFF)
endif (DEFINED BUILD_SHARED_LIBS)
option (BUILD_${${opm}_NAME}_SHARED "Build ${${opm}_NAME} as a shared library" ${_shared_def})
if (BUILD_${${opm}_NAME}_SHARED)
set (${opm}_LIBRARY_TYPE SHARED)
else (BUILD_${${opm}_NAME}_SHARED)
set (${opm}_LIBRARY_TYPE STATIC)
endif (BUILD_${${opm}_NAME}_SHARED)
# 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
get_gcc_version (CXX GCC_VERSION)
if (GCC_VERSION VERSION_LESS "4.7.2")
set (_precomp_def OFF)
else (GCC_VERSION VERSION_LESS "4.7.2")
set (_precomp_def ON)
endif (GCC_VERSION VERSION_LESS "4.7.2")
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)
# 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)

View File

@ -0,0 +1,62 @@
# - 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)
set (DISTCLEAN_FILES
CMakeCache.txt
cmake_install.cmake
Makefile
config.h
${${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}
)
# only remove these files if they were actually copied
if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
list (APPEND DISTCLEAN_FILES
GNUmakefile
)
endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
# script to remove empty directories (can't believe this isn't included!)
set (rmdir "${PROJECT_SOURCE_DIR}/cmake/Scripts/RemoveEmptyDir.cmake")
add_custom_target (distclean
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 ${PROJECT_SOURCE_DIR}/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}_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,74 @@
# - 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)
# find all the source code (note that these variables have name after
# the target library and not the project). the documentation recommends
# against using globs to enumerate source code, but if you list the
# files explicitly you'll change the build files every time you add to
# the project as well as having to rebuild completely anyway.
file (GLOB_RECURSE ${opm}_C_SOURCES "${${opm}_DIR}/[^.]*.c")
file (GLOB_RECURSE ${opm}_CXX_SOURCES "${${opm}_DIR}/[^.]*.cpp")
file (GLOB_RECURSE ${opm}_C_HEADERS "${${opm}_DIR}/[^.]*.h")
file (GLOB_RECURSE ${opm}_CXX_HEADERS "${${opm}_DIR}/[^.]*.hpp")
# remove pre-compile headers from output list
file (GLOB_RECURSE ${opm}_PRECOMP_CXX_HEADER "${${opm}_DIR}/${${opm}_NAME}-pch.hpp")
if ("${${opm}_PRECOMP_CXX_HEADER}" MATCHES ";")
message (FATAL_ERROR "There can only be one precompiled header!")
endif ("${${opm}_PRECOMP_CXX_HEADER}" MATCHES ";")
list (REMOVE_ITEM ${opm}_CXX_HEADERS
${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER}
)
# merge both languages into one compilation/installation
set (${opm}_SOURCES ${${opm}_C_SOURCES} ${${opm}_CXX_SOURCES})
set (${opm}_HEADERS ${${opm}_C_HEADERS} ${${opm}_CXX_HEADERS})
endmacro (opm_sources opm)
macro (opm_find_tests)
# every C++ program prefixed with test_ under tests/ directory should
# be automatically set up as a test
set (tests_DIR "tests")
file (GLOB_RECURSE tests_SOURCES
"${tests_DIR}/test_*.cpp"
"${tests_DIR}/*_test.cpp"
)
file (GLOB_RECURSE not_tests_SOURCES
"${tests_DIR}/not-unit/test_*.cpp"
"${tests_DIR}/not-unit/*_test.cpp"
)
# how to retrieve the "fancy" name from the filename
set (tests_REGEXP
"^test_([^/]*)$"
"^([^/]*)_test$"
)
if (tests_SOURCES AND not_tests_SOURCES)
list (REMOVE_ITEM tests_SOURCES ${not_tests_SOURCES})
endif (tests_SOURCES AND not_tests_SOURCES)
endmacro (opm_find_tests)
macro (opm_find_tutorials)
# enumerate tutorials in project
set (tutorial_DIR "tutorials")
file (GLOB tutorial_SOURCES "${tutorial_DIR}/tutorial[0-9].cpp")
endmacro (opm_find_tutorials)
macro (opm_find_examples)
set (examples_DIR "examples")
file (GLOB examples_SOURCES "${examples_DIR}/*.cpp")
endmacro (opm_find_examples)

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

@ -0,0 +1,120 @@
# - 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
# )
########################################################################
#
# - Remove duplicate library declarations
#
# Synopsis:
#
# remove_duplicate_libraries (module)
#
# where
# module Name of the module whose libraries should be pruned
# list of suffixes for all the project variables
set (_opm_proj_vars
LINKER_FLAGS
LIBRARIES
DEFINITIONS
INCLUDE_DIRS
LIBRARY_DIRS
CONFIG_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)
# insert this boilerplate whenever we are going to find a new package
macro (find_and_append_package_to prefix name)
# if we have specified a directory, don't revert to searching the
# system default paths afterwards
if (${name}_DIR)
find_package (${name} ${ARGN} PATHS ${${name}_DIR} NO_DEFAULT_PATH)
else (${name}_DIR)
find_package (${name} ${ARGN})
endif (${name}_DIR)
if (${name}_FOUND)
foreach (var IN LISTS _opm_proj_vars)
if (DEFINED ${name}_${var})
list (APPEND ${prefix}_${var} ${${name}_${var}})
# cleanup lists
if ("${var}" STREQUAL "LIBRARIES")
remove_duplicate_libraries (${prefix})
else ("${var}" STREQUAL "LIBRARIES")
list (REMOVE_DUPLICATES ${prefix}_${var})
endif ("${var}" STREQUAL "LIBRARIES")
endif (DEFINED ${name}_${var})
endforeach (var)
# some libraries only define xxx_FOUND and not a corresponding HAVE_xxx
string (TOUPPER "${name}" NAME)
if (NOT DEFINED HAVE_${NAME})
set (HAVE_${NAME} 1)
endif (NOT DEFINED HAVE_${NAME})
endif (${name}_FOUND)
endmacro (find_and_append_package_to prefix name)
# 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)
# 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)

View File

@ -0,0 +1,55 @@
# - 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
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/${_rel_dir}
)
endforeach (_hdr)
install (
TARGETS ${${opm}_TARGET}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
)
# 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)
set (_dbg_prefix "${DEBUG_FILE_DIRECTORY}/")
else (SYSTEM_DEBUG)
set (_dbg_prefix "")
endif (SYSTEM_DEBUG)
# 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")
install (
FILES ${PROJECT_BINARY_DIR}/${${opm}_DEBUG}
DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}
)
endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED")
install (
FILES ${PROJECT_SOURCE_DIR}/dune.module
DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}/dunecontrol/${${opm}_NAME}
)
endmacro (opm_install opm)

View File

@ -0,0 +1,252 @@
# - 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>
# 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)
# 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)
function (find_opm_package module deps header lib defs prog conf)
# if someone else has included this test, don't do it again
if (${${module}_FOUND})
return ()
endif (${${module}_FOUND})
# dependencies on other packages; underscore version only contains the
# name of the other package
set (_deps)
foreach (_dep IN LISTS deps)
separate_arguments (_args UNIX_COMMAND ${_dep})
find_package (${_args} QUIET)
list (GET _args 0 _name_only)
list (APPEND _deps ${_name_only})
endforeach (_dep)
# 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})
# 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
if (NOT (${module}_DIR OR ${module}_ROOT))
string (TOLOWER "${module}" _module_lower)
set (_guess
"../${module}"
"../${module}-build"
"../${_module_lower}"
"../${_module_lower}-build"
)
set (_guess_bin)
foreach (_item IN ITEMS ${_guess})
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
endforeach (_item)
endif (NOT (${module}_DIR OR ${module}_ROOT))
# search for this include and library file to get the installation
# 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 ${${module}_DIR} ${${module}_ROOT} ${PkgConf_${module}_INCLUDE_DIRS}
PATH_SUFFIXES "include"
)
# some modules are all in headers
if (NOT "${lib}" STREQUAL "")
find_library (${module}_LIBRARY
NAMES "${lib}"
PATHS ${_guess_bin}
HINTS ${${module}_DIR} ${${module}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
)
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}")
set (${module}_LIBRARIES "${${module}_LIBRARY}")
foreach (_dep IN LISTS _deps)
# only add those packages we actually found (find_package will show
# an error if it was marked as REQUIRED)
if (${_dep}_FOUND)
list (APPEND ${module}_INCLUDE_DIRS ${${_dep}_INCLUDE_DIRS})
list (APPEND ${module}_LIBRARIES ${${_dep}_LIBRARIES})
list (APPEND ${module}_DEFINITIONS ${${_dep}_DEFINITIONS})
list (APPEND ${module}_CONFIG_VARS ${${_dep}_CONFIG_VARS})
list (APPEND ${module}_LINKER_FLAGS ${${_dep}_LINKER_FLAGS})
endif (${_dep}_FOUND)
endforeach (_dep)
# compile with this option to avoid avalanche of warnings
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}")
foreach (_def IN LISTS defs)
list (APPEND ${module}_DEFINITIONS "-D${_def}")
endforeach (_def)
# tidy the lists before returning them
list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS)
remove_duplicate_libraries (${module})
list (REMOVE_DUPLICATES ${module}_DEFINITIONS)
# these defines are used in dune/${module} headers, and should be put
# in config.h when we include those
foreach (_var IN LISTS 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)
foreach (_dep in _deps)
if (DEFINED ${_dep}_CONFIG_VARS)
list (APPEND ${module}_CONFIG_VARS ${_dep}_CONFIG_VARS)
endif (DEFINED ${_dep}_CONFIG_VARS)
endforeach (_dep)
if (${module}_CONFIG_VARS)
list (REMOVE_DUPLICATES ${module}_CONFIG_VARS)
endif (${module}_CONFIG_VARS)
# 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_DIR 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})
string (TOUPPER ${module} MODULE)
string (REPLACE "-" "_" MODULE ${MODULE})
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 "")
else ("${lib}" STREQUAL "")
set (_lib_var "${module}_LIBRARY")
endif ("${lib}" STREQUAL "")
find_package_handle_standard_args (
${module}
DEFAULT_MSG
${module}_INCLUDE_DIR ${_lib_var}
)
# 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 (?!)
string (TOUPPER ${module} MODULE_UPPER)
set (${module}_FOUND "${${MODULE_UPPER}_FOUND}" PARENT_SCOPE)
# return these variables to the caller
set (${module}_INCLUDE_DIRS "${${module}_INCLUDE_DIRS}" PARENT_SCOPE)
set (${module}_LIBRARIES "${${module}_LIBRARIES}" PARENT_SCOPE)
set (${module}_DEFINITIONS "${${module}_DEFINITIONS}" PARENT_SCOPE)
set (${module}_CONFIG_VARS "${${module}_CONFIG_VARS}" PARENT_SCOPE)
set (${module}_LINKER_FLAGS "${${module}_LINKER_FLAGS}" PARENT_SCOPE)
set (HAVE_${MODULE} "${HAVE_${MODULE}}" PARENT_SCOPE)
endfunction (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}")
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 ""))
# numbers are not quoted, strings are
if (${_var} MATCHES "[0-9]+")
set (_quoted "${${_var}}")
else (${_var} MATCHES "[0-9]+")
set (_quoted "\"${${_var}}\"")
endif (${_var} MATCHES "[0-9]+")
# add command-line option to define this variable
list (APPEND _cmdline "-D${_var}=${_quoted}")
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,142 @@
# - Helper routines for opm-core like projects
# 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 (libs "-l" "${${name}_LIBRARIES}")
unseparate_args (defs "" "${${name}_DEFINITIONS}")
# necessary to make these variables visible to configure_file
set (name "${${name}_NAME}")
set (description "${${name}_DESCRIPTION}")
set (target "${${name}_LIBRARY}")
set (major "${${name}_VERSION_MAJOR}")
set (minor "${${name}_VERSION_MINOR}")
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 "${PROJECT_SOURCE_DIR}/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}_INCLUDE_DIRS
"${${name}_INCLUDE_DIRS}"
)
string (REPLACE
"${CMAKE_LIBRARY_OUTPUT_DIRECTORY}"
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
${name}_LIBRARY
"${${name}_LIBRARY}"
)
set (CMAKE_LIBRARY_OUTPUT_DIRECTORY
"${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}"
)
# 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}_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}_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}
${CMAKE_INSTALL_PREFIX}/include
)
# put this in the right system location; assume that we have binaries
install (
FILES ${PROJECT_BINARY_DIR}/${${name}_NAME}-install.pc
DESTINATION ${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}/pkgconfig/
RENAME ${${name}_NAME}.pc
)
endfunction (opm_cmake_config name)

View File

@ -0,0 +1,153 @@
# - 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_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_ALL"))
set (_incl_all "ALL")
else (NOT (${excl_all} MATCHES "EXCLUDE_ALL"))
set (_incl_all "")
endif (NOT (${excl_all} MATCHES "EXCLUDE_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})
strip_debug_symbols (${_sat_NAME} _sat_DEBUG)
list (APPEND ${satellite}_DEBUG ${_sat_DEBUG})
# 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 "")
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/" "*.xml")
#
macro (opm_data satellite target dirname files)
# 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)
set (${satellite}_DATA)
foreach (_fileset IN ITEMS ${files})
file (GLOB _fileset_DATA "${dirname}/${_fileset}")
list (APPEND ${satellite}_DATA ${_fileset_DATA})
endforeach (_fileset)
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,15 @@
# - 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)

View File

@ -0,0 +1,97 @@
# - 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)
# only debugging using the GNU toolchain is supported for now
if (CMAKE_COMPILER_IS_GNUCXX)
# add debug symbols to *all* targets, regardless. there WILL come a
# time when you need to find a bug which only manifests itself in a
# release target on a production system!
message (STATUS "Generating debug symbols: -ggdb3")
add_options (ALL_LANGUAGES ALL_BUILDS "-ggdb3")
# 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")
find_program (OBJCOPY
objcopy
${CYGWIN_INSTALL_PATH}/bin /usr/bin /usr/local/bin
)
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 (CMAKE_COMPILER_IS_GNUCXX)
# 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 (CMAKE_COMPILER_IS_GNUCXX 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)
get_filename_component (_name ${_full} NAME)
# only libraries have soversion property attached
get_target_property (_target_soversion ${target} SOVERSION)
get_target_property (_target_version ${target} VERSION)
if (_target_soversion)
set (_target_file "${_full}.${_target_version}")
set (_target_file_name "${_name}.${_target_version}")
else (_target_soversion)
set (_target_file "${_full}")
set (_target_file_name "${_name}")
endif (_target_soversion)
# do without generator expressions (which doesn't work everywhere)
add_custom_command (TARGET ${target}
POST_BUILD
WORKING_DIRECTORY ${_dir}
COMMAND ${OBJCOPY} ARGS --only-keep-debug ${_target_file} ${_target_file}.debug
COMMAND ${OBJCOPY} ARGS ${_strip_args} ${_target_file}
COMMAND ${OBJCOPY} ARGS --add-gnu-debuglink=${_target_file_name}.debug ${_target_file}
VERBATIM
)
# add this .debug file to the list
file (RELATIVE_PATH _this_debug_file "${PROJECT_BINARY_DIR}" "${_target_file}.debug")
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 (CMAKE_COMPILER_IS_GNUCXX AND OBJCOPY)
endfunction (strip_debug_symbols targets)

View File

@ -0,0 +1,33 @@
# be sure that this component is searched for
find_package (Boost COMPONENTS unit_test_framework QUIET)
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"
)

View File

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

View File

@ -0,0 +1,78 @@
# - 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)
# 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})
# 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,42 @@
# - 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.
#
# CMAKE_INSTALL_LIBDIR_NOARCH to lib or lib64 depending on the platform;
# use this path for architecture-independent
# files.
#
# Note that it will override the results of GNUInstallDirs if included after
# that module.
# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu;
# Fedora put module files in lib64/ too, but Debian uses lib/ for that
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
# Debian or Ubuntu?
if (EXISTS "/etc/debian_version")
set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}")
set (_libdir_noarch "lib")
else (EXISTS "/etc/debian_version")
# 64-bit system?
if (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_noarch "lib64")
else (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_noarch "lib")
endif (CMAKE_SIZEOF_VOID_P EQUAL 8)
set (_libdir_def "${_libdir_noarch}")
endif (EXISTS "/etc/debian_version")
else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux")
set (_libdir_def "lib")
set (_libdir_noarch "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")
set (CMAKE_INSTALL_LIBDIR_NOARCH "${_libdir_noarch}" CACHE PATH "Architecture-independent library files")
mark_as_advanced (
CMAKE_INSTALL_LIBDIR
CMAKE_INSTALL_LIBDIR_NOARCH
)

View File

@ -0,0 +1,36 @@
# - 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)
if (${var_name})
set (${var_name} "${value} ${${var_name}}" PARENT_SCOPE)
else (${var_name})
set (${var_name} "${value}")
endif (${var_name})
endfunction (prepend var_name value)
# 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)
# 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)

View File

@ -0,0 +1,41 @@
# - Turn on optimizations based on build type
include(TestCXXAcceptsFlag)
include (AddOptions)
# 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 (CMAKE_COMPILER_IS_GNUCXX)
# use these options for debug builds - no optimizations
add_options (
ALL_LANGUAGES
"Debug"
"-O0" "-DDEBUG"
)
# extra flags passed for optimization
set (_opt_flags "")
# link-time (a.k.a. global) optimizations
check_cxx_accepts_flag ("-flto" HAVE_LINK_OPTS)
if (HAVE_LINK_OPTS)
list (APPEND _opt_flags "-flto")
endif (HAVE_LINK_OPTS)
# 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)
# use these options for release builds - full optimization
add_options (
ALL_LANGUAGES
"Release;RelWithDebInfo;MinSizeRel"
"-O3" "-DNDEBUG" ${_opt_flags}
)
endif (CMAKE_COMPILER_IS_GNUCXX)

View File

@ -0,0 +1,152 @@
# - 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)
# 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")
# only support precompiled headers if the compiler is gcc >= 3.4
get_gcc_version (${language} GCC_VERSION)
if (GCC_VERSION)
if (GCC_VERSION VERSION_EQUAL 3.4 OR GCC_VERSION VERSION_GREATER 3.4)
# 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 (GCC_VERSION VERSION_EQUAL 3.4 OR GCC_VERSION VERSION_GREATER 3.4)
endif (GCC_VERSION)
endfunction (precompile_header
language type header tgt_kw target flgs_kw flags_name)

View File

@ -0,0 +1,50 @@
# - 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}")
else (CMAKE_SYSTEM MATCHES "Linux")
message (STATUS "Operating system: ${CMAKE_SYSTEM}")
endif (CMAKE_SYSTEM MATCHES "Linux")
endfunction (system_info)
# 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)
# 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)
# RHEL/CentOS etc. has just a text-file
elseif (NOT has_sys_release STREQUAL "")
file (READ /etc/system-release _descr)
else (NOT has_lsb_release STREQUAL "")
# no yet known release file found
set (_descr "unknown")
endif (NOT has_os_release STREQUAL "")
# 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)

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,7 @@
# - Turn on warnings when compiling
include (AddOptions)
if (CMAKE_COMPILER_IS_GNUCXX)
message (STATUS "All warnings enabled: -Wall")
add_options (ALL_LANGUAGES ALL_BUILDS "-Wall")
endif (CMAKE_COMPILER_IS_GNUCXX)

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,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)

1663
cmake/Templates/Doxyfile Normal file

File diff suppressed because it is too large Load Diff

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,62 @@
# - @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)
# 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}")
# ensure that we build with support for C++11 to preserve ABI
string (REPLACE "@CXX_STD0X_FLAGS@" "" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
string (STRIP "${CMAKE_CXX_FLAGS}" CMAKE_CXX_FLAGS)
set (CMAKE_CXX_FLAGS "@CXX_STD0X_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@ @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: -l@target@ @libs@
Cflags: @includes@ @defs@

289
configure vendored Executable file
View File

@ -0,0 +1,289 @@
#!/bin/bash
# where is the source tree located
srcdir=$(dirname "$0")
# name of the project
project=$(sed -n "s,^Module:[\ \t]*\([^\ \t]*\),\1,p" "${srcdir}/dune.module")
# 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.
--disable-debug build a release version of the library [default=no]
--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]
--disable-option-checking ignore unrecognized --enable/--with options
Optional Packages:
--with-boost=PATH use Boost library from a specified location
--with-dune-MODULE=PATH use given DUNE module from a specified location
--with-opm-MODULE=PATH use given OPM module from a specified location
--with-superlu=PATH user defined path to SuperLU library
--with-agmg=PATH Include DOUBLE PRECISION version Notay's of AGMG
Algebraic Multigrid solver from specified source
location. Note: this option requires a complete,
working Fortran 90 environment.
--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
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
}
# exit only if option checking is enabled, otherwise ignore
invalid_opt () {
if [ "${option_check}" = "yes" ]; then
invalid_arg $@
exit 1
fi
}
# default values
prefix=/usr/local
buildtype=Debug
#pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
pch_use=
#silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=OFF"
silent_rules=
#debug_loc=" -DSYSTEM_DEBUG=OFF"
debug_loc=
option_check=yes
# this variable will get feature options
FEATURES=
# command that launches cmake; look for 2.8 if available
if [ "${CMAKE_COMMAND}" = "" ]; then
if which cmake28 >/dev/null 2>&1; then
CMAKE_COMMAND=cmake28
else
CMAKE_COMMAND=cmake
fi
fi
# long arguments are implemented by putting a dash character followed by
# a colon in the optspec, see trick by Arvid Requate at
# <http://stackoverflow.com/questions/402377/#7680682>
while getopts -- ":-:" optchar; do
case "${optchar}" in
-)
# OPTARG now contains everything after double dashes
case "${OPTARG}" in
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
pkgloc=${OPTARG#*=}
# the parameter to this option is an executable program, so
# skip the directory test in that case
if [ "${pkgname}" = "cmake" ]; then
CMAKE_COMMAND="${pkgloc}"
break
fi
# expand to full path since CMake changes to source directory (!)
# this also normalize the path name wrt. not having a trailing slash
pkgloc=$(test -d "${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=""
;;
agmg |\
ert |\
boost |\
zlib)
rootvar="${pkgname^^}_ROOT"
;;
superlu)
rootvar="${pkgname^^}_PREFIX"
;;
SuiteSparse |\
TinyXML |\
opm-* |\
dune-*)
rootvar="${pkgname}_ROOT"
;;
*)
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-}
# special aliases
case "${pkgname}" in
umfpack)
pkgname="SuiteSparse"
;;
tinyxml)
pkgname="TinyXML"
;;
esac
# casing is of course different
case "${pkgname}" in
option-checking)
option_check=no
# special flag: don't disable any particular package
pkgname=""
;;
debug)
buildtype=Release
# special flag: don't disable any particular package
pkgname=""
;;
pch)
pch_use=" -DPRECOMPILE_HEADERS:BOOL=OFF"
pkgname=""
;;
silent-rules)
silent_rules=" -DCMAKE_VERBOSE_MAKEFILE=ON"
pkgname=""
;;
system-debug)
silent_rules=" -DSYSTEM_DEBUG=OFF"
pkgname=""
;;
agmg |\
ert |\
superlu)
pkgname="${pkgname^^}"
;;
openmp)
pkgname="OpenMP"
;;
gxx11check)
pkgname="CXX11Features"
;;
*)
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=""
;;
# 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_${project}_SHARED:BOOL=${shared}"
;;
*)
# remove everything *after* the equal sign
arg=${OPTARG%=*}
invalid_arg --$arg
exit 1
;;
esac
;;
*)
invalid_arg -$OPTARG
exit 1
;;
esac
done
# remove all arguments processed by getopts
shift $((OPTIND-1))
# remove Autotools-specific variables
ENVVARS=${@/ACLOCAL_*=*/}
# pass everything on to CMake
CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"${srcdir}\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}"
echo --- calling CMake for ${project} ---
echo ${CMDLINE}
eval exec ${CMDLINE}