Merge pull request #351 from atgeirr/cmake_01

Sync build system
This commit is contained in:
Bård Skaflestad 2015-04-10 17:35:34 +02:00
commit 69ac687eb2
17 changed files with 261 additions and 83 deletions

View File

@ -3,6 +3,7 @@
#
# Sets the follwing variable:
#
# HAVE_FINAL True if the compiler supports the "final" quantifier
# HAVE_TYPE_TRAITS True if the <type_traits> header is available and implements sufficient functionality
# HAVE_SHARED_PTR True if std::shared_ptr is available
# HAVE_UNIQUE_PTR True if std::unique_ptr is available
@ -70,6 +71,22 @@ endif (CXX_STD0X_FLAGS AND CXX_STDLIB_FLAGS)
# perform tests
include(CheckCXXSourceCompiles)
# the "final" method specifier
CHECK_CXX_SOURCE_COMPILES("
struct Base {
virtual void foo() = 0;
};
struct Derived : public Base {
virtual void foo() final {};
};
int main()
{
return 0;
}
" HAVE_FINAL
)
# std::is_convertible, std::is_base_of
CHECK_CXX_SOURCE_COMPILES("
#include <type_traits>

View File

@ -20,7 +20,7 @@ endif()
find_path (METIS_INCLUDE_DIRS
NAMES "metis.h"
PATHS ${METIS_SEARCH_PATH}
PATH_SUFFIXES "include" "METISLib"
PATH_SUFFIXES "include" "METISLib" "include/metis"
${METIS_NO_DEFAULT_PATH})
# only search in architecture-relevant directory
@ -39,7 +39,7 @@ if (METIS_INCLUDE_DIRS OR METIS_LIBRARIES)
set(METIS_FOUND TRUE)
set(HAVE_METIS TRUE)
endif()
# print a message to indicate status of this package
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args(METIS

View File

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

View File

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

View File

@ -22,6 +22,7 @@ find_opm_package (
"CXX11Features REQUIRED;
dune-grid REQUIRED;
ZLIB REQUIRED;
ZOLTAN;
METIS
"
# header to search for
@ -34,10 +35,8 @@ find_opm_package (
""
# test program
"#include <dune/alugrid/grid.hh>
"#include <dune/alugrid/2d/indexsets.hh>
int main (void) {
Dune::ALUGrid</*dim=*/2, /*dimWorld=*/2, Dune::simplex, Dune::nonconforming> grid;
grid.leafGridView().size(/*codim=*/0);
return 0;
}
"

View File

@ -11,6 +11,9 @@
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
set(DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS 1)
find_opm_package (
# module name
"dune-grid"
@ -52,7 +55,8 @@ int main (void) {
HAVE_PSURFACE;
HAVE_AMIRAMESH;
HAVE_ALBERTA;
HAVE_STDINT_H
HAVE_STDINT_H;
DUNE_GRID_EXPERIMENTAL_GRID_EXTENSIONS
")
#debug_find_vars ("dune-grid")

View File

@ -1,5 +1,7 @@
# - Compile main library target
option (STRIP_DEBUGGING_SYMBOLS "use separate files for the executable code and the debugging symbols" OFF)
macro (opm_compile opm)
# some CMake properties do not do list expansion
string (REPLACE ";" " " ${opm}_LINKER_FLAGS_STR "${${opm}_LINKER_FLAGS}")
@ -28,8 +30,10 @@ macro (opm_compile opm)
)
target_link_libraries (${${opm}_TARGET} ${${opm}_LIBRARIES})
# queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
if (STRIP_DEBUGGING_SYMBOLS)
# queue this executable to be stripped
strip_debug_symbols (${${opm}_TARGET} ${opm}_DEBUG)
endif()
else (${opm}_SOURCES)
# unset this variable to signal that no library is generated
set (${opm}_TARGET)

View File

@ -70,8 +70,10 @@ macro (opm_compile_satellites opm satellite excl_all test_regexp)
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})
if (STRIP_DEBUGGING_SYMBOLS)
strip_debug_symbols (${_sat_NAME} _sat_DEBUG)
list (APPEND ${satellite}_DEBUG ${_sat_DEBUG})
endif()
# variable with regular expression doubles as a flag for
# whether tests should be setup or not

View File

@ -18,12 +18,10 @@ if (CXX_COMPAT_GCC)
# default debug level, if not specified by the user
set_default_option (CXX _dbg_flag "-ggdb3" "(^|\ )-g")
# add debug symbols to *all* targets, 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!
# add debug symbols to *all* targets if the build mode is either "Debug" or "RelWithDebInfo"
if (_dbg_flag)
message (STATUS "Generating debug symbols: ${_dbg_flag}")
add_options (ALL_LANGUAGES ALL_BUILDS "${_dbg_flag}")
add_options (ALL_LANGUAGES "Debug;RelWithDebInfo" "${_dbg_flag}")
endif (_dbg_flag)
# extracting the debug info is done by a separate utility in the GNU

View File

@ -38,7 +38,7 @@ if (CXX_COMPAT_GCC)
# default optimization flags, if not set by user
set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O")
set_default_option (CXX _opt_rel "-O3" "(^|\ )-O")
set_default_option (CXX _opt_rel "-O2" "(^|\ )-O")
# use these options for debug builds - no optimizations
add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG")

View File

@ -1,10 +1,15 @@
# -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
# vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
# this avoids an annoying deprecation warning on DUNE 2.4 (which we
# are not interested in anyway)
set(DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING 1)
# defines that must be present in config.h for our headers
set (ewoms_CONFIG_VAR
HAVE_QUAD
HAVE_VALGRIND
DUNE_AVOID_CAPABILITIES_IS_PARALLEL_DEPRECATION_WARNING
)
# dependencies

View File

@ -21,5 +21,5 @@ set (opm-autodiff_DEPS
dune-cornerpoint;
opm-core REQUIRED"
# Eigen
"Eigen3 3.2.0 "
"Eigen3 3.2.0"
)

View File

@ -7,6 +7,7 @@ set (opm-core_CONFIG_VAR
HAVE_SUITESPARSE_UMFPACK_H
HAVE_DUNE_ISTL
HAVE_MPI
HAVE_PETSC
)
# dependencies
@ -31,6 +32,8 @@ set (opm-core_DEPS
"ERT REQUIRED"
# Look for MPI support
"MPI"
# PETSc numerical backend
"PETSc"
# DUNE dependency
"dune-common"
"dune-istl"

View File

@ -5,6 +5,7 @@
set (opm-material_CONFIG_VAR
HAVE_MPI
HAVE_VALGRIND
HAVE_FINAL
)
# dependencies

View File

@ -226,10 +226,7 @@ Default is OFF.
### Project-specific Files
All of these files are in the project root, except for `opm-xxx.m4`
which is in the `m4` directory. (`dunecontrol` always adds this
subdirectory for all the prerequisites listed in `dune.module`, to the
search path).
All of these files are in the project root.
<table><thead><tr><th>File<th>Description<tbody>
<tr>
@ -267,18 +264,6 @@ dependencies is taken from opm-xxx-prereqs.cmake and not from here).
Since this file must be present before the build starts (for dunecontrol),
the version information is kept here.
<tr>
<td> opm_xxx.m4
<td>
Tell the generic opm.m4 module which name it should request pkg-config
for. This module is used by autotools-projects which link to OPM.
Notice that dashes is replaced by underscore in the filename to be
compatible with M4. (The actual name of the file doesn't matter to the
autotools build system). The contents of this file is mostly boiler-plate
where the names need to be changed to the project in question. (The
DUNE build system assumes the presence of macros based on the project
name).
</table>
### Project Modules

View File

@ -21,6 +21,7 @@ Optional Features:
[default=no]
--disable-runpath do not use RUNPATH in installed library [default=yes]
--enable-lto use whole program optimization [default=no]
--enable-strip-debug separate the executable code and the debugging symbols [default=no]
--disable-tests do not compile and enable unit tests [default=yes]
--disable-examples do not compile example programs [default=yes]
--disable-pch do not use precompiled headers (if buggy compiler)
@ -123,6 +124,8 @@ silent_rules=
debug_loc=
#use_lto=" -DWHOLE_PROG_OPTIM=OFF"
use_lto=
#strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=OFF"
strip_debug=
#use_runpath=" -DUSE_RUNPATH=OFF"
use_runpath=
#use_tests=" -DBUILD_TESTING=ON"
@ -314,6 +317,10 @@ for OPT in "$@"; do
use_lto=" -DWHOLE_PROG_OPTIM=OFF"
pkgname=""
;;
strip-debug )
strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=OFF"
pkgname=""
;;
openmp)
use_openmp=" -DUSE_OPENMP=OFF"
pkgname=""
@ -397,6 +404,10 @@ for OPT in "$@"; do
use_lto=" -DWHOLE_PROG_OPTIM=ON"
shared=""
;;
strip-debug )
strip_debug=" -DSTRIP_DEBUGGING_SYMBOLS=ON"
pkgname=""
;;
tests)
use_tests=" -DBUILD_TESTING=ON"
pkgname=""
@ -534,7 +545,7 @@ elif test "$c_compiler$c_opts$cxx_compiler$cxx_opts$fort_compiler$fort_opts" !=
fi
# pass everything on to CMake
CMDLINE="${ENVVARS}${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${use_runpath}${use_tests}${use_samples}${use_underscoring}${c_compiler}${c_opts}${cxx_compiler}${cxx_opts}${fort_compiler}${fort_opts}${boost_opts}${buildname}${site} ${FEATURES}"
CMDLINE="${ENVVARS}${CMAKE_COMMAND} \"${srcdir}\" ${use_ninja}\"-DCMAKE_INSTALL_PREFIX=$prefix\"${buildtype}${pch_use}${silent_rules}${debug_loc}${use_openmp}${use_mpi}${use_lto}${strip_debug}${use_runpath}${use_tests}${use_samples}${use_underscoring}${c_compiler}${c_opts}${cxx_compiler}${cxx_opts}${fort_compiler}${fort_opts}${boost_opts}${buildname}${site} ${FEATURES}"
echo --- calling CMake ---
echo "${CMDLINE}"
eval exec "${CMDLINE}"

