From 9320faaf837ba082670394b7b235ff8a56ef768f Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 13:18:47 +0100 Subject: [PATCH 1/9] Correct typo which made distclean target malfunction Probably typed _DIRECTORY instead of _DIR since there were other variables nearby with that suffix. --- cmake/Modules/OpmDistClean.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Modules/OpmDistClean.cmake b/cmake/Modules/OpmDistClean.cmake index f0312fae..9d0aa628 100644 --- a/cmake/Modules/OpmDistClean.cmake +++ b/cmake/Modules/OpmDistClean.cmake @@ -35,7 +35,7 @@ macro (opm_dist_clean opm) ${${opm}_STYLESHEET_COPIED} ) # script to remove empty directories (can't believe this isn't included!) - set (rmdir "${PROJECT_SOURCE_DIRECTORY}/cmake/Scripts/RemoveEmptyDir.cmake") + set (rmdir "${PROJECT_SOURCE_DIR}/cmake/Scripts/RemoveEmptyDir.cmake") add_custom_target (distclean COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES} COMMAND ${CMAKE_COMMAND} -E remove_directory CMakeFiles/ From cbd78d9cc23ca4d16b8e62892d281bb1a04b1379 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 13:53:14 +0100 Subject: [PATCH 2/9] Allow user to specify another version of CMake On CentOS, cmake28 must be used rather than the standard cmake --- configure | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 9b90c23b..5f6240f9 100755 --- a/configure +++ b/configure @@ -35,6 +35,7 @@ Optional Packages: --with-tinyxml=PATH use TinyXML library from a specified location (Note: if not found, then a bundled library will be used) + --with-cmake=PROGRAM use this program instead of \`cmake' to configure Some influential environment variables: CC C compiler command @@ -88,6 +89,9 @@ option_check=yes # this variable will get feature options FEATURES= +# command that launches cmake +CMAKE=cmake + # long arguments are implemented by putting a dash character followed by # a colon in the optspec, see trick by Arvid Requate at # @@ -110,6 +114,12 @@ while getopts -- ":-:" optchar; do pkgname=${pkgname#with-} # get the location of the package; everyhing after equal sign pkgloc=${OPTARG#*=} + # the parameter to this option is an executable program, so + # skip the directory test in that case + if [ "${pkgname}" = "cmake" ]; then + CMAKE="${pkgloc}" + break + fi # expand to full path since CMake changes to source directory (!) # this also normalize the path name wrt. not having a trailing slash pkgloc=$(test -d "${pkgloc}" && sh -c "cd \"${pkgloc}\"; pwd") @@ -254,7 +264,7 @@ shift $((OPTIND-1)) ENVVARS=${@/ACLOCAL_*=*/} # pass everything on to CMake -CMDLINE="env ${ENVVARS} cmake \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}" +CMDLINE="env ${ENVVARS} ${CMAKE} \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}" echo --- calling CMake for opm-core --- echo ${CMDLINE} eval exec ${CMDLINE} From b412acb448b7099487e3f13fd7743876066d9f6e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 20:47:55 +0100 Subject: [PATCH 3/9] Don't remove original files from in-source trees If we are building in-source, some files are not copied because they would end up being the same, e.g. GNUmakefile. --- cmake/Modules/OpmDistClean.cmake | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/OpmDistClean.cmake b/cmake/Modules/OpmDistClean.cmake index 9d0aa628..8d09c42f 100644 --- a/cmake/Modules/OpmDistClean.cmake +++ b/cmake/Modules/OpmDistClean.cmake @@ -25,7 +25,6 @@ macro (opm_dist_clean opm) Doxyfile CTestTestfile.cmake DartConfiguration.tcl - GNUmakefile lib/${${opm}_LIBTOOL_ARCHIVE} ${${opm}_DEBUG} ${tests_DEBUG} @@ -34,6 +33,12 @@ macro (opm_dist_clean opm) install_manifest.txt ${${opm}_STYLESHEET_COPIED} ) + # only remove these files if they were actually copied + if (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) + list (APPEND DISTCLEAN_FILES + GNUmakefile + ) + endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR) # script to remove empty directories (can't believe this isn't included!) set (rmdir "${PROJECT_SOURCE_DIR}/cmake/Scripts/RemoveEmptyDir.cmake") add_custom_target (distclean From 4519ccb474c44ed4c0e799f8949dd389ad9ec430 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 21:12:27 +0100 Subject: [PATCH 4/9] Provide instr. for installing deps. on CentOS Currently these doesn't include packages for SuperLU and DUNE since they are not part of EPEL and must be provided on their own. --- README | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/README b/README index b97bf3eb..091901f2 100644 --- a/README +++ b/README @@ -66,6 +66,7 @@ sudo apt-get install -y libxml2-dev Note: You should compile the OPM modules using the same toolchain that was used to build DUNE. Otherwise, you can get strange ABI errors. + DEPENDENCIES FOR SUSE BASED DISTRIBUTIONS ----------------------------------------- @@ -80,6 +81,25 @@ sudo zypper ar http://download.opensuse.org/repositories/science/openSUSE_12.2/s sudo zypper in dune-common dune-istl +DEPENDENCIES FOR RHEL BASED DISTRIBUTIONS +----------------------------------------- + +# packages necessary for building +sudo yum install make gcc-c++ gcc-gfortran cmake28 util-linux + +# packages necessary for documentation +sudo yum install doxygen ghostscript texlive + +# packages necessary for version control +sudo yum install git + +# basic libraries necessary for both DUNE and OPM +sudo yum install boost-devel suitesparse-devel blas-devel lapack-devel + +# libraries necessary for OPM +sudo yum install libxml2-devel + + DOWNLOADING ----------- From 027407e50bc15eb65e847d7e98c5e636719b9995 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 21:28:37 +0100 Subject: [PATCH 5/9] Use TinyXML instead of LibXML2 The code only uses TinyXML, so the list of dependencies was wrong, something that was covered by the bundled version of TinyXML. --- README | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README b/README index 091901f2..1af9236a 100644 --- a/README +++ b/README @@ -61,7 +61,7 @@ sudo apt-get update sudo apt-get install libdune-common-dev libdune-istl-dev libdune-grid-dev # libraries necessary for OPM -sudo apt-get install -y libxml2-dev +sudo apt-get install -y libtinyxml-dev Note: You should compile the OPM modules using the same toolchain that was used to build DUNE. Otherwise, you can get strange ABI errors. @@ -71,7 +71,7 @@ DEPENDENCIES FOR SUSE BASED DISTRIBUTIONS ----------------------------------------- # libraries -sudo zypper in libblas3 liblapack3 libboost libxml2 libumfpack +sudo zypper in libblas3 liblapack3 libboost libtinyxml-devel libumfpack # tools sudo zypper in gcc cmake git doxygen @@ -97,7 +97,7 @@ sudo yum install git sudo yum install boost-devel suitesparse-devel blas-devel lapack-devel # libraries necessary for OPM -sudo yum install libxml2-devel +sudo yum install tinyxml-devel DOWNLOADING From ad5d4847c25f1fa2dc75b6739e7c219598af29fe Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 22:44:22 +0100 Subject: [PATCH 6/9] Look for CMake 2.8 if available on system We require at least this version, and if there is a newer, it will probably break due to lack of backward compatibility anyway. --- configure | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/configure b/configure index 5f6240f9..853c06c6 100755 --- a/configure +++ b/configure @@ -89,8 +89,12 @@ option_check=yes # this variable will get feature options FEATURES= -# command that launches cmake +# command that launches cmake; look for 2.8 if available +if which cmake28 >/dev/null 2>&1; then +CMAKE=cmake28 +else CMAKE=cmake +fi # long arguments are implemented by putting a dash character followed by # a colon in the optspec, see trick by Arvid Requate at From 4fc2593bb322c04c43e5fa2b6f2c1dcb62064d24 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 14 Feb 2013 22:59:32 +0100 Subject: [PATCH 7/9] Prevent conflict between older Boost and newer CMake The probe for Boost was changed in CMake 2.8; if the system has installed configuration files tailored for an older CMake, the library paths are not setup correctly. This patch disables using those configuration files; just use the library directly instead. --- cmake/Modules/OpmDefaults.cmake | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cmake/Modules/OpmDefaults.cmake b/cmake/Modules/OpmDefaults.cmake index 6aa1bed0..73a3df9e 100644 --- a/cmake/Modules/OpmDefaults.cmake +++ b/cmake/Modules/OpmDefaults.cmake @@ -35,4 +35,15 @@ macro (opm_defaults opm) if (NOT PRECOMPILE_HEADERS) message (STATUS "Precompiled headers: disabled") endif(NOT PRECOMPILE_HEADERS) + + # if we are on a system where CMake 2.6 is the default (Hi RHEL 6!), + # the configuration files for Boost will trip up the library paths + # (look for /usr/lib64/lib64/ in the log) when used with FindBoost + # module bundled with CMake 2.8. this can be circumvented by turning + # off config mode probing if we have not explicitly specified a + # directory to look for it. for more details, see + # + if (NOT BOOST_ROOT) + set (Boost_NO_BOOST_CMAKE ON) + endif (NOT BOOST_ROOT) endmacro (opm_defaults opm) From be26e078d26cdd36f481cd90929a4e6378d08575 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Feb 2013 09:31:13 +0100 Subject: [PATCH 8/9] Allow CMake program to be specified with env. var. If you are using a custom CMake, you should be able to set the environment variable "CMAKE" and have the configure script pick up the default from there so that you don't have to specify the option every time. --- configure | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/configure b/configure index 853c06c6..b9db0033 100755 --- a/configure +++ b/configure @@ -53,6 +53,7 @@ Some influential environment variables: FFLAGS Fortran 77 compiler flags FC Fortran compiler command FCFLAGS Fortran compiler flags + CMAKE_COMMAND Executable used to run cmake scripts Use these variables to override the choices made by \`configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -90,10 +91,12 @@ option_check=yes FEATURES= # command that launches cmake; look for 2.8 if available -if which cmake28 >/dev/null 2>&1; then -CMAKE=cmake28 -else -CMAKE=cmake +if [ "${CMAKE_COMMAND}" = "" ]; then + if which cmake28 >/dev/null 2>&1; then + CMAKE_COMMAND=cmake28 + else + CMAKE_COMMAND=cmake + fi fi # long arguments are implemented by putting a dash character followed by @@ -121,7 +124,7 @@ while getopts -- ":-:" optchar; do # the parameter to this option is an executable program, so # skip the directory test in that case if [ "${pkgname}" = "cmake" ]; then - CMAKE="${pkgloc}" + CMAKE_COMMAND="${pkgloc}" break fi # expand to full path since CMake changes to source directory (!) @@ -268,7 +271,7 @@ shift $((OPTIND-1)) ENVVARS=${@/ACLOCAL_*=*/} # pass everything on to CMake -CMDLINE="env ${ENVVARS} ${CMAKE} \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}" +CMDLINE="env ${ENVVARS} ${CMAKE_COMMAND} \"$(dirname "$0")\" \"-DCMAKE_INSTALL_PREFIX=$prefix\" -DCMAKE_BUILD_TYPE=${buildtype}${pch_use}${silent_rules}${debug_loc} ${FEATURES}" echo --- calling CMake for opm-core --- echo ${CMDLINE} eval exec ${CMDLINE} From be7ad261d553412b58a27189c19db11cdb3b76cb Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 15 Feb 2013 13:53:13 +0100 Subject: [PATCH 9/9] Probe various candidates for system release info Not all Linux distributions is LSB-compliant, notably RHEL 6, so we should make an effort to check various known other files in order to identify the distribution. --- cmake/Modules/UseSystemInfo.cmake | 47 ++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 10 deletions(-) diff --git a/cmake/Modules/UseSystemInfo.cmake b/cmake/Modules/UseSystemInfo.cmake index aa90b1b9..c0db9c1f 100644 --- a/cmake/Modules/UseSystemInfo.cmake +++ b/cmake/Modules/UseSystemInfo.cmake @@ -3,21 +3,48 @@ function (system_info) message (STATUS "CMake version: ${CMAKE_VERSION}") if (CMAKE_SYSTEM MATCHES "Linux") - read_lsb (ID INTO DISTRIB_ID) - read_lsb (RELEASE INTO DISTRIB_RELEASE) - read_lsb (CODENAME INTO DISTRIB_CODENAME) - message (STATUS "Linux distribution: ${DISTRIB_ID} \"${DISTRIB_CODENAME}\" ${DISTRIB_RELEASE}") + distro_name (DISTRO_NAME) + message (STATUS "Linux distribution: ${DISTRO_NAME}") else (CMAKE_SYSTEM MATCHES "Linux") message (STATUS "Operating system: ${CMAKE_SYSTEM}") endif (CMAKE_SYSTEM MATCHES "Linux") endfunction (system_info) -# read property from LSB information -function (read_lsb suffix INTO varname) - file (STRINGS /etc/lsb-release _distrib - REGEX "^DISTRIB_${suffix}=" +# probe various system files that may be found +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) + # start with /etc/os-release, + # see + if (NOT has_os_release STREQUAL "") + read_release (PRETTY_NAME FROM /etc/os-release INTO _descr) + # previous "standard", used on older Ubuntu and Debian + elseif (NOT has_lsb_release STREQUAL "") + read_release (DISTRIB_DESCRIPTION FROM /etc/lsb-release INTO _descr) + # RHEL/CentOS etc. has just a text-file + elseif (NOT has_sys_release STREQUAL "") + file (READ /etc/system-release _descr) + else (NOT has_lsb_release STREQUAL "") + # no yet known release file found + set (_descr "unknown") + endif (NOT has_os_release STREQUAL "") + # return from function (into appropriate variable) + string (STRIP "${_descr}" _descr) + set (${varname} "${_descr}" PARENT_SCOPE) +endfunction (distro_name varname) + +# read property from the newer /etc/os-release +function (read_release valuename FROM filename INTO varname) + file (STRINGS ${filename} _distrib + REGEX "^${valuename}=" ) string (REGEX REPLACE - "^DISTRIB_${suffix}=\(.*\)" "\\1" ${varname} ${_distrib}) + "^${valuename}=\"?\(.*\)" "\\1" ${varname} ${_distrib} + ) + # remove trailing quote that got globbed by the wildcard (greedy match) + string (REGEX REPLACE + "\"$" "" ${varname} "${${varname}}" + ) set (${varname} "${${varname}}" PARENT_SCOPE) -endfunction (read_lsb suffix INTO varname) +endfunction (read_release valuename FROM filename INTO varname)