Commit Graph

526 Commits

Author SHA1 Message Date
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
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
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
4dd3f9ec96 Append standard variables to project after finding package
Normally a package returns a set of standard variables such as
Xxx_INCLUDE_DIRS. Adding this to a list that is collected for the
project amounts to a bunch of boilerplate which can rather be
encapsulated in a macro.
2013-02-11 22:36:47 +01:00
Roland Kaufmann
644fc9f5cf Don't repeat option if already present 2013-02-11 22:36:47 +01:00
Roland Kaufmann
a4cf98055d Add options without repeating them on the command-line 2013-02-11 22:36:47 +01:00
Roland Kaufmann
9a1b24c621 Compile with C++0x/11 if available
We want to compile with the -std=c++0x since DUNE uses this settings and
we need to use the same ABI as that one if we are going to link with it.

Find module is a copy of the one in cmake/modules in (the cmake branch of)
dune-common.
2013-02-11 22:36:47 +01:00
Roland Kaufmann
eee961a527 Define function to write a list of variables to config.h
A fundamental problem with the configure_file() command is CMake is that
the author of the template file config.h.in must know which variables
all modules need to have defined, and this is not easily communicated.

The idea behind this function is: Each Find-module can return a list of
variables that it has filled with probed values, and that should be
written to config.h, which is again included by the header file of this
module.

Each project thus defines its own config.h file, which is common between
all module's headers.
2013-02-11 22:36:47 +01:00