Merge pull request #254 from bska/cmake_254

Synchronise build system with OPM core
This commit is contained in:
Atgeirr Flø Rasmussen 2014-12-08 15:31:31 +01:00
commit c051c7bd85
9 changed files with 193 additions and 7 deletions

View File

@ -73,6 +73,12 @@ endmacro (tests_hook)
# all setup common to the OPM library modules is done here
include (OpmLibMain)
add_custom_target(check-commits
COMMAND ${CMAKE_COMMAND}
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
-DCMAKE_BINARY_DIR=${CMAKE_BINARY_DIR}
-P ${PROJECT_SOURCE_DIR}/cmake/Scripts/CheckCommits.cmake)
# download Eigen if user doesn't have the correct version
if (NOT EIGEN3_FOUND)
message (STATUS "Downloading Eigen3")

View File

@ -133,19 +133,23 @@ CHECK_CXX_SOURCE_RUNS("
#include <regex>
int main(void)
{
std::regex r(\"AB.*|BC+\", std::regex::extended);
std::regex r(\"AB.*|BC+|DE.+\", std::regex::extended);
if (!std::regex_match(\"AB\", r))
return 1;
if (!std::regex_match(\"ABC\", r))
return 1;
return 2;
if (!std::regex_match(\"ABC!#\", r))
return 1;
return 3;
if (std::regex_match(\"B\", r))
return 1;
return 4;
if (!std::regex_match(\"BC\", r))
return 1;
return 5;
if (std::regex_match(\"BCE\", r))
return 1;
return 6;
if (std::regex_match(\"DE\", r))
return 7;
if (!std::regex_match(\"DEF\", r))
return 8;
return 0;
}
" HAVE_REGEX

View File

@ -9,6 +9,12 @@
include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-Werror -fext-numeric-literals" HAVE_EXTENDED_NUMERIC_LITERALS)
if (HAVE_EXTENDED_NUMERIC_LITERALS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fext-numeric-literals")
endif()
cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")

View File

@ -0,0 +1,52 @@
# - Find DUNE ALUgrid library
#
# Defines the following variables:
# dune-alugrid_INCLUDE_DIRS Directory of header files
# dune-alugrid_LIBRARIES Directory of shared object files
# dune-alugrid_DEFINITIONS Defines that must be set to compile
# dune-alugrid_CONFIG_VARS List of defines that should be in config.h
# HAVE_DUNE_ALUGRID Binary value to use in config.h
# Copyright (C) 2013 Uni Research AS
# This code is licensed under The GNU General Public License v3.0
include (OpmPackage)
find_opm_package (
# module name
"dune-alugrid"
# dependencies
# TODO: we should probe for all the HAVE_* values listed below;
# however, we don't actually use them in our implementation, so
# we just include them to forward here in case anyone else does
"CXX11Features REQUIRED;
dune-grid REQUIRED;
ZLIB REQUIRED;
METIS
"
# header to search for
"dune/alugrid/grid.hh"
# library to search for
"dunealugrid;alugrid_2d;alugrid_parallel;alugrid_serial"
# defines to be added to compilations
""
# test program
"#include <dune/alugrid/grid.hh>
int main (void) {
Dune::ALUGrid</*dim=*/2, /*dimWorld=*/2, Dune::simplex, Dune::nonconforming> grid;
grid.leafGridView().size(/*codim=*/0);
return 0;
}
"
# config variables
"HAVE_DUNE_ALUGRID
")
#debug_find_vars ("dune-grid")
# make version number available in config.h
include (UseDuneVer)
find_dune_version ("dune" "alugrid")

View File

@ -15,6 +15,19 @@
# tests_hook Do special processing before tests are compiled
# files_hook Do special processing before final targets are added
# for CMake >= 3.0, we need to change a few policies:
#
# - CMP0026 to allow access to the LOCATION target property
# - CMP0048 to indicate that we want to deal with the *VERSION*
# variables ourselves
if (POLICY CMP0026)
cmake_policy(SET CMP0026 OLD)
endif()
if (POLICY CMP0048)
cmake_policy(SET CMP0048 OLD)
endif()
# include special
if (CMAKE_VERSION VERSION_LESS "2.8.3")
message (STATUS "Enabling compatibility modules for CMake 2.8.3")

View File

@ -6,6 +6,9 @@ set (dune-cornerpoint_CONFIG_VAR
DUNE_GRID_VERSION_MAJOR
DUNE_GRID_VERSION_MINOR
DUNE_GRID_VERSION_REVISION
DUNE_COMMON_VERSION_MAJOR
DUNE_COMMON_VERSION_MINOR
DUNE_COMMON_VERSION_REVISION
)
# dependencies

View File

@ -19,6 +19,9 @@ set (ewoms_DEPS
"dune-istl REQUIRED"
"opm-core REQUIRED"
"opm-material REQUIRED"
"opm-parser"
"dune-alugrid"
"dune-cornerpoint"
# valgrind client requests
"Valgrind"
# quadruple precision floating point calculations

View File

@ -28,7 +28,7 @@ set (opm-core_DEPS
# xml processing (for config parsing)
"TinyXML"
# Ensembles-based Reservoir Tools (ERT)
"ERT"
"ERT REQUIRED"
# Look for MPI support
"MPI"
# DUNE dependency

View File

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