If we write a blank value into the cache, we tell CMake that ERT isn't
found and it won't check again. If we delete it from the cache in case
we didn't find the directories, then CMake will run the find module
again the next time we configure. Just probing for directories is cheap
so this is no problem. This allows us to install ERT, do a reconfigure
and it will then be picked up by the build system.
If we find ERT and it doesn't compile properly, a blank value will still
be written, and it won't try again the next time, so you must wipe the
cache if you *upgrade* ERT into a newer and more compatible version.
If the user has given a path to the module, then the system paths should
not be searched, as these may contain an old and outdated version. We
don't necessarily want that just because there was a problem with our
own installation!
If we are on a 64-bits machine, there is no point in searching lib32
and conversely. Quite the opposite, it can only end badly if a library
is actually found in the wrong architecture directory.
Instead of checking every pre-requisite and then determine if the
library is functional, quickly check if the library directories are
present, and if not bail out. The most common reason that ERT is
not usuable, is that it is installed, not that something else is
missing!
If the files for ERT is not found, then the find module cheats and
indicates that it didn't compile either (since there are some later
tests for HAVE_ERT).
However, erraneously, it gave this variable the value 0, which tests
for false in the CMake code but not in the #ifdef checks in the C++
code. This error is cancelled in opm-core by the fact that it didn't
store it as a cache variable, but resurfaced in opm-polymer when it
probes the second time (as both opm-core as a dependency and
opm-polymer itself declare a dependency on ERT).
It is now stored in a way that should be satisfactory to both
projects.
There were (at least) three implementations of the same macro; these
have been collected into a separate helper module. (Note that this
means that FindERT is now not completely stand-alone anymore).
The source code of ERT is located in a devel/ subdirectory, but it is
not usual (?) to have this structure in a separate build directory as
well. If you however build everything in the same directory as the
source code, then this sub-directory needs to be accounted for.
Although ERT is built with CMake, it does not yet provide a config-mode
module in its build directory. This also means that the find module must
be pointed to an installation, not a build directory.