From 9f411d6179535e2744faf024c41fd4f2666d971a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 24 Sep 2013 15:24:48 +0200 Subject: [PATCH 01/21] Revert " Use MultiArch-unaware path for dune.module" This reverts commit 512d49c41a73189871d0c69c5a9616f89236db03. --- cmake/Modules/OpmInstall.cmake | 5 +---- cmake/Modules/UseDuneVer.cmake | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/cmake/Modules/OpmInstall.cmake b/cmake/Modules/OpmInstall.cmake index 17f4a1179..59435249d 100644 --- a/cmake/Modules/OpmInstall.cmake +++ b/cmake/Modules/OpmInstall.cmake @@ -8,7 +8,6 @@ # _TARGET CMake target which builds the library # _LIBRARY_TYPE Static or shared library # _DEBUG File containing debug symbols -include (UseMultiArch) macro (opm_install opm) foreach (_hdr IN LISTS ${opm}_HEADERS) @@ -49,10 +48,8 @@ macro (opm_install opm) DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR} ) endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG) - # note that the DUNE parts that looks for dune.module is currently (2013-09) not - # multiarch-aware and will thus put in lib64/ on RHEL and lib/ on Debian install ( FILES ${PROJECT_SOURCE_DIR}/dune.module - DESTINATION ${LIBDIR_MULTIARCH_UNAWARE}${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} + DESTINATION lib${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} ) endmacro (opm_install opm) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index c2cd4c410..116de6ce9 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -72,7 +72,7 @@ function (find_dune_version suite module) # 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}/${LIBDIR_MULTIARCH_UNAWARE}${_multilib}/dunecontrol/${suite}-${module}/dune.module") + 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 "") From 7d86ae545370c52b8171b3406039c30e52372c15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?B=C3=A5rd=20Skaflestad?= Date: Tue, 24 Sep 2013 15:24:58 +0200 Subject: [PATCH 02/21] Revert " Add special variable for MultiArch-unaware components" This reverts commit 1cadc5af6d1074b8cd053db464924fb08e5a0ad7. --- cmake/Modules/UseMultiArch.cmake | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/cmake/Modules/UseMultiArch.cmake b/cmake/Modules/UseMultiArch.cmake index dfba736e2..f1a5d665a 100644 --- a/cmake/Modules/UseMultiArch.cmake +++ b/cmake/Modules/UseMultiArch.cmake @@ -8,11 +8,8 @@ # Note that it will override the results of GNUInstallDirs if included after # that module. -# default if we need to put something in the library directory for a -# component that is *not* multiarch-aware -set (LIBDIR_MULTIARCH_UNAWARE "lib") - -# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu +# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu; +# Fedora put module files in lib64/ too, but Debian uses lib/ for that if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") # Debian or Ubuntu? if (EXISTS "/etc/debian_version") @@ -22,7 +19,6 @@ if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") # 64-bit system? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_def "lib64") - set (LIBDIR_MULTIARCH_UNAWARE "${_libdir_def}") else (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_def "lib") endif (CMAKE_SIZEOF_VOID_P EQUAL 8) From 23499b7616740bfd6a1ff827b34fad13eec780ad Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Mon, 2 Sep 2013 18:03:05 +0200 Subject: [PATCH 03/21] Extracts the full compiler path and feeds it to cmake. Previously, specifying the compiler name with a variable to configure ("configure CC=gcc") lead to CMake complaining that /$CC was not a valid path. This patch fixes this by extracting the full path with "which ". Should fix issue #355. --- cmake/Scripts/configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 4d5710103..d04580c90 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -453,11 +453,11 @@ for a in "${VARS[@]}"; do ;; CC=*) # special processing for compiler options - a=${a#CC=} + a=`which ${a#CC=}` c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\"" ;; CXX=*) - a=${a#CXX=} + a=`which ${a#CXX=}` cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\"" ;; CFLAGS=*) @@ -469,7 +469,7 @@ for a in "${VARS[@]}"; do cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\"" ;; FC=*) - a=${a#FC=} + a=`which ${a#FC=}` fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\"" ;; FFLAGS=*) From 3db8443c8c44ada3b70984aad21e7e89c0e01481 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 5 Sep 2013 12:42:40 +0200 Subject: [PATCH 04/21] substituted which with command -v. --- cmake/Scripts/configure | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index d04580c90..c0ef819a8 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -453,11 +453,11 @@ for a in "${VARS[@]}"; do ;; CC=*) # special processing for compiler options - a=`which ${a#CC=}` + a=$(command -v ${a#CC=}) c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\"" ;; CXX=*) - a=`which ${a#CXX=}` + a=$(command -v ${a#CXX=}) cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\"" ;; CFLAGS=*) @@ -469,7 +469,7 @@ for a in "${VARS[@]}"; do cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\"" ;; FC=*) - a=`which ${a#FC=}` + a=$(command -v ${a#FC=}) fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\"" ;; FFLAGS=*) From efc7fab49c5a3360cf1355822ac749249ecf31d5 Mon Sep 17 00:00:00 2001 From: Markus Blatt Date: Thu, 5 Sep 2013 12:49:57 +0200 Subject: [PATCH 05/21] Change which test for cmake28 to use command -v. --- cmake/Scripts/configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index c0ef819a8..21acc02a5 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -145,7 +145,7 @@ VARS=() # command that launches cmake; look for 2.8 if available if [ "${CMAKE_COMMAND}" = "" ]; then - if which cmake28 >/dev/null 2>&1; then + if test -n "$(command -v cmake28)"; then CMAKE_COMMAND=cmake28 else CMAKE_COMMAND=cmake From a41b5e140ef1cbb92c998b7f77c9b35e4e0b0175 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 10 Sep 2013 08:55:25 +0200 Subject: [PATCH 06/21] Test for executable and preserve erroneous path for messages If an alternate compiler is specified, then check if this is actually executable before assigning it so that we don't end up with specifying an empty name to CMake. If the path does not exist, it will be preserved so that CMake will complain with an easily identifiable error message. --- cmake/Scripts/configure | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/cmake/Scripts/configure b/cmake/Scripts/configure index 21acc02a5..cd1f4ed49 100755 --- a/cmake/Scripts/configure +++ b/cmake/Scripts/configure @@ -145,7 +145,7 @@ VARS=() # command that launches cmake; look for 2.8 if available if [ "${CMAKE_COMMAND}" = "" ]; then - if test -n "$(command -v cmake28)"; then + if [ -x "$(command -v cmake28)" ]; then CMAKE_COMMAND=cmake28 else CMAKE_COMMAND=cmake @@ -453,11 +453,13 @@ for a in "${VARS[@]}"; do ;; CC=*) # special processing for compiler options - a=$(command -v ${a#CC=}) + a=${a#CC=} + [ -x "$(command -v $a)" ] && a=$(command -v "$a") c_compiler=" -DCMAKE_C_COMPILER=\"${a/\"/\\\"}\"" ;; CXX=*) - a=$(command -v ${a#CXX=}) + a=${a#CXX=} + [ -x "$(command -v $a)" ] && a=$(command -v "$a") cxx_compiler=" -DCMAKE_CXX_COMPILER=\"${a/\"/\\\"}\"" ;; CFLAGS=*) @@ -469,7 +471,8 @@ for a in "${VARS[@]}"; do cxx_opts=" -DCMAKE_CXX_FLAGS=\"${a/\"/\\\"}\"" ;; FC=*) - a=$(command -v ${a#FC=}) + a=${a#FC=} + [ -x "$(command -v $a)" ] && a=$(command -v "$a") fort_compiler=" -DCMAKE_Fortran_COMPILER=\"${a/\"/\\\"}\"" ;; FFLAGS=*) From 90723230b0530472834316f70318f75c565bd673 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 11 Sep 2013 22:49:00 +0200 Subject: [PATCH 07/21] Detect OS version when running on RHEL/CentOS 5.x These versions only have /etc/redhat-release, not any of the newer files. --- cmake/Modules/UseSystemInfo.cmake | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cmake/Modules/UseSystemInfo.cmake b/cmake/Modules/UseSystemInfo.cmake index 0de83a64c..b4b3f8af8 100644 --- a/cmake/Modules/UseSystemInfo.cmake +++ b/cmake/Modules/UseSystemInfo.cmake @@ -39,6 +39,7 @@ 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) + file (GLOB has_redhat_release /etc/redhat-release) set (_descr) # start with /etc/os-release, # see @@ -52,6 +53,8 @@ function (distro_name varname) if (NOT _descr) if (NOT has_sys_release STREQUAL "") file (READ /etc/system-release _descr) + elseif (NOT has_redhat_release STREQUAL "") + file (READ /etc/redhat-release _descr) else (NOT has_sys_release STREQUAL "") # no yet known release file found set (_descr "unknown") From 39a98783afad910bcf4d8224c47e61e4c57cd8f5 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 12 Sep 2013 09:36:19 +0200 Subject: [PATCH 08/21] Test variables instead of contents If you test the contents of a variable, this is not necessarily true in CMake (since the contents here is a path, and not a variable name; the default test is "does this variable exist", not "is this a non- empty string" like in shell script) --- cmake/Modules/FindSuiteSparse.cmake | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index 779973752..6d34664d8 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -87,10 +87,10 @@ if (NOT $ENV{SuiteSparse_DIR} STREQUAL "") set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}") set (_no_default_path "NO_DEFAULT_PATH") endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "") -if (${SuiteSparse_DIR}) +if (SuiteSparse_DIR) set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}") set (_no_default_path "NO_DEFAULT_PATH") -endif (${SuiteSparse_DIR}) +endif (SuiteSparse_DIR) # CMake uses _DIR suffix as default for config-mode files; it is unlikely # that we are building SuiteSparse ourselves; use _ROOT suffix to specify # location to pre-canned binaries @@ -98,10 +98,10 @@ if (NOT $ENV{SuiteSparse_ROOT} STREQUAL "") set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_ROOT}") set (_no_default_path "NO_DEFAULT_PATH") endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "") -if (${SuiteSparse_ROOT}) +if (SuiteSparse_ROOT) set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}") set (_no_default_path "NO_DEFAULT_PATH") -endif (${SuiteSparse_ROOT}) +endif (SuiteSparse_ROOT) # transitive closure of dependencies; after this SuiteSparse_MODULES is the # full list of modules that must be found to satisfy the user's link demands From d00cff8549cc34527ff23fe9d3519f805b68ecd0 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 12 Sep 2013 09:38:25 +0200 Subject: [PATCH 09/21] Don't set a default search path; use CMake's default If we set a default search path ourself, then this will be used if we specify a SuiteSparse_ROOT with error! Instead, we should just leave our SuiteSparse_SEARCH_PATH variable empty and then let CMake fill in its defaults. If there is a directory specified on the other hand (indicating that we want exactly that location), only use that and turn all the default paths completely off. --- cmake/Modules/FindSuiteSparse.cmake | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index 6d34664d8..a232635ee 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -72,37 +72,36 @@ endif (NOT LAPACK_FOUND) find_library (MATH_LIBRARY NAMES "m") set (SuiteSparse_EXTRA_LIBS ${LAPACK_LIBRARIES} ${BLAS_LIBRARIES} ${MATH_LIBRARY}) -# search paths for the library outside of standard system paths. these are the -# paths in which the package managers on various distros put the files -list (APPEND SuiteSparse_SEARCH_PATH "/usr") # Linux -list (APPEND SuiteSparse_SEARCH_PATH "/opt/local") # MacOS X - # if we don't get any further clues about where to look, then start # roaming around the system set (_no_default_path "") +# search system directories by default +set (SuiteSparse_SEARCH_PATH) + # pick up paths from the environment if specified there; these replace the # pre-defined paths so that we don't accidentially pick up old stuff if (NOT $ENV{SuiteSparse_DIR} STREQUAL "") set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_DIR}") - set (_no_default_path "NO_DEFAULT_PATH") endif (NOT $ENV{SuiteSparse_DIR} STREQUAL "") if (SuiteSparse_DIR) set (SuiteSparse_SEARCH_PATH "${SuiteSparse_DIR}") - set (_no_default_path "NO_DEFAULT_PATH") endif (SuiteSparse_DIR) # CMake uses _DIR suffix as default for config-mode files; it is unlikely # that we are building SuiteSparse ourselves; use _ROOT suffix to specify # location to pre-canned binaries if (NOT $ENV{SuiteSparse_ROOT} STREQUAL "") set (SuiteSparse_SEARCH_PATH "$ENV{SuiteSparse_ROOT}") - set (_no_default_path "NO_DEFAULT_PATH") endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "") if (SuiteSparse_ROOT) set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}") - set (_no_default_path "NO_DEFAULT_PATH") endif (SuiteSparse_ROOT) +# if we have specified a search path, then confine ourselves to that +if (SuiteSparse_SEARCH_PATH) + set (_no_default_path "NO_DEFAULT_PATH") +endif (SuiteSparse_SEARCH_PATH) + # transitive closure of dependencies; after this SuiteSparse_MODULES is the # full list of modules that must be found to satisfy the user's link demands set (SuiteSparse_MODULES ${SuiteSparse_FIND_COMPONENTS}) From d11a8bc5ac7cb93f91ade5a832320b684be14963 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Thu, 12 Sep 2013 09:40:17 +0200 Subject: [PATCH 10/21] Allow use of uppercase version of the _ROOT var The convention is to use uppercase names, in particular our own ./configure script uses this, so we should at least allow it here (in addition to the old way for backward compatibility) --- cmake/Modules/FindSuiteSparse.cmake | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/cmake/Modules/FindSuiteSparse.cmake b/cmake/Modules/FindSuiteSparse.cmake index a232635ee..7b6dd183f 100644 --- a/cmake/Modules/FindSuiteSparse.cmake +++ b/cmake/Modules/FindSuiteSparse.cmake @@ -96,6 +96,10 @@ endif (NOT $ENV{SuiteSparse_ROOT} STREQUAL "") if (SuiteSparse_ROOT) set (SuiteSparse_SEARCH_PATH "${SuiteSparse_ROOT}") endif (SuiteSparse_ROOT) +# most commonly, we use the uppercase version of this variable +if (SUITESPARSE_ROOT) + set (SuiteSparse_SEARCH_PATH "${SUITESPARSE_ROOT}") +endif (SUITESPARSE_ROOT) # if we have specified a search path, then confine ourselves to that if (SuiteSparse_SEARCH_PATH) From fd34cde5ad135443623afcc1156ea40d5df02c4e Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 17 Sep 2013 23:05:52 +0200 Subject: [PATCH 11/21] Add special variable for MultiArch-unaware components Some components are not yet MultiArch-aware and installs to either lib/ (Debian) or lib64/ (RHEL) on 64-bit platforms. If we need to interface with these components, then it is nice to have such a variable set together with the regular detection code. --- cmake/Modules/UseMultiArch.cmake | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/UseMultiArch.cmake b/cmake/Modules/UseMultiArch.cmake index f1a5d665a..87f0a76e9 100644 --- a/cmake/Modules/UseMultiArch.cmake +++ b/cmake/Modules/UseMultiArch.cmake @@ -8,17 +8,20 @@ # Note that it will override the results of GNUInstallDirs if included after # that module. -# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu; -# Fedora put module files in lib64/ too, but Debian uses lib/ for that +# default if we need to put something in the library directory for a +# component that is *not* multiarch-aware +set (LIBDIR_MULTIARCH_UNAWARE "lib") + +# Fedora uses lib64/ for 64-bit systems, Debian uses lib/x86_64-linux-gnu if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") # Debian or Ubuntu? if (EXISTS "/etc/debian_version") set (_libdir_def "lib/${CMAKE_LIBRARY_ARCHITECTURE}") - set (_libdir_noarch "lib") else (EXISTS "/etc/debian_version") # 64-bit system? if (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_def "lib64") + set (LIBDIR_MULTIARCH_UNAWARE "${_libdir_def}") else (CMAKE_SIZEOF_VOID_P EQUAL 8) set (_libdir_def "lib") endif (CMAKE_SIZEOF_VOID_P EQUAL 8) From 94e6b266425ce38931a609a2ed4e5e42287b933b Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 17 Sep 2013 23:24:59 +0200 Subject: [PATCH 12/21] Use MultiArch-unaware path for dune.module As of 2013-09 the DUNE code that reads dune.module is not MultiArch- aware. Thus, for a 64-bit platform it will look in lib/ on Debian and lib64/ on RHEL. --- cmake/Modules/OpmInstall.cmake | 5 ++++- cmake/Modules/UseDuneVer.cmake | 7 ++++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/OpmInstall.cmake b/cmake/Modules/OpmInstall.cmake index 59435249d..17f4a1179 100644 --- a/cmake/Modules/OpmInstall.cmake +++ b/cmake/Modules/OpmInstall.cmake @@ -8,6 +8,7 @@ # _TARGET CMake target which builds the library # _LIBRARY_TYPE Static or shared library # _DEBUG File containing debug symbols +include (UseMultiArch) macro (opm_install opm) foreach (_hdr IN LISTS ${opm}_HEADERS) @@ -48,8 +49,10 @@ macro (opm_install opm) DESTINATION ${_dbg_prefix}${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_LIBDIR}${${opm}_VER_DIR} ) endif (${opm}_LIBRARY_TYPE STREQUAL "SHARED" AND ${opm}_TARGET AND ${opm}_DEBUG) + # note that the DUNE parts that looks for dune.module is currently (2013-09) not + # multiarch-aware and will thus put in lib64/ on RHEL and lib/ on Debian install ( FILES ${PROJECT_SOURCE_DIR}/dune.module - DESTINATION lib${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} + DESTINATION ${LIBDIR_MULTIARCH_UNAWARE}${${opm}_VER_DIR}/dunecontrol/${${opm}_NAME} ) endmacro (opm_install opm) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index 116de6ce9..93e3674f6 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -41,6 +41,11 @@ function (find_dune_version suite module) # some modules does not have a library, use the directory of the # header files to find what would be the library dir. + # note that when we refer to a build tree, then the libraries always + # go into lib/, but we don't care about that because in that case, + # dune.module isn't in the lib/ directory anyway but must be retrieved + # from the source. hence, we only have to worry about the library + # directory of a system installation here. if (NOT ${suite}-${module}_LIBRARY) # this suffix is gotten from UseMultiArch.cmake set (_lib_path "${_inc_path}/${CMAKE_INSTALL_LIBDIR}") @@ -72,7 +77,7 @@ function (find_dune_version suite module) # 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") + set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_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 "") From 66907b7c42b0733bffa38b9951042bbaa3542b30 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 18 Sep 2013 14:35:30 +0200 Subject: [PATCH 13/21] Improve troubleshooting for missing dune.module If the library is found, but dune.module is not, we really should give an error because the #ifdefs in the code will not work as intended. Print the locations where we expect the library to appear to the console for better tracking. --- cmake/Modules/UseDuneVer.cmake | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index 93e3674f6..16fe658ca 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -56,6 +56,7 @@ function (find_dune_version suite module) # if we have a source tree, dune.module is available there set (_dune_mod "${_inc_path}/dune.module") if (NOT EXISTS "${_dune_mod}") + set (_last_dune_mod_src "${_dune_mod}") set (_dune_mod "") endif () @@ -80,6 +81,7 @@ function (find_dune_version suite module) set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_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 (_last_dune_mod_bld "${_dune_mod}") set (_dune_mod "") endif () endif () @@ -87,8 +89,8 @@ 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 (NOT _dune_mod) - if (${suite}-${module}_FIND_REQUIRED) - message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module}") + if (${suite}-${module}_FOUND) + message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module} (looking for either \"${_last_dune_mod_src}\" or \"${_last_dune_mod_bld}\")") else () return () endif () From 93bfbecb3ba0f75ab5b35feb2dd9e6643ae67e10 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 18 Sep 2013 14:44:49 +0200 Subject: [PATCH 14/21] Improve detection of dune.module Remove lib/.libs/ and lib64/ as well as lib/ to find the prefix for the installation root. --- cmake/Modules/UseDuneVer.cmake | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index 16fe658ca..ac972be52 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -64,13 +64,19 @@ function (find_dune_version suite module) # look for the build tree; if we found the library, then the # dune.module file should be in a sub-directory get_filename_component (_immediate "${_lib_path}" NAME) + if ("${_immediate}" STREQUAL ".libs") + # remove autotools internal path + get_filename_component (_lib_path "${_lib_path}" PATH) + endif () + get_filename_component (_immediate "${_lib_path}" NAME) if ("${_immediate}" STREQUAL "${CMAKE_LIBRARY_ARCHITECTURE}") # remove multi-arch part of the library path to get parent get_filename_component (_lib_path "${_lib_path}" PATH) endif () get_filename_component (_immediate "${_lib_path}" NAME) if (("${_immediate}" STREQUAL "${CMAKE_INSTALL_LIBDIR}") - OR ("${_immediate}" STREQUAL "lib")) + OR ("${_immediate}" STREQUAL "lib") + OR ("${_immediate}" STREQUAL "${LIBDIR_MULTIARCH_UNAWARE}")) # 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) From b6c5d3572db13d74930f1e044816db57dd3ff84f Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Tue, 17 Sep 2013 21:46:07 +0200 Subject: [PATCH 15/21] Update the CMake cache to reflect current settings During configuration some of the values for CMake properties (compiler flags etc.) may be changed either by the user (through command line parameters or option files), or by the configuration script itself (setting more aggressive options or detailed debugging for instance). This change writes many of the relevant values back into the cache so they are available for introspection (using e.g. ccmake) or when the rerunning the configuration without specifying all options. --- cmake/Modules/OpmDefaults.cmake | 37 +++++++++++++++++++++++++++++++++ cmake/Modules/OpmLibMain.cmake | 3 +++ 2 files changed, 40 insertions(+) diff --git a/cmake/Modules/OpmDefaults.cmake b/cmake/Modules/OpmDefaults.cmake index 2a9af878d..b3158d6cc 100644 --- a/cmake/Modules/OpmDefaults.cmake +++ b/cmake/Modules/OpmDefaults.cmake @@ -60,3 +60,40 @@ macro (opm_defaults opm) set (Boost_NO_BOOST_CMAKE ON) endif (NOT BOOST_ROOT) endmacro (opm_defaults opm) + +# overwrite a cache entry's value, but keep docstring and type +# if not already in cache, then does nothing +function (update_cache name) + get_property (_help CACHE "${name}" PROPERTY HELPSTRING) + get_property (_type CACHE "${name}" PROPERTY TYPE) + if (NOT "${_type}" STREQUAL "") + #message ("Setting ${name} to \"${${name}}\" in cache.") + set ("${name}" "${${name}}" CACHE ${_type} "${_help}" FORCE) + endif () +endfunction (update_cache name) + +# put all compiler options currently set back into the cache, so that +# they can be queried from there (using ccmake for instance) +function (write_back_options) + # build type + update_cache (CMAKE_BUILD_TYPE) + + # compilers + set (languages C CXX Fortran) + foreach (language IN LISTS _languages) + if (CMAKE_${language}_COMPILER) + update_cache (CMAKE_${language}_COMPILER) + endif () + endforeach (language) + + # flags (notice use of IN LISTS to get the empty variant) + set (buildtypes "" "_DEBUG" "_RELEASE" "_MINSIZEREL" "_RELWITHDEBINFO") + set (processors "C" "CXX" "Fortran" "EXE_LINKER" "MODULE_LINKER" "SHARED_LINKER") + foreach (processor IN LISTS processors) + foreach (buildtype IN LISTS buildtypes) + if (CMAKE_${processor}_FLAGS${buildtype}) + update_cache (CMAKE_${processor}_FLAGS${buildtype}) + endif () + endforeach (buildtype) + endforeach (processor) +endfunction (write_back_options) diff --git a/cmake/Modules/OpmLibMain.cmake b/cmake/Modules/OpmLibMain.cmake index 22dc0bc94..535cd5ff5 100644 --- a/cmake/Modules/OpmLibMain.cmake +++ b/cmake/Modules/OpmLibMain.cmake @@ -269,3 +269,6 @@ configure_file ( # make sure updated version information is available in the source code include (UseVersion) + +# update the cache for next run +write_back_options () From b13f9d251ba6889e8c563b9a14a9d495ae0b545f Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 18 Sep 2013 13:11:03 +0200 Subject: [PATCH 16/21] Fix logic bug and make language explicit The operator precedence in CMake can be surprising, so add parenthesis to make in unambigious. Also, make it more explicit from which language we get the default options. (They are all set from the settings given for C++; why would have different optimization options for C and C++?) --- cmake/Modules/AddOptions.cmake | 23 +++++++++++++---------- cmake/Modules/UseDebugSymbols.cmake | 2 +- cmake/Modules/UseOptimization.cmake | 4 ++-- cmake/Modules/UseWarnings.cmake | 2 +- 4 files changed, 17 insertions(+), 14 deletions(-) diff --git a/cmake/Modules/AddOptions.cmake b/cmake/Modules/AddOptions.cmake index 0ebb82366..56c623269 100644 --- a/cmake/Modules/AddOptions.cmake +++ b/cmake/Modules/AddOptions.cmake @@ -61,18 +61,21 @@ function (add_options langs builds) endfunction (add_options lang build) # set varname to flag unless user has specified something that matches regex -function (set_default_option varname flag regex) - if (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") +function (set_default_option lang varname flag regex) + # lang is either C, CXX or Fortran + if ("${lang}" STREQUAL "Fortran") + set (letter "F") + else () + set (letter "${lang}") + endif () + string (TOUPPER "${CMAKE_BUILD_TYPE}" _build) + if ((NOT ("$ENV{${letter}FLAGS}" MATCHES "${regex}")) + AND (NOT ("${CMAKE_${lang}_FLAGS}" MATCHES "${regex}")) + AND (NOT ("${CMAKE_${lang}_FLAGS_${_build}}" MATCHES "${regex}"))) set (${varname} ${flag} PARENT_SCOPE) - else (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") + else () set (${varname} PARENT_SCOPE) - endif (NOT "$ENV{CXXFLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS}" MATCHES "${regex}" - AND NOT "${CMAKE_CXX_FLAGS_${CMAKE_BUILD_TYPE}}" MATCHES "${regex}") + endif () endfunction (set_default_option) # note: this must be called before project() diff --git a/cmake/Modules/UseDebugSymbols.cmake b/cmake/Modules/UseDebugSymbols.cmake index e902e055a..23e9c50f3 100644 --- a/cmake/Modules/UseDebugSymbols.cmake +++ b/cmake/Modules/UseDebugSymbols.cmake @@ -16,7 +16,7 @@ is_compiler_gcc_compatible () # only debugging using the GNU toolchain is supported for now if (CXX_COMPAT_GCC) # default debug level, if not specified by the user - set_default_option (_dbg_flag "-ggdb3" "(^|\ )-g") + set_default_option (CXX _dbg_flag "-ggdb3" "(^|\ )-g") # add debug symbols to *all* targets, regardless. there WILL come a # time when you need to find a bug which only manifests itself in a diff --git a/cmake/Modules/UseOptimization.cmake b/cmake/Modules/UseOptimization.cmake index ce831a589..22f6672cc 100644 --- a/cmake/Modules/UseOptimization.cmake +++ b/cmake/Modules/UseOptimization.cmake @@ -37,8 +37,8 @@ if (CXX_COMPAT_GCC) endif (WITH_NATIVE) # default optimization flags, if not set by user - set_default_option (_opt_dbg "-O0" "(^|\ )-O") - set_default_option (_opt_rel "-O3" "(^|\ )-O") + set_default_option (CXX _opt_dbg "-O0" "(^|\ )-O") + set_default_option (CXX _opt_rel "-O3" "(^|\ )-O") # use these options for debug builds - no optimizations add_options (ALL_LANGUAGES "${_prof_DEBUG}" ${_opt_dbg} "-DDEBUG") diff --git a/cmake/Modules/UseWarnings.cmake b/cmake/Modules/UseWarnings.cmake index 2b340229a..8e42423d6 100644 --- a/cmake/Modules/UseWarnings.cmake +++ b/cmake/Modules/UseWarnings.cmake @@ -6,7 +6,7 @@ is_compiler_gcc_compatible () if (CXX_COMPAT_GCC) # default warnings flags, if not set by user - set_default_option (_warn_flag "-Wall" "(^|\ )-W") + set_default_option (CXX _warn_flag "-Wall" "(^|\ )-W") if (_warn_flag) message (STATUS "All warnings enabled: ${_warn_flag}") add_options (ALL_LANGUAGES ALL_BUILDS "${_warn_flag}") From c4b5cdedadc3c3ae1f35ea4457f059af137eb21a Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 18 Sep 2013 13:44:23 +0200 Subject: [PATCH 17/21] Clear default flags in an (im)proper way The CMAKE_NOT_USING_CONFIG_FLAGS option is really only settable by a user that doesn't want _DEBUG or _RELEASE flags to not have effect. If we want other flags than the platform default, we must do hairy things like clearing them from the cache (overriding the user's seletion if it was the same as the platform default). --- cmake/Modules/AddOptions.cmake | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/cmake/Modules/AddOptions.cmake b/cmake/Modules/AddOptions.cmake index 56c623269..19f02966f 100644 --- a/cmake/Modules/AddOptions.cmake +++ b/cmake/Modules/AddOptions.cmake @@ -78,8 +78,20 @@ function (set_default_option lang varname flag regex) endif () endfunction (set_default_option) -# note: this must be called before project() +# clear default options as a proxy for not using any default options +# at all. there is one *huge* problem with this: CMake runs the platform +# initialization before executing any line at all in the project and +# there seems to be no way to disable that behaviour, so we cannot really +# distinguish between a platform default and something that the user has +# passed on the command line. the best thing we can do is to all user- +# defined setting if they are something other than the platform default. macro (no_default_options) - # prevent the platform probe to set options - set (CMAKE_NOT_USING_CONFIG_FLAGS TRUE) + foreach (lang IN ITEMS C CXX Fortran) + foreach (build IN ITEMS DEBUG RELEASE MINSIZEREL RELWITHDEBINFO) + if ("${CMAKE_${lang}_FLAGS_${build}}" STREQUAL "${CMAKE_${lang}_FLAGS_${build}_INIT}") + # for some strange reason we cannot clear this flag, only set it to empty + set (CMAKE_${lang}_FLAGS_${build} "") + endif () + endforeach (build) + endforeach (lang) endmacro (no_default_options) From 48a7dc58b346567c5a2e34adcda2781ad1b2b798 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Wed, 18 Sep 2013 14:04:18 +0200 Subject: [PATCH 18/21] Honor the CMAKE_NOT_USING_CONFIG_FLAGS settings If this is set, then everything is lumped into CMAKE_CXX_FLAGS since that is the only one that is going to be used when building anyway. --- cmake/Modules/AddOptions.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/cmake/Modules/AddOptions.cmake b/cmake/Modules/AddOptions.cmake index 19f02966f..3255d90c4 100644 --- a/cmake/Modules/AddOptions.cmake +++ b/cmake/Modules/AddOptions.cmake @@ -37,6 +37,11 @@ function (add_options langs builds) else (NOT ("${build}" STREQUAL "ALL_BUILDS")) set (_bld "") endif (NOT ("${build}" STREQUAL "ALL_BUILDS")) + # if we want everything in the "global" flag, then simply + # ignore the build type here and go add everything to that one + if (CMAKE_NOT_USING_CONFIG_FLAGS) + set (_bld "") + endif () foreach (_opt IN LISTS ARGN) set (_var "CMAKE_${lang}_FLAGS${_bld}") #message (STATUS "Adding \"${_opt}\" to \${${_var}}") From 9b2cf047e5b8a7443a3d52d6aed6137169068684 Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 20 Sep 2013 13:17:38 +0200 Subject: [PATCH 19/21] Search for dune.module in private installations When doing a private install of DUNE libraries, the dune.module file is put in the lib/ directory, regardless of architecture. This patch searches the lib/ directory as a catch-all after having searched the platform-specific directories. This should minimize the chance of hitting an accidentally unrelated dune.module. --- cmake/Modules/UseDuneVer.cmake | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/cmake/Modules/UseDuneVer.cmake b/cmake/Modules/UseDuneVer.cmake index ac972be52..98e53994d 100644 --- a/cmake/Modules/UseDuneVer.cmake +++ b/cmake/Modules/UseDuneVer.cmake @@ -84,11 +84,22 @@ function (find_dune_version suite module) # 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}/${LIBDIR_MULTIARCH_UNAWARE}${_multilib}/dunecontrol/${suite}-${module}/dune.module") + set (_suffix "${_multilib}/dunecontrol/${suite}-${module}/dune.module") + set (_dune_mod "${_lib_path}/${LIBDIR_MULTIARCH_UNAWARE}${_suffix}") if (NOT EXISTS "${_dune_mod}") - # use the name itself as a flag for whether it was found or not set (_last_dune_mod_bld "${_dune_mod}") - set (_dune_mod "") + # one more try, if we have a private install, then it doesn't use + # e.g. lib64 but always lib (!) + if ("${LIBDIR_MULTIARCH_UNAWARE}" STREQUAL "lib") + set (_dune_mod "") + else () + set (_dune_mod "${_lib_path}/lib${_suffix}") + if (NOT EXISTS "${_dune_mod}") + set (_last_dune_mod_pri "${_dune_mod}") + # use the name itself as a flag for whether it was found or not + set (_dune_mod "") + endif () + endif () endif () endif () @@ -96,7 +107,14 @@ function (find_dune_version suite module) # code later, so we bail out early if (NOT _dune_mod) if (${suite}-${module}_FOUND) - message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module} (looking for either \"${_last_dune_mod_src}\" or \"${_last_dune_mod_bld}\")") + set (_searched_paths "\"${_last_dune_mod_src}\"") + if (NOT ("${_last_dune_mod_bld}" STREQUAL "")) + set (_searched_paths "either ${_searched_paths} or \"${_last_dune_mod_bld}\"") + endif () + if (NOT ("${_last_dune_mod_pri}" STREQUAL "")) + set (_searched_paths "${_searched_paths} or \"${_last_dune_mod_pri}\"") + endif () + message (FATAL_ERROR "Failed to locate dune.module for ${suite}-${module} (looking for ${_searched_paths})") else () return () endif () From 4e3d76a090ab768ac1de872d61aef23689651dfc Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Mon, 23 Sep 2013 15:46:53 +0200 Subject: [PATCH 20/21] add opm-core to the ewoms prerequisites --- cmake/Modules/ewoms-prereqs.cmake | 1 + 1 file changed, 1 insertion(+) diff --git a/cmake/Modules/ewoms-prereqs.cmake b/cmake/Modules/ewoms-prereqs.cmake index c61015c07..6fc39b669 100644 --- a/cmake/Modules/ewoms-prereqs.cmake +++ b/cmake/Modules/ewoms-prereqs.cmake @@ -17,6 +17,7 @@ set (ewoms_DEPS "dune-geometry REQUIRED" "dune-grid REQUIRED" "dune-istl REQUIRED" + "opm-core REQUIRED" "opm-material REQUIRED" # valgrind client requests "Valgrind" From cf38685acdfac6677502fe7ce741605ab486a01f Mon Sep 17 00:00:00 2001 From: Andreas Lauser Date: Fri, 20 Sep 2013 15:09:30 +0200 Subject: [PATCH 21/21] remove the dune-istl from the list of opm-material prerequisites the only reason dune-istl was required was that the spline class used ISTL's tridiagonal matrix. Since the spline class moved into the core (along with a more capable tridiagonal matrix), ISTL is no longer required by opm-material. --- cmake/Modules/opm-material-prereqs.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/cmake/Modules/opm-material-prereqs.cmake b/cmake/Modules/opm-material-prereqs.cmake index 8355d644e..7dd8b15a7 100644 --- a/cmake/Modules/opm-material-prereqs.cmake +++ b/cmake/Modules/opm-material-prereqs.cmake @@ -17,5 +17,4 @@ set (opm-material_DEPS "opm-core REQUIRED" # DUNE dependency "dune-common REQUIRED" - "dune-istl REQUIRED" )