Commit Graph

3052 Commits

Author SHA1 Message Date
Roland Kaufmann
c28aa9b9c3 Provide user-friendly front-end for efficient builds
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
02a9e13d75 Compile and link Algebraic Multigrid, if available
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
590a963e43 Provide FC_FUNC macro like AC_FC_WRAPPERS in Autotools
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
c387e04069 Don't expand variables for test
Use only expansion when comparing the variable against a literal, not
when comparing for logical true or if defined.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
7976b95983 Use native instruction set on build system
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
31fae50628 Probe for optimization flags before using them 2013-02-11 22:37:55 +01:00
Roland Kaufmann
9bd3f186d2 Do list cleanup in find routine
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).
2013-02-11 22:37:55 +01:00
Roland Kaufmann
2fc5a6349e Probe for C99 standard available
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
0e88d99c50 Write version file so user can specify lower bound
With the version file present, a user program can depend on a certain
version of the library.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
9942dcc8d9 Install config mode CMake module at installation
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
e7d9abcd8e Allow directory to be set for config mode CMake files
If you run CMake with -Dfoo_DIR= pointing to a build tree, it should
now pick up the correct config mode module from there.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
944eaf43cc C++11 is only recommended, not required
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.
2013-02-11 22:37:55 +01:00
Roland Kaufmann
fc3941d982 Add compiler options that may make the builds faster
Sometimes compiler options can help doing faster builds; for GCC the
pipe option will help interleave the various stages of the build.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
0b4a244a44 Compatibility script for Autotools addicts
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.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
34138223e8 Install the library and headers
Enables running `make && make install` on a target system. Documentation
is not yet built or installed.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
a4ea84cd89 Sources are named after library, not project
All targets in the project uses variables defined on a "project" basis
whereas only a specific target uses variables named after it.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
d79c2d2fed Rename version variables 2013-02-11 22:37:54 +01:00
Roland Kaufmann
8cf610e53a Remove superfluous definitions 2013-02-11 22:37:54 +01:00
Roland Kaufmann
2d3ed1cc27 Write snapshot of probes to config-mode module
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!
2013-02-11 22:37:54 +01:00
Roland Kaufmann
8234959abe Write config variables in either C++ or CMake syntax
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.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
8fddb7a879 Allow even empty lists of config vars
Modules that does not use the concept of _CONFIG_VARS will not have
exported anything, so we may end up with an empty list.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
e62f4a1b69 Separate defines for this library from those of deps
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.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
10d033698d Get linker flags from pkg-config if specified 2013-02-11 22:37:54 +01:00
Roland Kaufmann
3045092436 Specify dependencies as one list, including args
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.
2013-02-11 22:37:54 +01:00
Roland Kaufmann
ccb85102e8 Use declarative list of dependencies instead of functions 2013-02-11 22:37:54 +01:00
Roland Kaufmann
00b3f9431d Provide functions to find packages in batch
Dependencies can now be declared as a list and passed amongst modules
since CMake does not (easily) support passing anonymous functions.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
0deeef0127 Rename macro modules
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
88d635524c Search in Autotools variant of library directories too 2013-02-11 22:37:53 +01:00
Roland Kaufmann
275097ae34 Only add found libraries to test compilations
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
78bb77d863 Only add to -std option to C++ flags
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
507c122395 Also search include/ subdirectory for header files
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
834163707d Provide find module to search for opm-core library
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
607231b9e0 Add found variables to another library's
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
5f84bf718b Add library search directories to linker options
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.
2013-02-11 22:37:53 +01:00
Roland Kaufmann
42df5fdbd3 Config-mode CMake file
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).
2013-02-11 22:37:50 +01:00
Roland Kaufmann
871f6e90f1 Debug build by default
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
2013-02-11 22:36:49 +01:00
Roland Kaufmann
bc8a6a0027 Enable all warnings 2013-02-11 22:36:49 +01:00
Roland Kaufmann
f1111c73bb Turn on all warnings when compiling
Things that the compiler doesn't like is a source of bugs, so we strive
to compile with a full level of warning reporting.
2013-02-11 22:36:49 +01:00
Roland Kaufmann
8e9325659a Enable optimization 2013-02-11 22:36:49 +01:00
Roland Kaufmann
bed3921212 Turn on optimization flags based on build type 2013-02-11 22:36:49 +01:00
Roland Kaufmann
6c37e94056 Enable debugging support 2013-02-11 22:36:49 +01:00
Roland Kaufmann
f5c82a00b1 Compile with debug symbols and strip afterwards
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.
2013-02-11 22:36:49 +01:00
Roland Kaufmann
0443b80cfc Include configuration file without directory spec.
If the program is built out-of-source-tree then the configuration file
(which is generated and not part of the source) will not be available
relative to the source code file.
2013-02-11 22:36:49 +01:00
Roland Kaufmann
d37e7740bd Remove test when the feature is not available 2013-02-11 22:36:49 +01:00
Roland Kaufmann
6aae2aeda4 Compile programs in the tests/ directory 2013-02-11 22:36:49 +01:00
Roland Kaufmann
2a653ab51a Link with DUNE if available 2013-02-11 22:36:48 +01:00
Roland Kaufmann
b057f4ccea Probe for DUNE libraries
Search for known headers and library files that indicates that DUNE is
available on the system, and setup compiler and linker variables.

Unfortunately, this module has hard-coded some knowledge of the
dependencies on other modules, and knowledge of which symbols that
should be defined. This information must be revised whenever a new
version of DUNE is released, because it is hard and error-prone to
infer this automatically.

As for the name of the modules, see the comment by mblatt at 2012-05-22
in the thread about CMake evaluation in the DUNE user forum:
<http://www.dune-project.org/flyspray/index.php?do=details&task_id=1000>
2013-02-11 22:36:48 +01:00
Roland Kaufmann
b435e1994e Link with SuperLU if available 2013-02-11 22:36:48 +01:00
Roland Kaufmann
5d54f2728b Include all necessary information to link in standard variables
Users shouldn't be required to add anything that the standard variables
in their own CMakeLists.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
85a8ef5ead Provide binary value for HAVE_SUPERLU 2013-02-11 22:36:48 +01:00