From 476aff4697654f655b2ae270743da42447fc2fa5 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Mon, 26 Aug 2013 09:55:13 +0200 Subject: [PATCH 1/7] Allow build tree of SuiteSparse to be used as root With this changeset, the build tree of SuiteSparse can be used as the root; the package does not have to be installed. --- cmake/Modules/FindSuiteSparse.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index e4ce7929..77997375 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -161,13 +161,13 @@ foreach (module IN LISTS SuiteSparse_MODULES) find_path (${MODULE}_INCLUDE_DIR NAMES ${module}.h PATHS ${SuiteSparse_SEARCH_PATH} - PATH_SUFFIXES "include" "include/suitesparse" "include/ufsparse" + PATH_SUFFIXES "include" "include/suitesparse" "include/ufsparse" "${MODULE}/Include" ${_no_default_path} ) find_library (${MODULE}_LIBRARY NAMES ${module} PATHS ${SuiteSparse_SEARCH_PATH} - PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse" + PATH_SUFFIXES "lib/.libs" "lib" "lib${_BITS}" "lib/${CMAKE_LIBRARY_ARCHITECTURE}" "lib/ufsparse" "${MODULE}/Lib" ${_no_default_path} ) # start out by including the module itself; other dependencies will be added later From 8131f704349a31d2baeb23a5dab3662a57cce39c Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 27 Aug 2013 14:37:14 +0200 Subject: [PATCH 2/7] Test ERT for a newer API level We use an ERT version which needs to know whether at least this function signature exists. The earlier implementation covers too many versions. --- cmake/Modules/FindERT.cmake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/FindERT.cmake b/cmake/Modules/FindERT.cmake index 6976b429..2f15d4f5 100644 --- a/cmake/Modules/FindERT.cmake +++ b/cmake/Modules/FindERT.cmake @@ -199,8 +199,8 @@ if (NOT (ERT_INCLUDE_DIR MATCHES "-NOTFOUND" OR ERT_LIBRARIES MATCHES "-NOTFOUND check_c_source_compiles ( "#include int main (void) { - int sz; - sz = ecl_util_get_sizeof_ctype (ECL_INT_TYPE); + bool ok; + ok = ecl_util_fmt_file (\"foo.bar\", &ok); return 0; }" HAVE_ERT) cmake_pop_check_state () From 1065ca3589bcb8aa93508be68c261a40377dc0b5 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 27 Aug 2013 22:26:21 +0200 Subject: [PATCH 3/7] Noarch lib-dir was only used in one wrong place dune.module does not contain any paths to architecture-specific binaries. It is therefore always installed in no-arch lib/ directory. Thus, there is no need to have a variable for this, and there was no other users of this variable either. --- cmake/Modules/OpmInstall.cmake | 2 +- cmake/Modules/UseMultiArch.cmake | 16 +++------------- 2 files changed, 4 insertions(+), 14 deletions(-) diff --git a/cmake/Modules/OpmInstall.cmake b/cmake/Modules/OpmInstall.cmake index 1c713717..59435249 100644 --- a/cmake/Modules/OpmInstall.cmake +++ b/cmake/Modules/OpmInstall.cmake @@ -50,6 +50,6 @@ macro (opm_install opm) endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG) install ( FILES ${PROJECT_SOURCE_DIR}/dune.module - DESTINATION ${CMAKE_INSTALL_LIBDIR_NOARCH}${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} + DESTINATION lib${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} ) endmacro (opm_install opm) diff --git a/cmake/Modules/UseMultiArch.cmake b/cmake/Modules/UseMultiArch.cmake index 06a40126..f1a5d665 100644 --- a/cmake/Modules/UseMultiArch.cmake +++ b/cmake/Modules/UseMultiArch.cmake @@ -5,10 +5,6 @@ # depending on the platform; use this path # for platform-specific binaries. # -# CMAKE_INSTALL_LIBDIR_NOARCH to lib or lib64 depending on the platform; -# use this path for architecture-independent -# files. -# # Note that it will override the results of GNUInstallDirs if included after # that module. @@ -22,21 +18,15 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") else (EXISTS "/etc/debian_version") # 64-bit system? if (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (_libdir_noarch "lib64") + set (_libdir_def "lib64") else (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (_libdir_noarch "lib") + set (_libdir_def "lib") endif (CMAKE_SIZEOF_VOID_P EQUAL 8) - set (_libdir_def "${_libdir_noarch}") endif (EXISTS "/etc/debian_version") else ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") set (_libdir_def "lib") - set (_libdir_noarch "lib") endif ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") # let the user override if somewhere else is desirable set (CMAKE_INSTALL_LIBDIR "${_libdir_def}" CACHE PATH "Object code libraries") -set (CMAKE_INSTALL_LIBDIR_NOARCH "${_libdir_noarch}" CACHE PATH "Architecture-independent library files") -mark_as_advanced ( - CMAKE_INSTALL_LIBDIR - CMAKE_INSTALL_LIBDIR_NOARCH - ) +mark_as_advanced (CMAKE_INSTALL_LIBDIR) From 47b2c64675cd9c2dc0e8105161659991b7c2bfac Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 27 Aug 2013 22:28:53 +0200 Subject: [PATCH 4/7] Always search for dune.module in no-arch lib-dir The previous version may have ended up in lib64/ instead of lib/; now we remove the arch-specific suffix from the path, and always use the no-arch version. --- cmake/Modules/UseDuneVer.cmake | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index ef917d08..199ac6ea 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -62,7 +62,17 @@ function (find_dune_version suite module) # remove multi-arch part of the library path to get parent get_filename_component (_lib_path "${_lib_path}" PATH) endif () - set (_dune_mod "${_lib_path}${_multilib}/dunecontrol/${suite}-${module}/dune.module") + get_filename_component (_immediate "${_lib_path}" NAME) + if (("${_immediate}" STREQUAL "${CMAKE_INSTALL_LIBDIR}") + OR ("${_immediate}" STREQUAL "lib")) + # 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) + endif () + # 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}/lib${_multilib}/dunecontrol/${suite}-${module}/dune.module") if (NOT EXISTS "${_dune_mod}") # use the name itself as a flag for whether it was found or not set (_dune_mod "") @@ -71,8 +81,14 @@ function (find_dune_version suite module) # if it is not available, it may make havoc having empty defines in the source # code later, so we bail out early - if (${suite}-${module}_FIND_REQUIRED AND NOT _dune_mod) - message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module}") + if (_dune_mod) + message (STATUS "Version of ${suite}-${module} from ${_dune_mod}") + else () + if (${suite}-${module}_FIND_REQUIRED) + message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module}") + else () + return () + endif () endif () # parse the file for the Version: field From c26ea374eae56ef8f2367a7d6cc1dc1b90db61f6 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 28 Aug 2013 00:27:41 +0200 Subject: [PATCH 5/7] Special handling for some recognized env. vars. CMake does not like that you specify the compiler with the environment variables, instead preferring that you set them as cache variables. This layer translate between the names of the the two. --- cmake/Scripts/configure | 53 +++++++++++++++++++++++++++++++++++++---- 1 file changed, 48 insertions(+), 5 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 8e4ed96b..cbefff47 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -97,6 +97,15 @@ invalid_opt () { # default values prefix=/usr/local +#c_compiler=" -DCMAKE_C_COMPILER=cc" +c_compiler= +c_opts= +#cxx_compiler=" -DCMAKE_CXX_COMPILER=c++" +cxx_compiler= +cxx_opts= +#fort_compiler=" -DCMAKE_Fortran_COMPILER=fc" +fort_compiler= +fort_opts= #buildtype=" -DCMAKE_BUILD_TYPE=Debug" buildtype= #pch_use=" -DPRECOMPILE_HEADERS:BOOL=ON" @@ -405,15 +414,49 @@ done # remove all arguments processed by getopts shift $((OPTIND-1)) -# remove Autotools-specific variables. notice the usage of a quoted -# array: each element will be returned even with spaces. +# notice the usage of a quoted array: each element will be returned +# even with spaces. for a in "${VARS[@]}"; do - a="${a/ACLOCAL_*=*/}" - [ -n "$a" ] && ENVVARS="$ENVVARS \"${a/\"/\\\"}\"" + case "$a" in + ACLOCAL_*=*) + # remove Autotools-specific variables. + ;; + CC=*) + # special processing for compiler options + a=${a#CC=} + c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\"" + ;; + CXX=*) + a=${a#CXX=} + cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\"" + ;; + CFLAGS=*) + a=${a#CFLAGS=} + c_opts=" -DCMAKE_C_FLAGS=\"${a/\"/\\\"}\"" + ;; + CXXFLAGS=*) + a=${a#CXXFLAGS=} + cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\"" + ;; + FC=*) + a=${a#FC=} + fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\"" + ;; + FFLAGS=*) + a=${a#FFLAGS=} + fort_opts=" -DCMAKE_Fortran_FLAGS=\"${a/\"/\\\"}\"" + ;; + *) + ENVVARS="$ENVVARS \"${a/\"/\\\"}\"" + ;; + esac done +# only wrap in env command if any variable were actually passed +[ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} " + # pass everything on to CMake -CMDLINE="env ${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} ${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} ${FEATURES}" echo --- calling CMake --- echo ${CMDLINE} eval exec ${CMDLINE} From 976c5c54a29f57fbd2228e202feada046c24b998 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 28 Aug 2013 09:47:52 +0200 Subject: [PATCH 6/7] Print version number in log together with location --- cmake/Modules/UseDuneVer.cmake | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index 199ac6ea..116de6ce 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -81,9 +81,7 @@ function (find_dune_version suite module) # if it is not available, it may make havoc having empty defines in the source # code later, so we bail out early - if (_dune_mod) - message (STATUS "Version of ${suite}-${module} from ${_dune_mod}") - else () + if (NOT _dune_mod) if (${suite}-${module}_FIND_REQUIRED) message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module}") else () @@ -117,4 +115,7 @@ function (find_dune_version suite module) set (${_SUITE}_${_MODULE}_VERSION_MINOR "${_minor}" PARENT_SCOPE) set (${_SUITE}_${_MODULE}_VERSION_REVISION "${_revision}" PARENT_SCOPE) endif () + + # print the version number we detected in the configuration log + message (STATUS "Version ${_major}.${_minor}.${_revision} of ${suite}-${module} from ${_dune_mod}") endfunction (find_dune_version suite module) From 23e1896e401294fd19d7647a23c859eff88e2135 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 28 Aug 2013 11:03:15 +0200 Subject: [PATCH 7/7] Mimic Autotools way to specify non-standard Boost If Boost is installed in say /usr/include/boost141 and /usr/lib64/boost141, then there is no root you can specify to pick them both up. However, whereas Autotools uses --with-boost and --with-boost-libdir, FindBoost in CMake changes to using two different variables: BOOST_INCLUDEDIR and BOOST_LIBRARYDIR. Using the header directory for BOOST_ROOT will not work (in particularily not with old CMake versions). --- cmake/Scripts/configure | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index cbefff47..4d571010 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -129,6 +129,10 @@ use_samples= use_ninja= #use_underscoring=" -DUSE_UNDERSCORING=OFF" use_underscoring= +# boost_root="" +boost_root= +boost_libdir= +boost_opts= # default is to warn for unknown options, but this can be disabled option_check=yes @@ -208,8 +212,16 @@ for OPT in "$@"; do mpi-prefix) rootvar="_MPI_PREFIX_PATH" ;; + boost) + # special handling of this package, see further below + boost_root="${pkgloc}" + rootvar="" + ;; + boost-libdir) + boost_libdir="${pkgloc}" + rootvar="" + ;; alugrid |\ - boost |\ eigen3 |\ ert |\ metis |\ @@ -414,6 +426,24 @@ done # remove all arguments processed by getopts shift $((OPTIND-1)) +# special handling of Boost: if --with-boost-libdir has been used, +# then the --with-boost turns into specifying the header directory +# and not the search root. this mirrors the functionality in the +# Autotools ax_boost_base.m4. necessary because FindBoost in CMake +# uses two different variables if you want to specify them separately +if [ -n "${boost_libdir}" ]; then + boost_opts=" -DBOOST_LIBRARYDIR=\"${boost_libdir}\"" + if [ -n "${boost_root}" ]; then + boost_opts="${boost_opts} -DBOOST_INCLUDEDIR=\"${boost_root}\"" + fi +else + if [ -n "${boost_root}" ]; then + boost_opts=" -DBOOST_ROOT=\"${boost_root}\"" + else + boost_opts="" + fi +fi + # notice the usage of a quoted array: each element will be returned # even with spaces. for a in "${VARS[@]}"; do @@ -456,7 +486,7 @@ done [ -n "${ENVVARS}" ] && ENVVARS="env ${ENVVARS} " # 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} ${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} ${FEATURES}" echo --- calling CMake --- echo ${CMDLINE} eval exec ${CMDLINE}