Commit Graph

58 Commits

Author SHA1 Message Date
Roland Kaufmann
5ed1aa37f0 Move writing of config module to library routine 2013-02-11 22:38:02 +01:00
Roland Kaufmann
5aa7def08d Search in sibling directories if no other version found
Thus, if you checkout projects in a common directory, they will find
eachother.
2013-02-11 22:38:02 +01:00
Roland Kaufmann
61cdf5c1d6 Search for libraries on multi-arch distributions 2013-02-11 22:38:02 +01:00
Roland Kaufmann
2e1f2f3ffb Search for ERT library in updated locations
ERT project has recently changed the output locations due to packaging
efforts.
2013-02-11 22:38:02 +01:00
Roland Kaufmann
a0e0535512 Module to prune unnecessary libraries from link
On Linux all libraries that are specified on the command-line will be
referred to in the resulting binary. There may be find modules which
just adds everything to satisfy every possible dependency; we want to
discard those unnecessary libraries.
2013-02-11 22:38:01 +01:00
Roland Kaufmann
dc92805d9a Safe-guard against empty directories
CMake will raise an error if you try to remove something from an
unset variable (whereas removing something from an empty list "" is
fine). If the user doesn't have the appropriate library, the search
will turn out empty, and the configuration will fail with a syntax
error instead of a message that the library is not found.
2013-02-11 22:38:01 +01:00
Roland Kaufmann
e0e1a24edd Module to precompile headers
This CMake module will set up a target for compiling a set of headers
which can then be added to compilation modules to speed up compilation.

A separate target is created because the function doesn't know all the
sources of a target, and to reuse the precompiled header across several
targets that share the same characteristics (such as unit tests).
2013-02-11 22:38:00 +01:00
Roland Kaufmann
8b4a5969c0 Return name of debug files that has been stripped
These files can then be installed on the system, too.
2013-02-11 22:38:00 +01:00
Roland Kaufmann
e46d950739 Provide backward-compatibility modules for older CMakes
BLAS module originally required Fortran to be enabled, newer module
doesn't; LAPACK module had some spelling errors that prevented it
from working; and cmake_push_check_state() is not available before
2.8.6.
2013-02-11 22:38:00 +01:00
Roland Kaufmann
6d62476eaa Make without generator expressions
These are only supported from CMake >= 2.8.4; however, we can replicate
the functionality be smartly query target properties.
2013-02-11 22:37:59 +01:00
Roland Kaufmann
c0c42ec453 Find module for TinyXML
This reuses most of the OPM infrastructure, even if it isn't an OPM
project. Thus it probably have little value outside the OPM family.
2013-02-11 22:37:59 +01:00
Roland Kaufmann
107019d22b Only clean up config variables if there actually is any 2013-02-11 22:37:59 +01:00
Roland Kaufmann
7227bbf801 Better error messages on missing items
The old version only said that _req_vars was not found; now you get to
see the actual variables that are missing.
2013-02-11 22:37:59 +01:00
Roland Kaufmann
c3f2dad1c6 Transitively make dune-common optional if dune-istl is
CMake fails if a package that was required is not found, even if the
one module finding that package was optional itself.
2013-02-11 22:37:59 +01:00
Roland Kaufmann
2c31bee5dd Support arch.-indep. libraries files for 64-bit sys.
Fedora uses lib64/ for architecture-independent files on 64-bit systems,
whereas Debian (which is multi-arch for binaries) uses lib/
2013-02-11 22:37:59 +01:00
Roland Kaufmann
aae0d2b0ad Supplement GNUInstallDirs to support multi-arch
Debian object code libraries are in directories which include the
platform name to allow several of these to co-exist. Other distros
such as Fedora uses a simpler naming scheme (e.g. "lib64/") which
is more backward-compatible.
2013-02-11 22:37:58 +01:00
Roland Kaufmann
5a14e481fb Let SuiteSparse path be specified without config mode
Use the _ROOT suffix to direct the CMake module to use a particular path
to the SuiteSparse installation without also triggering config mode (by
convention CMake uses Foo_DIR as the name of the variable which
specifies where to look for another *project*).
2013-02-11 22:37:58 +01:00
Roland Kaufmann
f4f78bf163 Don't strip debug symbols from libraries
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.
2013-02-11 22:37:56 +01:00
Roland Kaufmann
2e7e07e17d Find module for Ensemble-based Reservoir Tools (ERT)
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.
2013-02-11 22:37:56 +01:00
Roland Kaufmann
23c98fd592 Allow package dir. to be specified with _ROOT suffix
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)
2013-02-11 22:37:56 +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
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
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
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
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
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
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
bed3921212 Turn on optimization flags based on build type 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
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
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