From c1d8d953c12ff1ac3c4afdbb06680b48b2b8cc6f Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Sat, 9 Nov 2013 16:53:44 +0100 Subject: [PATCH 1/9] fix test for HAVE_QUAD on some instances of ubuntu 13.10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit I haven't figured out why this happens, but on one of my computers running kubuntu 13.10 g++ says the following if one tries to use quadruple precision math: /home/erne/src/ewoms/ewoms/common/quad.hh: In static member function ‘static quad std::numeric_limits<__float128>::min()’: /home/erne/src/ewoms/ewoms/common/quad.hh:52:14: error: unable to find numeric literal operator ‘operator"" Q’ { return FLT128_MIN; } since this happens only on this machine and only with the c++ (but not the C) compiler, i suppose that this is either an upgrade issue with kubuntu or an issue with the ubuntu gcc stack. Strangely enough, my other kubuntu machine does not have a problem with that... In any case also testing for assignability of constants and using the C++ compiler for the quadmath test won't hurt... --- cmake/Modules/FindQuadmath.cmake | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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() From 2405462a3874ceb7200dec41cb1104283fe54f56 Mon Sep 17 00:00:00 2001 From: Joakim Hove Date: Thu, 14 Nov 2013 10:20:05 +0100 Subject: [PATCH 2/9] Changed the check_cxx_source_compiles() in Findopm-parser to look for Deck.hpp; Parser.hpp had uneccasary complicated interaction with cJSON --- cmake/Modules/Findopm-parser.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; From 2e9272384da54956c4c187b85b8d83986eefe932 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 11 Nov 2013 16:57:26 +0100 Subject: [PATCH 3/9] build system: prevent endless loop when using dunecontrol this seems to be a bug in cmake 2.8.10.2: if the user sets the CMAKE_CXX_COMPILER variable for a build directory where this variable has already been set, one gets an endless loop. This stings especially if using the dunecontrol compatibility layer as the compiler flags are unconditionally set via the CXX_FLAGS environment variable in the options file. Running duncontrol on a module twice will thus trigger the infinite loop if some compiler flags are set by the user. The solution is relatively simple: Delete the CMakeFiles directory before calling cmake. for the dunecontrol compatibility mode, we do this in the configure script. For details about the cmake bug, see http://www.cmake.org/Bug/view.php?id=14119 --- cmake/Scripts/configure | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 29e3e5d0a..785fa13c3 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -510,6 +510,13 @@ 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 +echo "--- deleting previous CMake files ---" +rm -rf CMakeFiles + # 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 --- From ba4c7400ba69da205ca39fa99f74229685cda822 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 13 Nov 2013 11:46:27 +0100 Subject: [PATCH 4/9] configure script: also delete the cmake cache This replicates the autotools behavior and was suggested by Roland Kaufmann. --- cmake/Scripts/configure | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 785fa13c3..354707125 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -516,6 +516,7 @@ done # For more details, see http://www.cmake.org/Bug/view.php?id=14119 echo "--- deleting previous CMake files ---" rm -rf CMakeFiles +rm -f CMakeCache.txt # 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}" From 5e73968b57e9e0d0f8a60554e65f881a9d12b401 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Wed, 13 Nov 2013 15:21:39 +0100 Subject: [PATCH 5/9] configure script: add a stub implementation for the --config-cache argument so far, it is only a flag which prevents the cache from being deleted. To warn the user about a potential infinite loop, a warning is printed if this flag was specified and some compiler or some compiler flags were set by the user. This idea was proposed by Roland Kaufmann. --- cmake/Scripts/configure | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 354707125..f14a7f9fc 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -168,6 +168,9 @@ for OPT in "$@"; do OPTARG=${OPT#--} # OPTARG now contains everything after double dashes case "${OPTARG}" in + config-cache*) + config_cache="1" + ;; src-dir=*) # allow the user to use these build macros for another # project (so source-dir is not relative to us) @@ -514,9 +517,14 @@ done # 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 -echo "--- deleting previous CMake files ---" -rm -rf CMakeFiles -rm -f CMakeCache.txt +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}" From 4c246092b64f1cb2b830b1889f0714f94afd1d60 Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 15 Nov 2013 13:08:09 +0100 Subject: [PATCH 6/9] include the latest review comments by Roland Kaufmann --- cmake/Scripts/configure | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index f14a7f9fc..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,7 +171,10 @@ for OPT in "$@"; do OPTARG=${OPT#--} # OPTARG now contains everything after double dashes case "${OPTARG}" in - config-cache*) + 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=*) From ce569c75d444d399e99a642225857d434d93f1c2 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 18 Nov 2013 11:21:06 +0100 Subject: [PATCH 7/9] Search in build/ sub-dir if only suite root is given If the package suite was given (e.g. DUNE_ROOT=/blum), then the code set up the root for each individual package automatically (e.g. DUNE_COMMON_ROOT=/blum/dune-common), but the path which was then activated did not get the local build sub-directory (e.g. if we are building opm-autodiff in /frub/opm-autodiff/build, then the local build directory is "build/"), and thus this was not appended to the library search path. The result was that the source was found (because the root pointed to a valid source tree), but the library was not (because it is "hidden" in the subdirectory). --- cmake/Modules/OpmPackage.cmake | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 65eec4954..ec055133e 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,15 +108,6 @@ 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 From 47eb8a054963e2bc8d792d1bbd2f0ca72002b417 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 18 Nov 2013 13:19:18 +0100 Subject: [PATCH 8/9] Only add build sub-directory if it is actually used Otherwise the search will cascade down one level too many. --- cmake/Modules/OpmPackage.cmake | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index ec055133e..1b1a5bec0 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -110,10 +110,12 @@ macro (find_opm_package module deps header lib defs prog conf) ) # 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) From 847d8fe92480b2ee5504f9a7fb5545c39b16a710 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 18 Nov 2013 13:19:58 +0100 Subject: [PATCH 9/9] Only add parent directories for actual variants Otherwise we'll inadvertedly add the root directory and will probably find the system implementation underneath there. --- cmake/Modules/OpmPackage.cmake | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/OpmPackage.cmake b/cmake/Modules/OpmPackage.cmake index 1b1a5bec0..538fc4f32 100644 --- a/cmake/Modules/OpmPackage.cmake +++ b/cmake/Modules/OpmPackage.cmake @@ -149,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!