Infer the type of library from the target and only activate debug symbol
stripping if it is an executable format. Note that this changes the
signature of the strip_debug_symbols macro.
CMake will change to the source directory when processing the
CMakeLists.txt file which causes relative paths to be based on this
instead of at the build directory which is probably assumed by the
user.
Instead of having to run `ccmake` or looking up which variables that
must be set, the configure driver is now enhanced to recognize options
that sets the installation directories for some of the dependencies.
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.
If one sets the variable foo_DIR it will cause CMake to look for a
configuration file in that directory. In case we want to set the root
directory to an installation which doesn't have a config-mode CMake
module, and use the find module provided by ourself, we need a separate
variable that can hold the location of this directory and the most
common suffix for this seems to be _ROOT (an alternative is _PREFIX)
QtCreator stores a file containing amongst other things the path to where
your build tree is and what parameters you used for the configuration
process. These data is user-specific and should not be stored in version
control.
If you open the project in QtCreator again after having made changes
to CMakeLists.txt outside of it, it may create a new user file which
should be ignored just like the original.
We call the Make utility passing the right number of cores to do
efficient parallel compilation. The command to do this is simple,
but laborious to type every time. Add one to the number of nodes
to keep the CPU busy while one is waiting for I/O.
Put the entire compilation at a lower priority, both CPU and I/O-
wise. This way we don't kill the computer and the user can continue
working with other interactive tasks. If there are no other jobs,
then it will complete as before.
By having a front-end for the compilation, we can later switch to
the Ninja generator without disturbing the workflow.
If the path to Notay's AGMG library is provided through the cache
variable AGMG_ROOT, then include this in the build and enable the
test.
It would have been desirable to use the variable name AGMG_DIR for
consistency with the other modules, but unfortunately this name
will alter the functionality of CMake's find_package.
CMake has a similar set of macros to FC_FUNC, but they of course use
another name. It also blatantly writes these macros to its own file,
overwriting anything else there (!).
This wrapper provides the same FC_FUNC interface as Autotools would
do, thus requiring no source changes.
CMake files are in general not portable between systems anyway, so we
may as well take full advantage of the native instruction set.
There must be a companion option to switch this off in case anyone
wants to build a package for distribution.
Although this amounts to some double work, it doesn't make the
configuration noticeably slower, and it ensures that the lists are
always cleaned up (in a proper way).
Similar to the -std=c++0x flag for C++ code, we probe for, and add if
available, -std=c99 for C code, since the compiler may generate
different initialization code for this variant.
The reporting from the bundled CMake modules is not as polished as for
probing for C++ flags, but not bad enough to warrant rewriting the code
from scratch just to fix the output.
find_package only searches for FindXxx-modules in the path specified by
CMAKE_MODULE_PATH; other paths are supposed to contain config-mode
modules (much like pkgconfig).
Generate the config-mode module in the installation directory using the
same template as is used for the one in the build directory, only
selectively swapping some directories in the relevant variables.
If we don't have a C++11 compiler, we won't be able to build DUNE, but
opm-core is still usable with for instance UMFPACK. However, if it *is*
available, it should be used to improve the ABI compatibility with other
parts of the suite.
This script enables the use of `configure && make && make install` for
those users who have this combination ingrained in their fingers or are
too busy to read the manual.
Put everything the user needs to link to the opm-core library into the
config-mode file, including result of probes. If this conflicts with
other packages, that is a configuration issue that must be resolved
anyway.
The advantage of doing it like this is that the user can build against
the library without knowing how it was configured; the only thing that
must be provided is the path to the config-mode module!
We need the list of variables to put in config.h for the CMake config-
mode module; reuse the code that writes the list to config.h in the
first place to also write CMake-compatible lines.
This makes it easier to write this list to the config-mode module and
let it merge with those from dependencies in the user's program
(although that implies that we no longer pretend that inconsistencies
are not possible).
The convention that singular form contains values for this project
alone whereas plural form contains values for both this project and
dependencies, is used.
Allow arguments to be used on the list of dependencies, this facilitates
searching for things like e.g. Boost, and there is now only need for one
list since REQUIRED can be one of the arguments.
Modules that starts with the prefix "Use" alters the build to enable
something by default, whereas modules that only provide functionality
is not common to start with that prefix.
If the library is not found, we will now get a message that the test
program failed to link because of a missing symbol, instead of an error
message from CMake that we tried to add -NOTFOUND libraries.
CMAKE_REQUIRED_FLAGS is intended to be added only to the compile for the
next probe, and inside an cmake_push_check_state/cmake_pop_check_state
guard. If we add it to the main flags (CMAKE_CXX_FLAGS), it will also be
added to subsequent checks, so it suffices.
If the package is installed at system standard location (such as
/usr or /usr/local), the headers will be located in the include
subdirectory and not under the root.
This find module is provided to help user programs locate an opm-core
library installation on their system; it is not used by opm-core itself.
Note that it has a direct dependency on the UseOpmFind and UseOpmPackage
helper modules; these must be in the CMAKE_MODULE_PATH also.
Instead of adding a package's standard variables to the project, it may
be desirable to be able to specify the prefix of the variables to add
them to, so the macro find_and_append can also be used in find modules.
Some older packages, and notably those that are detected by PkgConfig,
only give library names and then a list of library search directories.
Add to link_directories here in order to support this configuration,
even though it is deprecated in newer versions of CMake.
Users should be able to point their opm-core_DIR to the build tree of
this project and have their client programs pick up all the necessary
settings to use the library. The config mode file helps to bridge
variables from one build (of opm-core) to another (of client program).
In this stage of development it is assumed that having a build that is
easy to debug from within an IDE has the most value for most users.
If any speed comparisons are to be done, be sure to configure with
-DCMAKE_BUILD_TYPE=Release
Always include debug symbols in the build, and strip them to a separate
file after compiling. The GNU debugger will automatically pick up the
external debug symbols due to a link we put in the executable.
Having debug symbols do not affect the level of optimization in the GNU
toolchain.