| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | # -*- mode: cmake; tab-width: 2; indent-tabs-mode: t; truncate-lines: t; compile-command: "cmake -Wdev" -*-
 | 
					
						
							|  |  |  | # vim: set filetype=cmake autoindent tabstop=2 shiftwidth=2 noexpandtab softtabstop=2 nowrap:
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Key information about the library
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | set (project "opm-autodiff")
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | set (${project}_NAME "${project}")
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | set (${project}_DESCRIPTION "OPM module for automatic differentiation")
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | set (${project}_DIR "opm")
 | 
					
						
							|  |  |  | set (${project}_VERSION_MAJOR 1)
 | 
					
						
							|  |  |  | set (${project}_VERSION_MINOR 0)
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | set (doxy_dir "doc/doxygen")
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Defines that must be present in config.h for our headers
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | set (${project}_CONFIG_VAR | 
					
						
							|  |  |  | 	HAVE_DYNAMIC_BOOST_TEST
 | 
					
						
							|  |  |  | 	)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Prerequisites
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | set (${project}_DEPS | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | 	# Compile with C99 support if available
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 	"C99"
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | 	# Compile with C++0x/11 support if available
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 	"CXX11Features"
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | 	# Various runtime library enhancements
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 	"Boost 1.39.0
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | 		COMPONENTS system unit_test_framework REQUIRED"
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | 	# DUNE prerequisites
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | 	"dune-common REQUIRED;
 | 
					
						
							|  |  |  | 	dune-istl REQUIRED;
 | 
					
						
							|  |  |  | 	opm-core REQUIRED"
 | 
					
						
							| 
									
										
										
										
											2013-05-16 11:23:59 +02:00
										 |  |  | 	# Eigen
 | 
					
						
							| 
									
										
										
										
											2013-07-09 11:37:56 +02:00
										 |  |  | 	"Eigen3 3.1"
 | 
					
						
							| 
									
										
										
										
											2013-07-09 13:54:47 +02:00
										 |  |  | 	# Tim Davis' SuiteSparse package (UMFPACK component)
 | 
					
						
							|  |  |  | 	"SuiteSparse COMPONENTS umfpack"
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 	)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Additional search modules
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | set (${project}_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
 | 
					
						
							|  |  |  | list (APPEND CMAKE_MODULE_PATH ${${project}_MODULE_DIR})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Include special
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | if (CMAKE_VERSION VERSION_LESS "2.8.5")
 | 
					
						
							|  |  |  | 	message (STATUS "Enabling compatibility modules for CMake 2.8.5")
 | 
					
						
							| 
									
										
										
										
											2013-05-16 11:23:59 +02:00
										 |  |  | 	list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.5")
 | 
					
						
							|  |  |  | endif (CMAKE_VERSION VERSION_LESS "2.8.5")
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 
 | 
					
						
							|  |  |  | if (CMAKE_VERSION VERSION_LESS "2.8.7")
 | 
					
						
							|  |  |  | 	message (STATUS "Enabling compatibility modules for CMake 2.8.7")
 | 
					
						
							|  |  |  | 	list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.7")
 | 
					
						
							|  |  |  | endif (CMAKE_VERSION VERSION_LESS "2.8.7")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Don't write default flags into the cache, preserve that for user set values
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (AddOptions)
 | 
					
						
							|  |  |  | no_default_options ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | # C++ project
 | 
					
						
							|  |  |  | cmake_minimum_required (VERSION 2.8)
 | 
					
						
							|  |  |  | project (${${project}_NAME})
 | 
					
						
							|  |  |  | enable_language (C)
 | 
					
						
							|  |  |  | enable_language (CXX)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Print system information to better pinpoint issues from log alone
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseSystemInfo)
 | 
					
						
							|  |  |  | system_info ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Very early try to print repo id (to pinpoint version if something goes wrong)
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseVCSInfo)
 | 
					
						
							|  |  |  | vcs_info ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Print toolchain information to identify compilers with potential bugs
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseCompVer)
 | 
					
						
							|  |  |  | compiler_info ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Default settings: build static debug library
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmDefaults)
 | 
					
						
							|  |  |  | opm_defaults (${project})
 | 
					
						
							|  |  |  | message (STATUS "Build type: ${CMAKE_BUILD_TYPE}")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Use tricks to do faster builds
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseFastBuilds)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Precompiled headers
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UsePrecompHeaders)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Optimise if we're not doing a debug build
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseOptimization)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Turn on all warnings; this must be done before adding any
 | 
					
						
							|  |  |  | # prerequisites, in case they alter the list of warnings
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseWarnings)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Parallel computing must be explicitly enabled
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | option (USE_MPI "Use Message Passing Interface for parallel computing" OFF)
 | 
					
						
							|  |  |  | if (NOT USE_MPI)
 | 
					
						
							|  |  |  | 	set (CMAKE_DISABLE_FIND_PACKAGE_MPI TRUE)
 | 
					
						
							|  |  |  | endif (NOT USE_MPI)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | ### --- begin opm-autodiff specific --- ###
 | 
					
						
							|  |  |  | # Parallel programming
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseOpenMP)
 | 
					
						
							|  |  |  | find_openmp (${project})
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | ### --- end opm-autodiff specific --- ###
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Macro to set standard variables (INCLUDE_DIRS, LIBRARIES etc.)
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmFind)
 | 
					
						
							|  |  |  | find_and_append_package_list_to (${project} ${${project}_DEPS})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Remove testing framework requirement from the main library;
 | 
					
						
							|  |  |  | # It is not possible to query for Boost twice with different components.
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | list (REMOVE_ITEM ${project}_LIBRARIES ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Don't import more libraries than we need to
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseOnlyNeeded)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Put debug information into every executable
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseDebugSymbols)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Detect if Boost is in a shared library
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseDynamicBoost)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Needed for Debian installation scheme
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (UseMultiArch)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # This module contains code to figure out which files is where
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmFiles)
 | 
					
						
							|  |  |  | opm_auto_dirs ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Put libraries in lib/
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | opm_out_dirs ()
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Identify the compilation units in the library; sources in opm/,
 | 
					
						
							| 
									
										
										
										
											2013-05-15 15:49:48 +02:00
										 |  |  | # tests files in tests/, examples in examples/
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | opm_sources (${project})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Create configuration header which describes available features
 | 
					
						
							|  |  |  | # necessary to compile this library. Singular version is the names that
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | # is required by this project alone, plural version transitively
 | 
					
						
							|  |  |  | # includes the necessary defines by the dependencies
 | 
					
						
							|  |  |  | include (ConfigVars)
 | 
					
						
							|  |  |  | list (APPEND ${project}_CONFIG_VARS ${${project}_CONFIG_VAR})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Write configuration variables to this file. Note that it is a temporary.
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | message (STATUS "Writing config file \"${PROJECT_BINARY_DIR}/config.h\"...")
 | 
					
						
							|  |  |  | set (CONFIG_H "${PROJECT_BINARY_DIR}/config.h.tmp")
 | 
					
						
							|  |  |  | configure_vars ( | 
					
						
							|  |  |  | 	FILE  CXX  ${CONFIG_H}
 | 
					
						
							|  |  |  | 	WRITE ${${project}_CONFIG_VARS}
 | 
					
						
							|  |  |  | 	)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Overwrite the config.h that is used by the code only if we have some
 | 
					
						
							|  |  |  | # real changes. Thus, we don't have to recompile if a reconfigure is run
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | # due to some files being added, for instance
 | 
					
						
							|  |  |  | execute_process (COMMAND | 
					
						
							|  |  |  | 	${CMAKE_COMMAND} -E copy_if_different ${CONFIG_H} ${PROJECT_BINARY_DIR}/config.h
 | 
					
						
							|  |  |  | 	)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Compile main library; pull in all required includes and libraries
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmCompile)
 | 
					
						
							|  |  |  | opm_compile (${project})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-09 11:37:56 +02:00
										 |  |  | if (NOT EIGEN3_FOUND)
 | 
					
						
							|  |  |  | 	message(STATUS "Downloading Eigen3")
 | 
					
						
							|  |  |  | 	include(ExternalProject)
 | 
					
						
							|  |  |  | 	externalProject_Add(Eigen3 | 
					
						
							|  |  |  | 										  GIT_REPOSITORY git://github.com/OPM/eigen3
 | 
					
						
							| 
									
										
										
										
											2013-07-10 09:57:57 +02:00
										 |  |  | 											UPDATE_COMMAND git checkout 9f6cc779c101b87184076322603f496e5fdd0432
 | 
					
						
							| 
									
										
										
										
											2013-07-09 11:37:56 +02:00
										 |  |  | 											CMAKE_ARGS -DEIGEN_TEST_NO_OPENGL=1 -DEIGEN_BUILD_PKGCONFIG=0 -DCMAKE_INSTALL_PREFIX=${CMAKE_BINARY_DIR}/eigen3-installed)
 | 
					
						
							| 
									
										
										
										
											2013-07-10 09:57:57 +02:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-07-09 11:37:56 +02:00
										 |  |  | 	include_directories(${CMAKE_BINARY_DIR}/eigen3-installed/include/eigen3)
 | 
					
						
							|  |  |  | 	add_dependencies(opmautodiff Eigen3)
 | 
					
						
							|  |  |  | endif (NOT EIGEN3_FOUND)
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Installation target: copy the library together with debug and
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | # configuration files to system directories
 | 
					
						
							|  |  |  | include (OpmInstall)
 | 
					
						
							|  |  |  | opm_install (${project})
 | 
					
						
							|  |  |  | message (STATUS "This build defaults to installing in ${CMAKE_INSTALL_PREFIX}")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Installation of CMake modules to help user programs locate the library
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmProject)
 | 
					
						
							|  |  |  | opm_cmake_config (${project})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Routines to build satellites such as tests, tutorials and samples
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmSatellites)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Example programs are found in the examples/ directory
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | opm_compile_satellites (${project} examples "" "")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Infrastructure for testing
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | enable_testing ()
 | 
					
						
							|  |  |  | include (CTest)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Make datafiles necessary for tests available in output directory
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | opm_data (tests datafiles "${tests_DIR}")
 | 
					
						
							|  |  |  | opm_compile_satellites (${project} tests "" "${tests_REGEXP}")
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Use this target to run all tests
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | add_custom_target (check | 
					
						
							|  |  |  | 	COMMAND ${CMAKE_CTEST_COMMAND}
 | 
					
						
							|  |  |  | 	DEPENDS tests
 | 
					
						
							|  |  |  | 	COMMENT "Checking if library is functional"
 | 
					
						
							|  |  |  | 	VERBATIM
 | 
					
						
							|  |  |  | 	)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Generate documentation from source code with Doxygen;
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | # setup install target for this documentation
 | 
					
						
							|  |  |  | include (OpmDoc)
 | 
					
						
							|  |  |  | opm_doc (${project} ${doxy_dir})
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:32 +02:00
										 |  |  | # Provide compatibility with using this build in dunecontrol
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (DuneCompat)
 | 
					
						
							|  |  |  | include (LibtoolArchives)
 | 
					
						
							|  |  |  | configure_la (${project} ${${project}_TARGET} ${project}_LIBTOOL_ARCHIVE)
 | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2013-05-16 00:10:51 +02:00
										 |  |  | ### Clean in-source builds ###
 | 
					
						
							| 
									
										
										
										
											2013-05-15 10:40:00 +02:00
										 |  |  | include (OpmDistClean)
 | 
					
						
							|  |  |  | opm_dist_clean (${project})
 |