View File

@ -1,50 +0,0 @@
dnl -*- autoconf -*-
dnl OPM_PKG_CONFIG_MODULE (name, version, description)
dnl
dnl Common routine to include configuration module for an OPM project
AC_DEFUN([OPM_CHECK_PKG_MODULE],[
dnl local variables representing parameters
m4_pushdef([_opm_name], [$1])
m4_pushdef([_opm_version], [$2])
m4_pushdef([_opm_description], [$3])
dnl macro-friendly version of the name; uppercase and with dashes
dnl replaced with underscores
m4_pushdef([_opm_module], [m4_translit(_opm_name,[-],[_])])
m4_pushdef([_OPM_MODULE], [m4_toupper(_opm_module)])
dnl if we are given the location as a parameter, look there first
AC_ARG_WITH(_opm_name,
AS_HELP_STRING([--with-_opm_name=PATH],[_opm_description directory]))
AS_IF([test -n "$with_[]_opm_module"],[
export PKG_CONFIG_PATH=$with_[]_opm_module:$PKG_CONFIG_PATH
])
dnl let pkg-config do the heavy lifting of finding the .pc file
PKG_CHECK_MODULES(_OPM_MODULE,[_opm_name = _opm_version],[
AC_DEFINE(HAVE_[]_OPM_MODULE,[1],[_opm_description available])
])
dnl TODO: here we could call PKG_CONFIG --variable if we need more
dnl make flag available for Makefiles too
AM_CONDITIONAL(HAVE_[]_OPM_MODULE, test x$HAVE_[]_OPM_MODULE = x1)
dnl add our libraries to the global list of compiler and linker options
DUNE_CPPFLAGS="$DUNE_CPPFLAGS $_OPM_MODULE[]_CFLAGS"
DUNE_LIBS="$DUNE_LIBS $_OPM_MODULE[]_LIBS"
# add this module to summary (if we are used with dunecontrol)
ifdef([DUNE_MODULE_ADD_SUMMARY_ENTRY],[
DUNE_MODULE_ADD_SUMMARY_ENTRY(_opm_name)
])
dnl cleanup
m4_popdef([_OPM_MODULE])
m4_popdef([_opm_module])
m4_popdef([_opm_description])
m4_popdef([_opm_version])
m4_popdef([_opm_name])
])