Commit Graph

2621 Commits

Author SHA1 Message Date
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
Roland Kaufmann
a1141b56f7 Add define for SuperLU later than 2005
This is a prerequisite for using the find module, but some code
explicitly check this macro anyway.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
779b02dda2 Search module for SuperLU library
Original downloaded from:
  <https://svn.dune-project.org/svn/dune-istl/branches/cmake/cmake/modules/FindSuperLU.cmake>

Renamed to all capitals in name so that the name of the package is
consistent with the variables it returns.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
f5c9f97c83 Link with UMFPACK in SuiteSparse if available 2013-02-11 22:36:48 +01:00
Roland Kaufmann
751c721c55 Probe for SuiteSparse libraries
Search for modules in this library in the same style as Boost; by
specifying a list of components. If all on the list is present, then
a list of libraries to link with, is returned.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
5876ab7f30 Check for dynamic linking of Boost::Test library
BOOST_TEST_DYN_LINK must be defined if you are *building* Boost::Test as
a shared object, and the client programs must also include this option
when they use the header files, to link to it correctly.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
370b8580d1 Link with C++ Boost library 2013-02-11 22:36:48 +01:00
Roland Kaufmann
21c4194b7c Link against XML parser library 2013-02-11 22:36:48 +01:00
Roland Kaufmann
b47d0de4c6 Link against BLAS+LAPACK numerical libraries
The tests for these packages are part of the standard CMake installation
so there is no config modules for them here.
2013-02-11 22:36:48 +01:00
Roland Kaufmann
1af93bd757 Use generic boilerplate macro to include packages 2013-02-11 22:36:47 +01:00