Merge pull request #320 from rolk/320_build
Put in hooks to change build directory later
This commit is contained in:
@@ -17,7 +17,13 @@
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
# additional search modules
|
||||
list (APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules")
|
||||
find_path (OPM_MACROS_ROOT cmake/Modules/OpmInit.cmake
|
||||
PATHS ${opm-macros_ROOT}
|
||||
${CMAKE_CURRENT_SOURCE_DIR}
|
||||
DOC "Path to build system macros and scripts"
|
||||
NO_DEFAULT_PATH
|
||||
)
|
||||
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/cmake/Modules")
|
||||
|
||||
# not the same location as most of the other projects; this hook overrides
|
||||
macro (dir_hook)
|
||||
@@ -98,5 +104,13 @@ macro (tests_hook)
|
||||
cond_disable_test ("ERT")
|
||||
endmacro (tests_hook)
|
||||
|
||||
macro (install_hook)
|
||||
# # copy the cmake macros to system when installing
|
||||
# install (
|
||||
# DIRECTORY cmake
|
||||
# DESTINATION share/opm
|
||||
# )
|
||||
endmacro (install_hook)
|
||||
|
||||
# all setup common to the OPM library modules is done here
|
||||
include (OpmLibMain)
|
||||
|
||||
@@ -17,7 +17,7 @@ if (CMAKE_GENERATOR MATCHES "Unix Makefiles")
|
||||
# amazingly, nothing depends on the generated Makefile, so this can be
|
||||
# run whenever in the build without trigging a compile of e.g. config.h
|
||||
add_custom_target (dune-compat ALL
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY} -P ${PROJECT_SOURCE_DIR}/cmake/Scripts/DuneCompat2.cmake
|
||||
COMMAND ${CMAKE_COMMAND} -DCMAKE_HOME_DIRECTORY=${CMAKE_HOME_DIRECTORY} -P ${OPM_MACROS_ROOT}/cmake/Scripts/DuneCompat2.cmake
|
||||
COMMENT "Patching Makefile to be DUNE compatible"
|
||||
)
|
||||
endif (CMAKE_GENERATOR MATCHES "Unix Makefiles")
|
||||
|
||||
@@ -141,7 +141,7 @@ function (configure_la name target)
|
||||
# assume that we are in cmake/Modules, and that the template have been
|
||||
# put in cmake/Templates. we cannot use CMAKE_CURRENT_LIST_DIR because
|
||||
# this is in a function, and we cannot know who's calling us
|
||||
set (templ_dir "${PROJECT_SOURCE_DIR}/cmake/Templates")
|
||||
set (templ_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
|
||||
# only write an .la if libtool is found; otherwise we have no use
|
||||
|
||||
@@ -68,7 +68,7 @@ macro (opm_dist_clean opm)
|
||||
)
|
||||
endif (NOT PROJECT_SOURCE_DIR STREQUAL PROJECT_BINARY_DIR)
|
||||
# script to remove empty directories (can't believe this isn't included!)
|
||||
set (rmdir "${PROJECT_SOURCE_DIR}/cmake/Scripts/RemoveEmptyDir.cmake")
|
||||
set (rmdir "${OPM_MACROS_ROOT}/cmake/Scripts/RemoveEmptyDir.cmake")
|
||||
add_custom_target (distclean
|
||||
COMMAND ${CMAKE_COMMAND} --build ${PROJECT_BINARY_DIR} -- clean
|
||||
COMMAND ${CMAKE_COMMAND} -E remove -f ${DISTCLEAN_FILES}
|
||||
|
||||
@@ -13,7 +13,7 @@
|
||||
|
||||
macro (opm_doc opm doxy_dir)
|
||||
# combine the template with local customization
|
||||
file (READ ${PROJECT_SOURCE_DIR}/cmake/Templates/Doxyfile _doxy_templ)
|
||||
file (READ ${OPM_MACROS_ROOT}/cmake/Templates/Doxyfile _doxy_templ)
|
||||
string (REPLACE ";" "\\;" _doxy_templ "${_doxy_templ}")
|
||||
if (EXISTS ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal)
|
||||
file (READ ${PROJECT_SOURCE_DIR}/${doxy_dir}/Doxylocal _doxy_local)
|
||||
|
||||
@@ -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 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.3")
|
||||
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/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 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.5")
|
||||
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/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 "${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules/compat-2.8.7")
|
||||
list (APPEND CMAKE_MODULE_PATH "${OPM_MACROS_ROOT}/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
|
||||
@@ -179,6 +179,9 @@ opm_compile (${project})
|
||||
# installation target: copy the library together with debug and
|
||||
# configuration files to system directories
|
||||
include (OpmInstall)
|
||||
if (COMMAND install_hook)
|
||||
install_hook ()
|
||||
endif (COMMAND install_hook)
|
||||
opm_install (${project})
|
||||
message (STATUS "This build defaults to installing in ${CMAKE_INSTALL_PREFIX}")
|
||||
|
||||
|
||||
@@ -70,7 +70,7 @@ function (opm_cmake_config name)
|
||||
# assume that the template is located in cmake/Templates (cannot use
|
||||
# the current directory since this is in a function and the directory
|
||||
# at runtime not at definition will be used
|
||||
set (template_dir "${PROJECT_SOURCE_DIR}/cmake/Templates")
|
||||
set (template_dir "${OPM_MACROS_ROOT}/cmake/Templates")
|
||||
|
||||
# write configuration file to locate library
|
||||
configure_cmake_file (${name} "config" "")
|
||||
|
||||
@@ -39,7 +39,7 @@ else ()
|
||||
-DPROJECT_SOURCE_DIR=${PROJECT_SOURCE_DIR}
|
||||
-DPROJECT_BINARY_DIR=${PROJECT_BINARY_DIR}
|
||||
-DPROJECT_LABEL=${${project}_LABEL}
|
||||
-P ${PROJECT_SOURCE_DIR}/cmake/Scripts/WriteVerSHA.cmake
|
||||
-P ${OPM_MACROS_ROOT}/cmake/Scripts/WriteVerSHA.cmake
|
||||
COMMENT "Updating version information"
|
||||
)
|
||||
|
||||
|
||||
7
cmake/Scripts/configure
vendored
7
cmake/Scripts/configure
vendored
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
# where is the source tree located
|
||||
# where is the source tree located by default relative to here
|
||||
srcdir=$(dirname $(dirname $(dirname "$0")))
|
||||
|
||||
# display help text
|
||||
@@ -141,6 +141,11 @@ for OPT in "$@"; do
|
||||
OPTARG=${OPT#--}
|
||||
# OPTARG now contains everything after double dashes
|
||||
case "${OPTARG}" in
|
||||
src-dir=*)
|
||||
# allow the user to use these build macros for another
|
||||
# project (so source-dir is not relative to us)
|
||||
srcdir=${OPTARG#*=}
|
||||
;;
|
||||
prefix=*)
|
||||
# remove prefix consisting of everything up to equal sign
|
||||
prefix=${OPTARG#*=}
|
||||
|
||||
34
configure
vendored
34
configure
vendored
@@ -1,3 +1,35 @@
|
||||
#!/bin/sh
|
||||
# this file is supposed to be located in the source directory
|
||||
src_dir=$(dirname $0)
|
||||
|
||||
# scan the arguments and set this if build macros could be specified
|
||||
mod_dir=
|
||||
for OPT in "$@"; do
|
||||
case "$OPT" in
|
||||
--with-opm-macros=*)
|
||||
# remove everything before equal sign and assign the rest
|
||||
mod_dir=${OPT#*=}
|
||||
# tilde expansion; note that doing eval may have side effects
|
||||
mod_dir=$(eval echo $mod_dir)
|
||||
# absolute path
|
||||
[ -d "$mod_dir" ] && mod_dir=$(cd $mod_dir ; pwd)
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# if it isn't specified, the look around in other known places
|
||||
conf_file=cmake/Scripts/configure
|
||||
if [ -z "$mod_dir" ]; then
|
||||
if [ -r "$src_dir/$conf_file" ]; then
|
||||
mod_dir="$src_dir"
|
||||
fi
|
||||
fi
|
||||
|
||||
# terminate with error message here if the module directory is not found
|
||||
if [ ! -r "$mod_dir/$conf_file" ]; then
|
||||
echo Build macros not located in \"$mod_dir\", use --with-opm-macros= to specify! 1>&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# forward to the corresponding script in the cmake/Scripts/ directory
|
||||
exec $(dirname $0)/cmake/Scripts/configure "$@"
|
||||
exec "$mod_dir/$conf_file" --src-dir="$src_dir" "$@"
|
||||
|
||||
Reference in New Issue
Block a user