OPM/opm-core — pull request #565 by andlaus (2014-04-08 19:21:59+00:00)
Title: Build system fixes for LAPACK

Recently my build failed because of errors like

```
[...]
Linking CXX executable bin/test_linearsolver
/usr/bin/cmake -E cmake_link_script CMakeFiles/test_linearsolver.dir/link.txt --verbose=1
/usr/bin/g++-4.9 -Wall -Wno-cast-align -fno-strict-aliasing -fstrict-overflow -g -DDEBUG=1 -pipe -Wno-unknown-pragmas -std=c++11 -O0 -DDEBUG -Wl,--as-needed -Wl,--enable-new-dtags CMakeFiles/test_linearsolver.dir/tests/test_linearsolver.cpp.o -o bin/test_linearsolver -rdynamic lib/libopmcore.a -lumfpack -lcholmod -lamd -lcolamd -lcamd -lsuitesparseconfig -lrt /home/and/ctest/gcc-49/src/ert/install/lib64/libecl.so /home/and/ctest/gcc-49/src/ert/install/lib64/libert_geometry.so /home/and/ctest/gcc-49/src/ert/install/lib64/libert_util.so -lz /home/and/ctest/gcc-49/src/dune-common/lib/.libs/libdunecommon.a -llapack /usr/lib64/mpi/gcc/openmpi/lib64/libmpi_cxx.so /usr/lib64/mpi/gcc/openmpi/lib64/libmpi.so /home/and/ctest/gcc-49/external/SuperLU_4.3/lib/libsuperlu_4.3.a -lblas /home/and/ctest/gcc-49/src/opm-parser/lib64/libParser.a /home/and/ctest/gcc-49/src/opm-parser/lib64/libopm-json.a /home/and/ctest/gcc-49/src/opm-parser/lib64/libcjson.a -lm -lboost_date_time-mt -lboost_filesystem-mt -lboost_system-mt -lboost_iostreams-mt -lboost_unit_test_framework-mt -Wl,-rpath,/home/and/ctest/gcc-49/src/ert/install/lib64:/usr/lib64/mpi/gcc/openmpi/lib64
/usr/lib64/gcc/x86_64-suse-linux/4.9/../../../../lib64/libcholmod.so: undefined reference to `dpotrf_'
[...]
```

strangly enough, these only appear if optimizations are enabled on GCC
4.8.2, while on GCC 4.9 they appear in all configurations.

The errors seemed to be caused by an incorrect library ordering for
LAPACK, which in turn is caused by Finddune-common.cmake. This module
checks for LAPACK which causes the library to be added too end of the
library list. Since, to my knowledge, LAPACK is _not_ required
required by dune-common, this patch "fixes" the issue by just removing
LAPACK from the prerequisites of dune-common. It also changes
FindERT.cmake such that the module first checks whether BLAS and
LAPACK have been previously found and only if not, it tries to find
them itself...