mirror of
https://github.com/OPM/opm-upscaling.git
synced 2025-02-25 18:45:23 -06:00
Merge pull request #28 from rolk/028_cmakeupd
Update CMake scripts to commit 11bf7bf3 from opm-core
This commit is contained in:
commit
46a78df3cd
@ -108,25 +108,20 @@ opm_auto_dirs ()
|
||||
# put libraries in lib/
|
||||
opm_out_dirs ()
|
||||
|
||||
# identify the compilation units in the library
|
||||
# identify the compilation units in the library; sources in opm/,
|
||||
# examples in examples/
|
||||
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 ()
|
||||
|
||||
# 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")
|
||||
|
||||
# write configuration variables to this file. note that it is a temporary.
|
||||
message (STATUS "Writing config file \"${PROJECT_BINARY_DIR}/config.h\"...")
|
||||
set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h.tmp")
|
||||
configure_vars (
|
||||
FILE CXX ${CONFIG_H}
|
||||
WRITE ${${project}_CONFIG_VARS}
|
||||
@ -138,6 +133,13 @@ define_fc_func (
|
||||
IF HAVE_LAPACK
|
||||
)
|
||||
|
||||
# overwrite the config.h that is used by the code only if we have some
|
||||
# real changes. thus, we don't have to recompile if a reconfigure is run
|
||||
# due to some files being added, for instance
|
||||
execute_process (COMMAND
|
||||
${CMAKE_COMMAND} -E copy_if_different ${CONFIG_H} ${PROJECT_BINARY_DIR}/config.h
|
||||
)
|
||||
|
||||
# compile main library; pull in all required includes and libraries
|
||||
include (OpmCompile)
|
||||
opm_compile (${project})
|
||||
@ -155,8 +157,7 @@ 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 "" "")
|
||||
# example programs are found in the examples/ directory
|
||||
opm_compile_satellites (${project} examples "" "")
|
||||
|
||||
# infrastructure for testing
|
||||
@ -164,7 +165,7 @@ enable_testing ()
|
||||
include (CTest)
|
||||
|
||||
# make datafiles necessary for tests available in output directory
|
||||
opm_data (tests datafiles "${tests_DIR}" "*.xml")
|
||||
opm_data (tests datafiles "${tests_DIR}")
|
||||
opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
|
||||
|
||||
# use this target to run all tests
|
||||
@ -188,9 +189,3 @@ 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}
|
||||
)
|
||||
|
102
CMakeLists_files.cmake
Normal file
102
CMakeLists_files.cmake
Normal file
@ -0,0 +1,102 @@
|
||||
# -*- 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 file sets up five lists:
|
||||
# MAIN_SOURCE_FILES List of compilation units which will be included in
|
||||
# the library. If it isn't on this list, it won't be
|
||||
# part of the library. Please try to keep it sorted to
|
||||
# maintain sanity.
|
||||
#
|
||||
# TEST_SOURCE_FILES List of programs that will be run as unit tests.
|
||||
#
|
||||
# TEST_DATA_FILES Files from the source three that should be made
|
||||
# available in the corresponding location in the build
|
||||
# tree in order to run tests there.
|
||||
#
|
||||
# EXAMPLE_SOURCE_FILES Other programs that will be compiled as part of the
|
||||
# build, but which is not part of the library nor is
|
||||
# run as tests.
|
||||
#
|
||||
# PUBLIC_HEADER_FILES List of public header files that should be
|
||||
# distributed together with the library. The source
|
||||
# files can of course include other files than these;
|
||||
# you should only add to this list if the *user* of
|
||||
# the library needs it.
|
||||
|
||||
# originally generated with the command:
|
||||
# find opm -name '*.c*' -printf '\t%p\n' | sort
|
||||
list (APPEND MAIN_SOURCE_FILES
|
||||
opm/elasticity/boundarygrid.cpp
|
||||
opm/elasticity/dynmatrixev.cpp
|
||||
opm/elasticity/fmatrixev_ext.cc
|
||||
opm/elasticity/material.cpp
|
||||
opm/elasticity/materials.cpp
|
||||
opm/elasticity/mpc.cpp
|
||||
)
|
||||
|
||||
# originally generated with the command:
|
||||
# find tests -name '*.cpp' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
|
||||
list (APPEND TEST_SOURCE_FILES
|
||||
)
|
||||
|
||||
# originally generated with the command:
|
||||
# find tests -name '*.xml' -a ! -wholename '*/not-unit/*' -printf '\t%p\n' | sort
|
||||
list (APPEND TEST_DATA_FILES
|
||||
)
|
||||
|
||||
# originally generated with the command:
|
||||
# find examples -name '*.c*' -a ! -name 'twophase2_test.cpp' -printf '\t%p\n' | sort
|
||||
list (APPEND EXAMPLE_SOURCE_FILES
|
||||
examples/cpchop.cpp
|
||||
examples/cpchop_depthtrend.cpp
|
||||
examples/cpregularize.cpp
|
||||
examples/exp_variogram.cpp
|
||||
examples/grdecldips.cpp
|
||||
examples/upscale_avg.cpp
|
||||
examples/upscale_cap.cpp
|
||||
examples/upscale_cond.cpp
|
||||
examples/upscale_elasticity.cpp
|
||||
examples/upscale_perm.cpp
|
||||
examples/upscale_relperm.cpp
|
||||
examples/upscale_relpermvisc.cpp
|
||||
examples/upscale_steadystate_implicit.cpp
|
||||
)
|
||||
|
||||
# originally generated with the command:
|
||||
# find opm -name '*.h*' -a ! -name '*-pch.hpp' -printf '\t%p\n' | sort
|
||||
list (APPEND PUBLIC_HEADER_FILES
|
||||
opm/elasticity/applier.hpp
|
||||
opm/elasticity/asmhandler.hpp
|
||||
opm/elasticity/asmhandler_impl.hpp
|
||||
opm/elasticity/boundarygrid.hh
|
||||
opm/elasticity/dynmatrixev.hh
|
||||
opm/elasticity/elasticity.hpp
|
||||
opm/elasticity/elasticity_impl.hpp
|
||||
opm/elasticity/elasticity_upscale.hpp
|
||||
opm/elasticity/elasticity_upscale_impl.hpp
|
||||
opm/elasticity/fmatrixev_ext.hh
|
||||
opm/elasticity/logutils.hpp
|
||||
opm/elasticity/material.hh
|
||||
opm/elasticity/materials.hh
|
||||
opm/elasticity/matrixops.hpp
|
||||
opm/elasticity/matrixops_impl.hpp
|
||||
opm/elasticity/mortar_evaluator.hpp
|
||||
opm/elasticity/mortar_schur.hpp
|
||||
opm/elasticity/mortar_schur_precond.hpp
|
||||
opm/elasticity/mortar_utils.hpp
|
||||
opm/elasticity/mpc.hh
|
||||
opm/elasticity/seqlu.hpp
|
||||
opm/elasticity/shapefunctions.hpp
|
||||
opm/elasticity/uzawa_solver.hpp
|
||||
opm/upscaling/SinglePhaseUpscaler.hpp
|
||||
opm/upscaling/SteadyStateUpscaler.hpp
|
||||
opm/upscaling/SteadyStateUpscaler_impl.hpp
|
||||
opm/upscaling/SteadyStateUpscalerImplicit.hpp
|
||||
opm/upscaling/SteadyStateUpscalerImplicit_impl.hpp
|
||||
opm/upscaling/SteadyStateUpscalerManager.hpp
|
||||
opm/upscaling/SteadyStateUpscalerManagerImplicit.hpp
|
||||
opm/upscaling/UpscalerBase.hpp
|
||||
opm/upscaling/UpscalerBase_impl.hpp
|
||||
opm/upscaling/upscaling.hh
|
||||
opm/upscaling/UpscalingTraits.hpp
|
||||
)
|
43
GNUmakefile
43
GNUmakefile
@ -1,43 +0,0 @@
|
||||
# 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
|
@ -43,16 +43,18 @@ function (add_options langs builds)
|
||||
# remove it first
|
||||
string (REPLACE "${_opt}" "" _without "${${_var}}")
|
||||
string (STRIP "${_without}" _without)
|
||||
# we need to strip this one as well, so they are comparable
|
||||
string (STRIP "${${_var}}" _stripped)
|
||||
# if it wasn't there, then add it at the end
|
||||
if ("${_without}" STREQUAL "${${_var}}")
|
||||
if ("${_without}" STREQUAL "${_stripped}")
|
||||
# don't add any extra spaces if no options yet are set
|
||||
if (NOT ${${_var}} STREQUAL "")
|
||||
set (${_var} "${${_var}} ${_opt}")
|
||||
else (NOT ${${_var}} STREQUAL "")
|
||||
if (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${_stripped} ${_opt}")
|
||||
else (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${_opt}")
|
||||
endif (NOT ${${_var}} STREQUAL "")
|
||||
endif (NOT ${_stripped} STREQUAL "")
|
||||
set (${_var} "${${_var}}" PARENT_SCOPE)
|
||||
endif ("${_without}" STREQUAL "${${_var}}")
|
||||
endif ("${_without}" STREQUAL "${_stripped}")
|
||||
endforeach (_opt)
|
||||
endforeach (build)
|
||||
endforeach (lang)
|
||||
|
@ -27,7 +27,6 @@
|
||||
|
||||
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")
|
||||
@ -47,10 +46,10 @@ function (configure_vars obj syntax filename verb)
|
||||
# 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")
|
||||
if ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
add_definitions (-DHAVE_CONFIG_H=1)
|
||||
include_directories (BEFORE "${_config_path}")
|
||||
endif ("${_config_file}" STREQUAL "config.h")
|
||||
endif ("${_config_file}" MATCHES "config\\.h(\\..+)?")
|
||||
|
||||
# only write the current value of each variable once
|
||||
set (_args ${ARGN})
|
||||
|
44
cmake/Modules/Duplicates.cmake
Normal file
44
cmake/Modules/Duplicates.cmake
Normal file
@ -0,0 +1,44 @@
|
||||
# - Remove duplicate library declarations
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# remove_duplicate_libraries (module)
|
||||
#
|
||||
# where
|
||||
# module Name of the module whose libraries should be pruned
|
||||
|
||||
# Copyright (C) 2013 Uni Research AS
|
||||
# This file is licensed under the GNU General Public License v3.0
|
||||
|
||||
# libraries should always be trimmed from the beginning, so that also
|
||||
# missing functions in those later in the list will be resolved
|
||||
macro (remove_duplicate_libraries module)
|
||||
if (DEFINED ${module}_LIBRARIES)
|
||||
list (REVERSE ${module}_LIBRARIES)
|
||||
list (REMOVE_DUPLICATES ${module}_LIBRARIES)
|
||||
list (REVERSE ${module}_LIBRARIES)
|
||||
endif (DEFINED ${module}_LIBRARIES)
|
||||
endmacro (remove_duplicate_libraries module)
|
||||
|
||||
# headers can be trimmed from the end, since adding a directory to
|
||||
# the list is an idempotent action
|
||||
macro (remove_duplicate_headers module)
|
||||
if (DEFINED ${module}_INCLUDE_DIRS)
|
||||
list (REMOVE_DUPLICATES ${module}_INCLUDE_DIRS)
|
||||
endif (DEFINED ${module}_INCLUDE_DIRS)
|
||||
endmacro (remove_duplicate_headers module)
|
||||
|
||||
# linker flags may not be specified at all
|
||||
macro (remove_duplicate_flags module)
|
||||
if (DEFINED ${module}_LINKER_FLAGS)
|
||||
list (REMOVE_DUPLICATES ${module}_LINKER_FLAGS)
|
||||
endif (DEFINED ${module}_LINKER_FLAGS)
|
||||
endmacro (remove_duplicate_flags module)
|
||||
|
||||
# fix up both headers and libraries, in case two dependencies have
|
||||
# included the same second-level library independently
|
||||
macro (remove_dup_deps module)
|
||||
remove_duplicate_headers (${module})
|
||||
remove_duplicate_libraries (${module})
|
||||
remove_duplicate_flags (${module})
|
||||
endmacro (remove_dup_deps module)
|
@ -118,21 +118,8 @@ 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)
|
||||
include (UseOpenMP)
|
||||
find_openmp (ERT)
|
||||
|
||||
# compression library
|
||||
find_package (ZLIB ${ERT_QUIET})
|
||||
@ -166,19 +153,8 @@ 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)
|
||||
include (Duplicates)
|
||||
remove_dup_deps (ERT)
|
||||
|
||||
# see if we can compile a minimum example
|
||||
# CMake logical test doesn't handle lists (sic)
|
||||
|
@ -3,7 +3,7 @@
|
||||
# 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
|
||||
# SUPERLU_ROOT Path list to search for SuperLU
|
||||
#
|
||||
# Sets the follwing variable:
|
||||
#
|
||||
@ -38,7 +38,7 @@ 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}
|
||||
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
|
||||
PATH_SUFFIXES "superlu" "include/superlu" "include" "SRC"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
@ -52,7 +52,7 @@ find_path(SUPERLU_INCLUDE_DIR
|
||||
# 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}
|
||||
PATHS ${SUPERLU_PREFIX} ${SUPERLU_ROOT}
|
||||
PATH_SUFFIXES "lib" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
|
@ -14,12 +14,14 @@ macro (opm_defaults opm)
|
||||
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)
|
||||
string (TOUPPER "${${opm}_NAME}" opm_UPPER)
|
||||
string (REPLACE "-" "_" opm_UPPER "${opm_UPPER}")
|
||||
option (BUILD_${opm_UPPER}_SHARED "Build ${${opm}_NAME} as a shared library" ${_shared_def})
|
||||
if (BUILD_${opm_UPPER}_SHARED)
|
||||
set (${opm}_LIBRARY_TYPE SHARED)
|
||||
else (BUILD_${${opm}_NAME}_SHARED)
|
||||
else (BUILD_${opm_UPPER}_SHARED)
|
||||
set (${opm}_LIBRARY_TYPE STATIC)
|
||||
endif (BUILD_${${opm}_NAME}_SHARED)
|
||||
endif (BUILD_${opm_UPPER}_SHARED)
|
||||
|
||||
# precompile standard headers to speed up compilation
|
||||
# unfortunately, this functionality is buggy and tends to segfault at
|
||||
|
@ -17,6 +17,7 @@ macro (opm_dist_clean opm)
|
||||
cmake_install.cmake
|
||||
Makefile
|
||||
config.h
|
||||
config.h.tmp
|
||||
${${opm}_NAME}-config.cmake
|
||||
${${opm}_NAME}-config-version.cmake
|
||||
${${opm}_NAME}-install.cmake
|
||||
|
@ -16,59 +16,72 @@ macro (opm_auto_dirs)
|
||||
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
|
||||
# this is necessary to set so that we know where we are going to
|
||||
# execute the test programs (and make datafiles available)
|
||||
set (tests_DIR "tests")
|
||||
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)
|
||||
# start out with defined, empty lists which will be specified externally
|
||||
set (MAIN_SOURCE_FILES)
|
||||
set (EXAMPLE_SOURCE_FILES)
|
||||
set (TEST_SOURCE_FILES)
|
||||
set (TEST_DATA_FILES)
|
||||
set (PUBLIC_HEADER_FILES)
|
||||
|
||||
macro (opm_find_examples)
|
||||
set (examples_DIR "examples")
|
||||
file (GLOB examples_SOURCES "${examples_DIR}/*.cpp")
|
||||
endmacro (opm_find_examples)
|
||||
# read the list of components from this file; it should set the above
|
||||
# lists (which are generic names)
|
||||
include (${PROJECT_SOURCE_DIR}/CMakeLists_files.cmake)
|
||||
|
||||
# rename from "friendly" names to ones that fit the "almost-structural"
|
||||
# scheme used in the .cmake modules, converting them to absolute file
|
||||
# names in the process
|
||||
foreach (_file IN LISTS MAIN_SOURCE_FILES)
|
||||
list (APPEND ${opm}_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
|
||||
endforeach (_file)
|
||||
foreach (_file IN LISTS PUBLIC_HEADER_FILES)
|
||||
list (APPEND ${opm}_HEADERS ${PROJECT_SOURCE_DIR}/${_file})
|
||||
endforeach (_file)
|
||||
foreach (_file IN LISTS TEST_SOURCE_FILES)
|
||||
list (APPEND tests_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
|
||||
endforeach (_file)
|
||||
foreach (_file IN LISTS TEST_DATA_FILES)
|
||||
list (APPEND tests_DATA ${PROJECT_SOURCE_DIR}/${_file})
|
||||
endforeach (_file)
|
||||
foreach (_file IN LISTS EXAMPLE_SOURCE_FILES)
|
||||
list (APPEND examples_SOURCES ${PROJECT_SOURCE_DIR}/${_file})
|
||||
endforeach (_file)
|
||||
|
||||
# identify pre-compile header; if the project is called opm-foobar,
|
||||
# then it should be in opm/foobar/opm-foobar-pch.hpp
|
||||
string (REPLACE "-" "/" opm_NAME_AS_DIR ${${opm}_NAME})
|
||||
set (${opm}_PRECOMP_CXX_HEADER "${opm_NAME_AS_DIR}/${${opm}_NAME}-pch.hpp")
|
||||
if (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
|
||||
set (${opm}_PRECOMP_CXX_HEADER "")
|
||||
endif (NOT EXISTS ${PROJECT_SOURCE_DIR}/${${opm}_PRECOMP_CXX_HEADER})
|
||||
endmacro (opm_sources opm)
|
||||
|
||||
# disable an entire directory from sources
|
||||
macro (opm_disable_source opm)
|
||||
foreach (_exp IN ITEMS ${ARGN})
|
||||
# regexp or directory?
|
||||
if (IS_ABSOLUTE "${_exp}")
|
||||
set (_prefix "")
|
||||
else (IS_ABSOLUTE "${_exp}")
|
||||
set (_prefix "${PROJECT_SOURCE_DIR}/")
|
||||
endif (IS_ABSOLUTE "${_exp}")
|
||||
if (IS_DIRECTORY "${_prefix}${_exp}")
|
||||
set (_glob "/*")
|
||||
else (IS_DIRECTORY "${_prefix}${_exp}")
|
||||
set (_glob "")
|
||||
endif (IS_DIRECTORY "${_prefix}${_exp}")
|
||||
file (GLOB_RECURSE _disabled RELATIVE ${PROJECT_SOURCE_DIR} "${_prefix}${_exp}${_glob}")
|
||||
foreach (_file IN ITEMS ${_disabled})
|
||||
list (REMOVE_ITEM ${opm}_SOURCES "${PROJECT_SOURCE_DIR}/${_file}")
|
||||
endforeach (_file)
|
||||
endforeach (_exp)
|
||||
endmacro (opm_disable_source opm reldir)
|
||||
|
@ -31,16 +31,8 @@
|
||||
# "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
|
||||
|
||||
include (Duplicates)
|
||||
|
||||
# list of suffixes for all the project variables
|
||||
set (_opm_proj_vars
|
||||
@ -108,13 +100,3 @@ endmacro (find_and_append_package_list_to 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)
|
||||
|
@ -26,6 +26,7 @@
|
||||
# ${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
|
||||
# ${module}_QUIET Verbosity of last find of this module
|
||||
# HAVE_${MODULE} Binary value to use in config.h
|
||||
#
|
||||
# Note: Arguments should be quoted, otherwise a list will spill into the
|
||||
@ -36,16 +37,7 @@
|
||||
|
||||
# <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)
|
||||
|
||||
include (Duplicates)
|
||||
# append all items from src into dst; both must be *names* of lists
|
||||
macro (append_found src dst)
|
||||
foreach (_item IN LISTS ${src})
|
||||
@ -56,6 +48,13 @@ macro (append_found src dst)
|
||||
endmacro (append_found src dst)
|
||||
|
||||
function (find_opm_package module deps header lib defs prog conf)
|
||||
# variables to pass on to other packages
|
||||
if (FIND_QUIETLY)
|
||||
set (${module}_QUIET "QUIET")
|
||||
else (FIND_QUIETLY)
|
||||
set (${module}_QUIET "")
|
||||
endif (FIND_QUIETLY)
|
||||
|
||||
# if someone else has included this test, don't do it again
|
||||
if (${${module}_FOUND})
|
||||
return ()
|
||||
@ -80,12 +79,17 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER})
|
||||
set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER})
|
||||
|
||||
# in addition to accepting mod-ule_ROOT, we also accept the somewhat
|
||||
# more idiomatic MOD_ULE_ROOT variant
|
||||
string (TOUPPER ${module} MODULE_UPPER)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE_UPPER})
|
||||
|
||||
# if 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))
|
||||
if (NOT (${module}_DIR OR ${module}_ROOT OR ${MODULE}_ROOT))
|
||||
string (TOLOWER "${module}" _module_lower)
|
||||
set (_guess
|
||||
"../${module}"
|
||||
@ -97,7 +101,7 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
foreach (_item IN ITEMS ${_guess})
|
||||
list (APPEND _guess_bin "${PROJECT_BINARY_DIR}/${_item}")
|
||||
endforeach (_item)
|
||||
endif (NOT (${module}_DIR OR ${module}_ROOT))
|
||||
endif (NOT (${module}_DIR OR ${module}_ROOT 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,
|
||||
@ -105,7 +109,7 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
find_path (${module}_INCLUDE_DIR
|
||||
NAMES "${header}"
|
||||
PATHS ${_guess}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${PkgConf_${module}_INCLUDE_DIRS}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_INCLUDE_DIRS}
|
||||
PATH_SUFFIXES "include"
|
||||
)
|
||||
|
||||
@ -114,7 +118,7 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
find_library (${module}_LIBRARY
|
||||
NAMES "${lib}"
|
||||
PATHS ${_guess_bin}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
|
||||
HINTS ${${module}_DIR} ${${module}_ROOT} ${${MODULE}_ROOT} ${PkgConf_${module}_LIBRARY_DIRS}
|
||||
PATH_SUFFIXES "lib" "lib/.libs" ".libs" "lib32" "lib64" "lib/${CMAKE_LIBRARY_ARCHITECTURE}"
|
||||
)
|
||||
else (NOT "${lib}" STREQUAL "")
|
||||
@ -175,13 +179,11 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
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}_INCLUDE_DIRS CMAKE_REQUIRED_INCLUDES)
|
||||
append_found (${module}_LIBRARIES CMAKE_REQUIRED_LIBRARIES)
|
||||
# since we don't have any config.h yet
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_DEFINITIONS})
|
||||
list (APPEND CMAKE_REQUIRED_DEFINITIONS ${${module}_CMD_CONFIG})
|
||||
string (TOUPPER ${module} MODULE)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE})
|
||||
check_cxx_source_compiles ("${prog}" HAVE_${MODULE})
|
||||
cmake_pop_check_state ()
|
||||
|
||||
@ -195,7 +197,7 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
find_package_handle_standard_args (
|
||||
${module}
|
||||
DEFAULT_MSG
|
||||
${module}_INCLUDE_DIR ${_lib_var}
|
||||
${module}_INCLUDE_DIR ${_lib_var} HAVE_${MODULE}
|
||||
)
|
||||
|
||||
# allow the user to override these from user interface
|
||||
@ -204,7 +206,6 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
|
||||
# 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
|
||||
@ -213,6 +214,7 @@ function (find_opm_package module deps header lib defs prog conf)
|
||||
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 (${module}_QUIET "${${module}_QUIET}" PARENT_SCOPE)
|
||||
set (HAVE_${MODULE} "${HAVE_${MODULE}}" PARENT_SCOPE)
|
||||
endfunction (find_opm_package module deps header lib defs prog conf)
|
||||
|
||||
@ -223,6 +225,8 @@ function (debug_find_vars module)
|
||||
message (STATUS "${module}_LIBRARIES = ${${module}_LIBRARIES}")
|
||||
message (STATUS "${module}_DEFINITIONS = ${${module}_DEFINITIONS}")
|
||||
message (STATUS "${module}_CONFIG_VARS = ${${module}_CONFIG_VARS}")
|
||||
message (STATUS "${module}_LINKER_FLAGS = ${${module}_LINKER_FLAGS}")
|
||||
message (STATUS "${module}_QUIET = ${${module}_QUIET}")
|
||||
string (TOUPPER ${module} MODULE)
|
||||
string (REPLACE "-" "_" MODULE ${MODULE})
|
||||
message (STATUS "HAVE_${MODULE} = ${HAVE_${MODULE}}")
|
||||
|
@ -108,9 +108,9 @@ endmacro (opm_compile_satellites opm prefix)
|
||||
#
|
||||
# Example:
|
||||
#
|
||||
# opm_data (tests datafiles "tests/" "*.xml")
|
||||
# opm_data (tests datafiles "tests/")
|
||||
#
|
||||
macro (opm_data satellite target dirname files)
|
||||
macro (opm_data satellite target dirname)
|
||||
# even if there are no datafiles, create the directory so the
|
||||
# satellite programs have a homedir to run in
|
||||
execute_process (
|
||||
@ -124,11 +124,6 @@ macro (opm_data satellite target dirname files)
|
||||
# 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})
|
||||
|
41
cmake/Modules/UseOpenMP.cmake
Normal file
41
cmake/Modules/UseOpenMP.cmake
Normal file
@ -0,0 +1,41 @@
|
||||
# - Use OpenMP features
|
||||
#
|
||||
# Synopsis:
|
||||
#
|
||||
# find_openmp (module)
|
||||
#
|
||||
# where:
|
||||
#
|
||||
# module Name of the module to which OpenMP libraries
|
||||
# etc. should be added, e.g. "opm-core".
|
||||
#
|
||||
# Note: Compiler flags are always added globally, to avoid ABI
|
||||
# incompatibility problems.
|
||||
#
|
||||
# It is assumed that the following variables are available
|
||||
#
|
||||
# ${module}_QUIET Verbosity level of the parent's find module
|
||||
# ${module}_LIBRARIES List of libraries to which OpenMP will be added
|
||||
#
|
||||
# Example:
|
||||
# find_openmp (opm-core)
|
||||
# remove_dup_deps (opm-core)
|
||||
|
||||
include (AddOptions)
|
||||
macro (find_openmp opm)
|
||||
# enabling OpenMP is supposedly enough to make the compiler link with
|
||||
# the appropriate libraries
|
||||
find_package (OpenMP ${${opm}_QUIET})
|
||||
list (APPEND ${opm}_LIBRARIES ${OpenMP_LIBRARIES})
|
||||
if (OPENMP_FOUND)
|
||||
add_options (C ALL_BUILDS "${OpenMP_C_FLAGS}")
|
||||
add_options (CXX ALL_BUILDS "${OpenMP_CXX_FLAGS}")
|
||||
endif (OPENMP_FOUND)
|
||||
|
||||
# threading library (search for this *after* OpenMP
|
||||
set (CMAKE_THREAD_PREFER_PTHREAD TRUE)
|
||||
find_package (Threads ${${opm}_QUIET})
|
||||
if (CMAKE_USE_PTHREADS_INIT)
|
||||
list (APPEND ${opm}_LIBRARIES ${CMAKE_THREAD_LIBS_INIT})
|
||||
endif (CMAKE_USE_PTHREADS_INIT)
|
||||
endmacro (find_openmp opm)
|
@ -97,6 +97,11 @@ function (precompile_header
|
||||
else (language STREQUAL "CXX")
|
||||
message (FATAL "Only C or C++ can have precompiled headers")
|
||||
endif (language STREQUAL "CXX")
|
||||
|
||||
# if no precompiled header was found, then we shouldn't do anything here
|
||||
if (NOT header)
|
||||
return ()
|
||||
endif (NOT header)
|
||||
|
||||
# only support precompiled headers if the compiler is gcc >= 3.4
|
||||
get_gcc_version (${language} GCC_VERSION)
|
||||
|
28
configure
vendored
28
configure
vendored
@ -141,20 +141,17 @@ while getopts -- ":-:" optchar; do
|
||||
pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON"
|
||||
rootvar=""
|
||||
;;
|
||||
agmg |\
|
||||
ert |\
|
||||
boost |\
|
||||
zlib)
|
||||
rootvar="${pkgname^^}_ROOT"
|
||||
;;
|
||||
superlu)
|
||||
rootvar="${pkgname^^}_PREFIX"
|
||||
;;
|
||||
agmg |\
|
||||
ert |\
|
||||
boost |\
|
||||
superlu |\
|
||||
SuiteSparse |\
|
||||
TinyXML |\
|
||||
opm-* |\
|
||||
dune-*)
|
||||
rootvar="${pkgname}_ROOT"
|
||||
dune-* |\
|
||||
zlib)
|
||||
rootvar="${pkgname^^}_ROOT"
|
||||
rootvar="${rootvar/-/_}"
|
||||
;;
|
||||
*)
|
||||
invalid_opt --with-${pkgname}
|
||||
@ -249,8 +246,10 @@ while getopts -- ":-:" optchar; do
|
||||
shared=""
|
||||
;;
|
||||
esac
|
||||
projuppr=${project^^}
|
||||
projuppr=${projuppr/-/_}
|
||||
test -n "${shared}" && \
|
||||
FEATURES="${FEATURES} -DBUILD_${project}_SHARED:BOOL=${shared}"
|
||||
FEATURES="${FEATURES} -DBUILD_${projuppr}_SHARED:BOOL=${shared}"
|
||||
;;
|
||||
*)
|
||||
# remove everything *after* the equal sign
|
||||
@ -270,7 +269,10 @@ done
|
||||
shift $((OPTIND-1))
|
||||
|
||||
# remove Autotools-specific variables
|
||||
ENVVARS=${@/ACLOCAL_*=*/}
|
||||
for a in "$@"; do
|
||||
a="${a/ACLOCAL_*=*/}"
|
||||
[ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\""
|
||||
done
|
||||
|
||||
# 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}"
|
||||
|
Loading…
Reference in New Issue
Block a user