From 8cbfaa3c14c443e03b06370bc9f72b1f62f31abd Mon Sep 17 00:00:00 2001 From: Roland Kaufmann Date: Fri, 24 Jan 2014 12:48:58 +0100 Subject: [PATCH] Create aliases for probed variables Headers from other libraries (notably DUNE) require definitions of other variables than our probe process set (e.g. HAVE_UMFPACK instead of HAVE_SUITESPARSE_UMFPACK_H). This module sets those aliases for compatibility. --- cmake/Modules/OpmAliases.cmake | 24 ++++++++++++++++++++++++ cmake/Modules/OpmLibMain.cmake | 3 +++ cmake/OPM-CMake.md | 6 ++++++ 3 files changed, 33 insertions(+) create mode 100644 cmake/Modules/OpmAliases.cmake diff --git a/cmake/Modules/OpmAliases.cmake b/cmake/Modules/OpmAliases.cmake new file mode 100644 index 000000000..06292137a --- /dev/null +++ b/cmake/Modules/OpmAliases.cmake @@ -0,0 +1,24 @@ +# - Alias probed variables for compatibility with DUNE buildsystem +# +# DUNE build system sets some variables which have different names +# in the CMake modules we are using; this module set those variable +# so they can be exported to config.h visible to DUNE headers + +function (set_aliases) + # hardcoded list of "dune-var opm-var" pairs, where the components + # are separated by space + set (aliases + ) + foreach (alias IN LISTS aliases) + # convert entry "X Y" into a list "X;Y", then pick apart + string (REGEX REPLACE "\ +" ";" tuple "${alias}") + list (GET tuple 0 var) + list (GET tuple 1 name) + + # write this alias to cache + set (${var} ${${name}} PARENT_SCOPE) + endforeach (alias) +endfunction (set_aliases) + +# always call this when the module is imported +set_aliases () diff --git a/cmake/Modules/OpmLibMain.cmake b/cmake/Modules/OpmLibMain.cmake index 535cd5ff5..7aef0322f 100644 --- a/cmake/Modules/OpmLibMain.cmake +++ b/cmake/Modules/OpmLibMain.cmake @@ -89,6 +89,9 @@ endif (COMMAND prereqs_hook) include (OpmFind) find_and_append_package_list_to (${project} ${${project}_DEPS}) +# set aliases to probed variables +include (OpmAliases) + # remove the dependency on the testing framework from the main library; # it is not possible to query for Boost twice with different components. list (REMOVE_ITEM "${project}_LIBRARIES" "${Boost_UNIT_TEST_FRAMEWORK_LIBRARY}") diff --git a/cmake/OPM-CMake.md b/cmake/OPM-CMake.md index 18a69e3d2..c1f015d51 100644 --- a/cmake/OPM-CMake.md +++ b/cmake/OPM-CMake.md @@ -423,6 +423,12 @@ Wrapper script which emulates an autotools front-end, making the build system usable with dunecontrol. There is one in the project root directory which just forwards everything to the main script in `cmake/Scripts`. + + OpmAliases + +Copy variables which are probed by our find modules to the names which +are expected by DUNE. + OpmCompile