mirror of
https://github.com/OPM/opm-simulators.git
synced 2025-02-25 18:55:30 -06:00
Merge branch '037_cmake'
This synchronises the opm-autodiff build system with that of opm-core.
This commit is contained in:
commit
341f0f666d
@ -37,6 +37,11 @@ function (add_options langs builds)
|
||||
else (NOT ("${build}" STREQUAL "ALL_BUILDS"))
|
||||
set (_bld "")
|
||||
endif (NOT ("${build}" STREQUAL "ALL_BUILDS"))
|
||||
# if we want everything in the "global" flag, then simply
|
||||
# ignore the build type here and go add everything to that one
|
||||
if (CMAKE_NOT_USING_CONFIG_FLAGS)
|
||||
set (_bld "")
|
||||
endif ()
|
||||
foreach (_opt IN LISTS ARGN)
|
||||
set (_var "CMAKE_${lang}_FLAGS${_bld}")
|
||||
#message (STATUS "Adding \"${_opt}\" to \${${_var}}")
|
||||
@ -61,22 +66,37 @@ function (add_options langs builds)
|
||||
endfunction (add_options lang build)
|
||||
|
||||
# set varname to flag unless user has specified something that matches regex
|
||||
function (set_default_option varname flag regex)
|
||||
if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
|
||||
function (set_default_option lang varname flag regex)
|
||||
# lang is either C, CXX or Fortran
|
||||
if ("${lang}" STREQUAL "Fortran")
|
||||
set (letter "F")
|
||||
else ()
|
||||
set (letter "${lang}")
|
||||
endif ()
|
||||
string (TOUPPER "${CMAKE_BUILD_TYPE}" _build)
|
||||
if ((NOT ("$ENV{${letter}FLAGS}" MATCHES "${regex}"))
|
||||
AND (NOT ("${CMAKE_${lang}_FLAGS}" MATCHES "${regex}"))
|
||||
AND (NOT ("${CMAKE_${lang}_FLAGS_${_build}}" MATCHES "${regex}")))
|
||||
set (${varname} ${flag} PARENT_SCOPE)
|
||||
else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
|
||||
else ()
|
||||
set (${varname} PARENT_SCOPE)
|
||||
endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}"
|
||||
AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}")
|
||||
endif ()
|
||||
endfunction (set_default_option)
|
||||
|
||||
# note: this must be called before project()
|
||||
# clear default options as a proxy for not using any default options
|
||||
# at all. there is one *huge* problem with this: CMake runs the platform
|
||||
# initialization before executing any line at all in the project and
|
||||
# there seems to be no way to disable that behaviour, so we cannot really
|
||||
# distinguish between a platform default and something that the user has
|
||||
# passed on the command line. the best thing we can do is to all user-
|
||||
# defined setting if they are something other than the platform default.
|
||||
macro (no_default_options)
|
||||
# prevent the platform probe to set options
|
||||
set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE)
|
||||
foreach (lang IN ITEMS C CXX Fortran)
|
||||
foreach (build IN ITEMS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO)
|
||||
if ("${CMAKE_${lang}_FLAGS_${build}}" STREQUAL "${CMAKE_${lang}_FLAGS_${build}_INIT}")
|
||||
# for some strange reason we cannot clear this flag, only set it to empty
|
||||
set (CMAKE_${lang}_FLAGS_${build} "")
|
||||
endif ()
|
||||
endforeach (build)
|
||||
endforeach (lang)
|
||||
endmacro (no_default_options)
|
||||
|
@ -72,36 +72,39 @@ endif (NOT LAPACK_FOUND)
|
||||
find_library (MATH_LIBRARY NAMES "m")
|
||||
set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MATH_LIBRARY})
|
||||
|
||||
# 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
|
||||
|
||||
# if we don't get any further clues about where to look, then start
|
||||
# roaming around the system
|
||||
set (_no_default_path "")
|
||||
|
||||
# search system directories by default
|
||||
set (SuiteSparse_SEARCH_PATH)
|
||||
|
||||
# pick up paths from the environment if specified there; these replace the
|
||||
# pre-defined paths so that we don't accidentially pick up old stuff
|
||||
if (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
|
||||
set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "")
|
||||
if (${SuiteSparse_DIR})
|
||||
if (SuiteSparse_DIR)
|
||||
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (${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}")
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "")
|
||||
if (${SuiteSparse_ROOT})
|
||||
if (SuiteSparse_ROOT)
|
||||
set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}")
|
||||
endif (SuiteSparse_ROOT)
|
||||
# most commonly, we use the uppercase version of this variable
|
||||
if (SUITESPARSE_ROOT)
|
||||
set (SuiteSparse_SEARCH_PATH "${SUITESPARSE_ROOT}")
|
||||
endif (SUITESPARSE_ROOT)
|
||||
|
||||
# if we have specified a search path, then confine ourselves to that
|
||||
if (SuiteSparse_SEARCH_PATH)
|
||||
set (_no_default_path "NO_DEFAULT_PATH")
|
||||
endif (${SuiteSparse_ROOT})
|
||||
endif (SuiteSparse_SEARCH_PATH)
|
||||
|
||||
# transitive closure of dependencies; after this SuiteSparse_MODULES is the
|
||||
# full list of modules that must be found to satisfy the user's link demands
|
||||
|
@ -60,3 +60,40 @@ macro (opm_defaults opm)
|
||||
set (Boost_NO_BOOST_CMAKE ON)
|
||||
endif (NOT BOOST_ROOT)
|
||||
endmacro (opm_defaults opm)
|
||||
|
||||
# overwrite a cache entry's value, but keep docstring and type
|
||||
# if not already in cache, then does nothing
|
||||
function (update_cache name)
|
||||
get_property (_help CACHE "${name}" PROPERTY HELPSTRING)
|
||||
get_property (_type CACHE "${name}" PROPERTY TYPE)
|
||||
if (NOT "${_type}" STREQUAL "")
|
||||
#message ("Setting ${name} to \"${${name}}\" in cache.")
|
||||
set ("${name}" "${${name}}" CACHE ${_type} "${_help}" FORCE)
|
||||
endif ()
|
||||
endfunction (update_cache name)
|
||||
|
||||
# put all compiler options currently set back into the cache, so that
|
||||
# they can be queried from there (using ccmake for instance)
|
||||
function (write_back_options)
|
||||
# build type
|
||||
update_cache (CMAKE_BUILD_TYPE)
|
||||
|
||||
# compilers
|
||||
set (languages C CXX Fortran)
|
||||
foreach (language IN LISTS _languages)
|
||||
if (CMAKE_${language}_COMPILER)
|
||||
update_cache (CMAKE_${language}_COMPILER)
|
||||
endif ()
|
||||
endforeach (language)
|
||||
|
||||
# flags (notice use of IN LISTS to get the empty variant)
|
||||
set (buildtypes "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO")
|
||||
set (processors "C" "CXX" "Fortran" "EXE_LINKER" "MODULE_LINKER" "SHARED_LINKER")
|
||||
foreach (processor IN LISTS processors)
|
||||
foreach (buildtype IN LISTS buildtypes)
|
||||
if (CMAKE_${processor}_FLAGS${buildtype})
|
||||
update_cache (CMAKE_${processor}_FLAGS${buildtype})
|
||||
endif ()
|
||||
endforeach (buildtype)
|
||||
endforeach (processor)
|
||||
endfunction (write_back_options)
|
||||
|
@ -269,3 +269,6 @@ configure_file (
|
||||
|
||||
# make sure updated version information is available in the source code
|
||||
include (UseVersion)
|
||||
|
||||
# update the cache for next run
|
||||
write_back_options ()
|
||||
|
@ -16,7 +16,7 @@ is_compiler_gcc_compatible ()
|
||||
# only debugging using the GNU toolchain is supported for now
|
||||
if (CXX_COMPAT_GCC)
|
||||
# default debug level, if not specified by the user
|
||||
set_default_option (_dbg_flag "-ggdb3" "(^|\ )-g")
|
||||
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
|
||||
|
@ -41,6 +41,11 @@ function (find_dune_version suite module)
|
||||
|
||||
# some modules does not have a library, use the directory of the
|
||||
# header files to find what would be the library dir.
|
||||
# note that when we refer to a build tree, then the libraries always
|
||||
# go into lib/, but we don't care about that because in that case,
|
||||
# dune.module isn't in the lib/ directory anyway but must be retrieved
|
||||
# from the source. hence, we only have to worry about the library
|
||||
# directory of a system installation here.
|
||||
if (NOT ${suite}-${module}_LIBRARY)
|
||||
# this suffix is gotten from UseMultiArch.cmake
|
||||
set (_lib_path "${_inc_path}/${CMAKE_INSTALL_LIBDIR}")
|
||||
@ -51,6 +56,7 @@ function (find_dune_version suite module)
|
||||
# if we have a source tree, dune.module is available there
|
||||
set (_dune_mod "${_inc_path}/dune.module")
|
||||
if (NOT EXISTS "${_dune_mod}")
|
||||
set (_last_dune_mod_src "${_dune_mod}")
|
||||
set (_dune_mod "")
|
||||
endif ()
|
||||
|
||||
@ -58,13 +64,19 @@ function (find_dune_version suite module)
|
||||
# look for the build tree; if we found the library, then the
|
||||
# dune.module file should be in a sub-directory
|
||||
get_filename_component (_immediate "${_lib_path}" NAME)
|
||||
if ("${_immediate}" STREQUAL ".libs")
|
||||
# remove autotools internal path
|
||||
get_filename_component (_lib_path "${_lib_path}" PATH)
|
||||
endif ()
|
||||
get_filename_component (_immediate "${_lib_path}" NAME)
|
||||
if ("${_immediate}" STREQUAL "${CMAKE_LIBRARY_ARCHITECTURE}")
|
||||
# remove multi-arch part of the library path to get parent
|
||||
get_filename_component (_lib_path "${_lib_path}" PATH)
|
||||
endif ()
|
||||
get_filename_component (_immediate "${_lib_path}" NAME)
|
||||
if (("${_immediate}" STREQUAL "${CMAKE_INSTALL_LIBDIR}")
|
||||
OR ("${_immediate}" STREQUAL "lib"))
|
||||
OR ("${_immediate}" STREQUAL "lib")
|
||||
OR ("${_immediate}" STREQUAL "${LIBDIR_MULTIARCH_UNAWARE}"))
|
||||
# remove library part of the path; this also undo the suffix
|
||||
# we added if we used the library as a standin
|
||||
get_filename_component (_lib_path "${_lib_path}" PATH)
|
||||
@ -72,18 +84,37 @@ function (find_dune_version suite module)
|
||||
# from this point on, _lib_path does not contain an architecture-
|
||||
# specific component anymore; dune.module is always put in straight
|
||||
# noarch lib/ since it does not contain any paths to binaries
|
||||
set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_multilib}/dunecontrol/${suite}-${module}/dune.module")
|
||||
set (_suffix "${_multilib}/dunecontrol/${suite}-${module}/dune.module")
|
||||
set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_suffix}")
|
||||
if (NOT EXISTS "${_dune_mod}")
|
||||
# use the name itself as a flag for whether it was found or not
|
||||
set (_dune_mod "")
|
||||
set (_last_dune_mod_bld "${_dune_mod}")
|
||||
# one more try, if we have a private install, then it doesn't use
|
||||
# e.g. lib64 but always lib (!)
|
||||
if ("${LIBDIR_MULTIARCH_UNAWARE}" STREQUAL "lib")
|
||||
set (_dune_mod "")
|
||||
else ()
|
||||
set (_dune_mod "${_lib_path}/lib${_suffix}")
|
||||
if (NOT EXISTS "${_dune_mod}")
|
||||
set (_last_dune_mod_pri "${_dune_mod}")
|
||||
# use the name itself as a flag for whether it was found or not
|
||||
set (_dune_mod "")
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
# if it is not available, it may make havoc having empty defines in the source
|
||||
# code later, so we bail out early
|
||||
if (NOT _dune_mod)
|
||||
if (${suite}-${module}_FIND_REQUIRED)
|
||||
message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module}")
|
||||
if (${suite}-${module}_FOUND)
|
||||
set (_searched_paths "\"${_last_dune_mod_src}\"")
|
||||
if (NOT ("${_last_dune_mod_bld}" STREQUAL ""))
|
||||
set (_searched_paths "either ${_searched_paths} or \"${_last_dune_mod_bld}\"")
|
||||
endif ()
|
||||
if (NOT ("${_last_dune_mod_pri}" STREQUAL ""))
|
||||
set (_searched_paths "${_searched_paths} or \"${_last_dune_mod_pri}\"")
|
||||
endif ()
|
||||
message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module} (looking for ${_searched_paths})")
|
||||
else ()
|
||||
return ()
|
||||
endif ()
|
||||
|
@ -17,7 +17,6 @@ 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)
|
||||
|
@ -37,8 +37,8 @@ if (CXX_COMPAT_GCC)
|
||||
endif (WITH_NATIVE)
|
||||
|
||||
# default optimization flags, if not set by user
|
||||
set_default_option (_opt_dbg "-O0" "(^|\ )-O")
|
||||
set_default_option (_opt_rel "-O3" "(^|\ )-O")
|
||||
set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O")
|
||||
set_default_option (CXX _opt_rel "-O3" "(^|\ )-O")
|
||||
|
||||
# use these options for debug builds - no optimizations
|
||||
add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG")
|
||||
|
@ -39,6 +39,7 @@ function (distro_name varname)
|
||||
file (GLOB has_os_release /etc/os-release)
|
||||
file (GLOB has_lsb_release /etc/lsb-release)
|
||||
file (GLOB has_sys_release /etc/system-release)
|
||||
file (GLOB has_redhat_release /etc/redhat-release)
|
||||
set (_descr)
|
||||
# start with /etc/os-release,
|
||||
# see <http://0pointer.de/blog/projects/os-release.html>
|
||||
@ -52,6 +53,8 @@ function (distro_name varname)
|
||||
if (NOT _descr)
|
||||
if (NOT has_sys_release STREQUAL "")
|
||||
file (READ /etc/system-release _descr)
|
||||
elseif (NOT has_redhat_release STREQUAL "")
|
||||
file (READ /etc/redhat-release _descr)
|
||||
else (NOT has_sys_release STREQUAL "")
|
||||
# no yet known release file found
|
||||
set (_descr "unknown")
|
||||
|
@ -6,7 +6,7 @@ is_compiler_gcc_compatible ()
|
||||
|
||||
if (CXX_COMPAT_GCC)
|
||||
# default warnings flags, if not set by user
|
||||
set_default_option (_warn_flag "-Wall" "(^|\ )-W")
|
||||
set_default_option (CXX _warn_flag "-Wall" "(^|\ )-W")
|
||||
if (_warn_flag)
|
||||
message (STATUS "All warnings enabled: ${_warn_flag}")
|
||||
add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}")
|
||||
|
@ -17,6 +17,7 @@ set (ewoms_DEPS
|
||||
"dune-geometry REQUIRED"
|
||||
"dune-grid REQUIRED"
|
||||
"dune-istl REQUIRED"
|
||||
"opm-core REQUIRED"
|
||||
"opm-material REQUIRED"
|
||||
# valgrind client requests
|
||||
"Valgrind"
|
||||
|
@ -17,5 +17,4 @@ set (opm-material_DEPS
|
||||
"opm-core REQUIRED"
|
||||
# DUNE dependency
|
||||
"dune-common REQUIRED"
|
||||
"dune-istl REQUIRED"
|
||||
)
|
||||
|
5
cmake/Scripts/configure
vendored
5
cmake/Scripts/configure
vendored
@ -145,7 +145,7 @@ VARS=()
|
||||
|
||||
# command that launches cmake; look for 2.8 if available
|
||||
if [ "${CMAKE_COMMAND}" = "" ]; then
|
||||
if which cmake28 >/dev/null 2>&1; then
|
||||
if [ -x "$(command -v cmake28)" ]; then
|
||||
CMAKE_COMMAND=cmake28
|
||||
else
|
||||
CMAKE_COMMAND=cmake
|
||||
@ -454,10 +454,12 @@ for a in "${VARS[@]}"; do
|
||||
CC=*)
|
||||
# special processing for compiler options
|
||||
a=${a#CC=}
|
||||
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
|
||||
c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CXX=*)
|
||||
a=${a#CXX=}
|
||||
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
|
||||
cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
CFLAGS=*)
|
||||
@ -470,6 +472,7 @@ for a in "${VARS[@]}"; do
|
||||
;;
|
||||
FC=*)
|
||||
a=${a#FC=}
|
||||
[ -x "$(command -v $a)" ] && a=$(command -v "$a")
|
||||
fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\""
|
||||
;;
|
||||
FFLAGS=*)
|
||||
|
Loading…
Reference in New Issue
Block a user