diff --git a/cmake/Modules/FindQuadmath.cmake b/cmake/Modules/FindQuadmath.cmake index 4d0efd40a..51948d2aa 100644 --- a/cmake/Modules/FindQuadmath.cmake +++ b/cmake/Modules/FindQuadmath.cmake @@ -12,11 +12,12 @@ include(CMakePushCheckState) cmake_push_check_state() list(APPEND CMAKE_REQUIRED_LIBRARIES "quadmath") -CHECK_C_SOURCE_COMPILES(" +CHECK_CXX_SOURCE_COMPILES(" #include int main(void){ __float128 foo = sqrtq(123.456); + foo = FLT128_MIN; }" HAVE_QUAD) cmake_pop_check_state() diff --git a/cmake/Modules/Findopm-parser.cmake b/cmake/Modules/Findopm-parser.cmake index 293f335d1..3ae6cc0b2 100644 --- a/cmake/Modules/Findopm-parser.cmake +++ b/cmake/Modules/Findopm-parser.cmake @@ -135,7 +135,7 @@ if (NOT (OPM_PARSER_INCLUDE_DIR MATCHES "-NOTFOUND" check_cxx_source_compiles ( "#include -#include +#include int main (void) { return EXIT_SUCCESS; diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 65eec4954..538fc4f32 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -82,6 +82,16 @@ macro (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}) + # 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 # in standard system locations either, then start to wander # 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_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 - list (APPEND _guess_bin_only - "../../${module}/${_build_dir}" - "../../${_module_lower}/${_build_dir}" - ) + if (_build_dir) + list (APPEND _guess_bin_only + "../../${module}/${_build_dir}" + "../../${_module_lower}/${_build_dir}" + ) + endif (_build_dir) # generate items that are in the build, not source dir set (_guess_bin) @@ -146,10 +149,18 @@ macro (find_opm_package module deps header lib defs prog conf) ${${module}_DIR} ${${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 # 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! diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 29e3e5d0a..8aaadf934 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -33,6 +33,7 @@ Optional Features: --enable-underscoring assume Fortran routines have _ suffix [default=no] --enable-ninja use Ninja build generator [default=no] (automatically implies --enable-underscoring) + --config-cache Reuse build configuration cache from a previous run Optional Packages: --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 buildname= 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 option_check=yes @@ -168,6 +171,12 @@ for OPT in "$@"; do OPTARG=${OPT#--} # OPTARG now contains everything after double dashes 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=*) # allow the user to use these build macros for another # 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 [ -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 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 ---