Merge pull request #287 from rolk/286_info
Read project settings from dune.module
This commit is contained in:
commit
054b764224
@ -1,19 +1,33 @@
|
||||
# -*- 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:
|
||||
|
||||
###########################################################################
|
||||
# #
|
||||
# Note: The bulk of the build system is located in the cmake/ directory. #
|
||||
# This file only contains the specializations for this particular #
|
||||
# project. Most likely you are interested in editing one of these #
|
||||
# files instead: #
|
||||
# #
|
||||
# dune.module Name and version number #
|
||||
# CMakeLists_files.cmake Path of source files #
|
||||
# cmake/Modules/${project}-prereqs.cmake Dependencies #
|
||||
# #
|
||||
###########################################################################
|
||||
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
# key information about the library
|
||||
set (project "opm-core")
|
||||
set (${project}_NAME "${project}")
|
||||
set (${project}_DESCRIPTION "Open Porous Media Initiative Core Library")
|
||||
set (${project}_DIR "opm")
|
||||
set (${project}_VERSION_MAJOR 1)
|
||||
set (${project}_VERSION_MINOR 0)
|
||||
set (doxy_dir "Documentation")
|
||||
|
||||
# additional search modules
|
||||
set (${project}_MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||
list (APPEND CMAKE_MODULE_PATH ${${project}_MODULE_DIR})
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||
|
||||
# not the same location as most of the other projects; this hook overrides
|
||||
macro (dir_hook)
|
||||
set (doxy_dir "Documentation")
|
||||
endmacro (dir_hook)
|
||||
|
||||
# project information is in dune.module. Read this file and set variables.
|
||||
# we cannot generate dune.module since it is read by dunecontrol before
|
||||
# the build starts, so it makes sense to keep the data there then.
|
||||
include (OpmInit)
|
||||
|
||||
# list of prerequisites for this particular project; this is in a
|
||||
# separate file (in cmake/Modules sub-directory) because it is shared
|
||||
|
59
cmake/Modules/OpmInit.cmake
Normal file
59
cmake/Modules/OpmInit.cmake
Normal file
@ -0,0 +1,59 @@
|
||||
# - Initialize project-specific variables
|
||||
#
|
||||
# This will read the dune.module file for project information and
|
||||
# set the following variables:
|
||||
#
|
||||
# project From the Module: field
|
||||
# ${project}_NAME Same as above
|
||||
# ${project}_DESCRIPTION From the Description: field
|
||||
# ${project}_VERSION_MAJOR From the Version: field
|
||||
# ${project}_VERSION_MINOR From the Version: field also
|
||||
#
|
||||
# This module should be the first to be included in the project,
|
||||
# because most of the others (OpmXxx.cmake) use these variables.
|
||||
|
||||
# helper macro to retrieve a single field of a dune.module file
|
||||
macro(OpmGetDuneModuleDirective field variable contents)
|
||||
string (REGEX MATCH ".*${field}:[ ]*([^\n]+).*" ${variable} "${contents}")
|
||||
string (REGEX REPLACE ".*${field}:[ ]*([^\n]+).*" "\\1" "${variable}" "${${variable}}")
|
||||
string (STRIP "${${variable}}" ${variable})
|
||||
endmacro()
|
||||
|
||||
function (OpmInitProjVars)
|
||||
# locate the "dune.module" file
|
||||
set (DUNE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/dune.module")
|
||||
|
||||
# read this file into a variable
|
||||
file (READ "${DUNE_MODULE_PATH}" DUNE_MODULE)
|
||||
|
||||
# read fields from the file
|
||||
OpmGetDuneModuleDirective ("Module" project "${DUNE_MODULE}")
|
||||
OpmGetDuneModuleDirective ("Description" description "${DUNE_MODULE}")
|
||||
OpmGetDuneModuleDirective ("Version" version "${DUNE_MODULE}")
|
||||
|
||||
# parse the version number
|
||||
set (verno_regex "^([0-9]*)\\.([0-9]*).*\$")
|
||||
string (REGEX REPLACE "${verno_regex}" "\\1" major "${version}")
|
||||
string (REGEX REPLACE "${verno_regex}" "\\2" minor "${version}")
|
||||
|
||||
# return these variables
|
||||
set (project "${project}" PARENT_SCOPE)
|
||||
set (${project}_NAME "${project}" PARENT_SCOPE)
|
||||
set (${project}_DESCRIPTION "${description}" PARENT_SCOPE)
|
||||
set (${project}_VERSION_MAJOR "${major}" PARENT_SCOPE)
|
||||
set (${project}_VERSION_MINOR "${minor}" PARENT_SCOPE)
|
||||
endfunction ()
|
||||
|
||||
macro (OpmInitDirVars)
|
||||
# these are the most common (and desired locations)
|
||||
set (${project}_DIR "opm")
|
||||
set (doxy_dir "doc/doxygen")
|
||||
|
||||
# but for backward compatibility we can override it
|
||||
if (COMMAND dir_hook)
|
||||
dir_hook ()
|
||||
endif (COMMAND dir_hook)
|
||||
endmacro ()
|
||||
|
||||
OpmInitProjVars ()
|
||||
OpmInitDirVars ()
|
@ -17,17 +17,17 @@
|
||||
# include special
|
||||
if (CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
message (STATUS "Enabling compatibility modules for CMake 2.8.3")
|
||||
list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.3")
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.3")
|
||||
endif (CMAKE_VERSION VERSION_LESS "2.8.3")
|
||||
|
||||
if (CMAKE_VERSION VERSION_LESS "2.8.5")
|
||||
message (STATUS "Enabling compatibility modules for CMake 2.8.5")
|
||||
list (APPEND CMAKE_MODULE_PATH "${${project}_MODULE_DIR}/compat-2.8.5")
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.5")
|
||||
endif (CMAKE_VERSION VERSION_LESS "2.8.5")
|
||||
|
||||
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")
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.7")
|
||||
endif (CMAKE_VERSION VERSION_LESS "2.8.7")
|
||||
|
||||
# don't write default flags into the cache, preserve that for user set values
|
||||
|
@ -1,4 +1,5 @@
|
||||
Module: opm-core
|
||||
Description: Open Porous Media Initiative Core Library
|
||||
Version: 1.0
|
||||
Maintainer: atgeirr@sintef.no
|
||||
Depends: dune-common (>= 2.2) dune-istl (>= 2.2)
|
||||
|
Loading…
Reference in New Issue
Block a user