Merge pull request #61 from bska/061_cmake

Synchronise build system with opm-core
This commit is contained in:
Atgeirr Flø Rasmussen 2013-11-25 03:52:32 -08:00
commit fb672abee9
4 changed files with 52 additions and 18 deletions

View File

@ -12,11 +12,12 @@ include(CMakePushCheckState)
cmake_push_check_state() cmake_push_check_state()
list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath") list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath")
CHECK_C_SOURCE_COMPILES(" CHECK_CXX_SOURCE_COMPILES("
#include <quadmath.h> #include <quadmath.h>
int main(void){ int main(void){
__float128 foo = sqrtq(123.456); __float128 foo = sqrtq(123.456);
foo = FLT128_MIN;
}" HAVE_QUAD) }" HAVE_QUAD)
cmake_pop_check_state() cmake_pop_check_state()

View File

@ -135,7 +135,7 @@ if (NOT (OPM_PARSER_INCLUDE_DIR MATCHES "-NOTFOUND"
check_cxx_source_compiles ( check_cxx_source_compiles (
"#include <cstdlib> "#include <cstdlib>
#include <opm/parser/eclipse/Parser/Parser.hpp> #include <opm/parser/eclipse/Deck/Deck.hpp>
int main (void) { int main (void) {
return EXIT_SUCCESS; return EXIT_SUCCESS;

View File

@ -82,6 +82,16 @@ macro (find_opm_package module deps header lib defs prog conf)
set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER}) set (${module}_DEFINITIONS ${PkgConf_${module}_CFLAGS_OTHER})
set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER}) set (${module}_LINKER_FLAG ${PkgConf_${module}_LDFLAGS_OTHER})
# try to figure out whether we are in a subdir build tree, and attempt
# to put the same name as the appropriate build tree for the module
get_filename_component (_build_dir "${CMAKE_CURRENT_BINARY_DIR}" NAME)
# don't bother if we are in a project specific directory already
# (assuming no-one wants to name the build dir after another module!)
if ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
set (_build_dir "")
endif ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
# if the user hasn't specified any location, and it isn't found # if the user hasn't specified any location, and it isn't found
# in standard system locations either, then start to wander # in standard system locations either, then start to wander
# about and look for it in proximity to ourself. Qt Creator likes # about and look for it in proximity to ourself. Qt Creator likes
@ -98,21 +108,14 @@ macro (find_opm_package module deps header lib defs prog conf)
"../${module}-build" "../${module}-build"
"../${_module_lower}-build" "../${_module_lower}-build"
) )
# try to figure out whether we are in a subdir build tree, and attempt
# to put the same name as the appropriate build tree for the module
get_filename_component (_build_dir "${CMAKE_CURRENT_BINARY_DIR}" NAME)
# don't bother if we are in a project specific directory already
# (assuming no-one wants to name the build dir after another module!)
if ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
set (_build_dir "")
endif ("${_build_dir}" STREQUAL "${PROJECT_NAME}")
# look in similar dirs for the other module # look in similar dirs for the other module
list (APPEND _guess_bin_only if (_build_dir)
"../../${module}/${_build_dir}" list (APPEND _guess_bin_only
"../../${_module_lower}/${_build_dir}" "../../${module}/${_build_dir}"
) "../../${_module_lower}/${_build_dir}"
)
endif (_build_dir)
# generate items that are in the build, not source dir # generate items that are in the build, not source dir
set (_guess_bin) set (_guess_bin)
@ -146,10 +149,18 @@ macro (find_opm_package module deps header lib defs prog conf)
${${module}_DIR} ${${module}_DIR}
${${module}_ROOT} ${${module}_ROOT}
${${MODULE}_ROOT} ${${MODULE}_ROOT}
${${module}_DIR}/..
${${module}_ROOT}/..
${${MODULE}_ROOT}/..
) )
# only add parent directories for those variants that are actually set
# (otherwise, we'll inadvertedly add the root directory (=all))
if (${module}_DIR)
list (APPEND _guess ${${module}_DIR}/..)
endif (${module}_DIR)
if (${module}_ROOT)
list (APPEND _guess ${${module}_ROOT}/..)
endif (${module}_ROOT)
if (${MODULE}_ROOT)
list (APPEND _guess ${${MODULE}_ROOT}/..)
endif (${MODULE}_ROOT)
# don't search the system paths! that would be dangerous; if there # don't search the system paths! that would be dangerous; if there
# is a problem in our own specified directory, we don't necessarily # is a problem in our own specified directory, we don't necessarily
# want an old version that is left in one of the system paths! # want an old version that is left in one of the system paths!

View File

@ -33,6 +33,7 @@ Optional Features:
--enable-underscoring assume Fortran routines have _ suffix [default=no] --enable-underscoring assume Fortran routines have _ suffix [default=no]
--enable-ninja use Ninja build generator [default=no] --enable-ninja use Ninja build generator [default=no]
(automatically implies --enable-underscoring) (automatically implies --enable-underscoring)
--config-cache Reuse build configuration cache from a previous run
Optional Packages: Optional Packages:
--with-alugrid=PATH use the ALUGrid library from a specified location --with-alugrid=PATH use the ALUGrid library from a specified location
@ -138,6 +139,8 @@ boost_opts=
# configuration that is passed on to CTest/CDash # configuration that is passed on to CTest/CDash
buildname= buildname=
site= site=
# if set, this prevents the previous CMake cache from being deleted
config_cache=
# default is to warn for unknown options, but this can be disabled # default is to warn for unknown options, but this can be disabled
option_check=yes option_check=yes
@ -168,6 +171,12 @@ for OPT in "$@"; do
OPTARG=${OPT#--} OPTARG=${OPT#--}
# OPTARG now contains everything after double dashes # OPTARG now contains everything after double dashes
case "${OPTARG}" in case "${OPTARG}" in
config-cache)
cache-file=*)
# prevent the previous CMake cache from being deleted. The
# second option is only here for Dune/autotools compatibility
config_cache="1"
;;
src-dir=*) src-dir=*)
# allow the user to use these build macros for another # allow the user to use these build macros for another
# project (so source-dir is not relative to us) # project (so source-dir is not relative to us)
@ -510,6 +519,19 @@ done
# only wrap in env command if any variable were actually passed # only wrap in env command if any variable were actually passed
[ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} " [ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} "
# delete the previous 'CMakeFiles' directory. this prevents an endless
# loop if variables that require a full regeneration of the cache are
# set (most notably 'CXX' and 'CXX_FLAGS').
# For more details, see http://www.cmake.org/Bug/view.php?id=14119
if test "$config_cache" = ""; then
echo "--- deleting previous CMake files ---"
rm -rf CMakeFiles
rm -f CMakeCache.txt
elif test "$c_compiler$c_opts$cxx_compiler$cxx_opts$fort_compiler$fort_opts" != ""; then
echo "--- WARNING '--config-cache' option specified but a compiler was set"
echo "--- from the command line. This may lead to an infinite loop!"
fi
# pass everything on to CMake # 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}${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 --- calling CMake ---