Skip to content
Snippets Groups Projects
Commit ab8ed6f3 authored by Markus Blatt's avatar Markus Blatt
Browse files

[Merge] Merge CMake buildsystem from branches/cmake.

One would think that this is an easy task, but it turns
out that subversion has many problems when merging back and forth
with deleted or added files. This needed a lot more manual
polishing than exspected.

[[Imported from SVN: r7441]]
parents 774f6221 6e8fb5f8
No related branches found
No related tags found
No related merge requests found
Showing
with 1584 additions and 47 deletions
Makefile
Makefile.in
config.*
config.guess
config.h.in
config.log
config.status
config.h
config.lt
config.sub
configure
configure
aclocal.m4
autom4te.cache
......@@ -19,3 +26,8 @@ ltmain.sh
.libs
dependencies.m4
dune.css
config.h.in
config.h
config.log
config.guess
# set up project
project("dune-common" C CXX)
# general stuff
cmake_minimum_required(VERSION 2.8.6)
message("CMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}|")
# make sure our own modules are found
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules")
message("CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}")
# set the script dir for the macros.
set(DUNE_COMMON_SCRIPT_DIR "${PROJECT_SOURCE_DIR}/cmake/scripts")
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
# add subdirectories to execute CMakeLists.txt there
add_subdirectory("lib")
add_subdirectory("dune")
add_subdirectory("bin")
add_subdirectory("m4")
add_subdirectory("am")
add_subdirectory("doc")
add_subdirectory("cmake/modules")
add_subdirectory("cmake/scripts")
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project()
include(CPack)
# $Id$
# we need the module file to be able to build via dunecontrol
EXTRA_DIST=dune.module
EXTRA_DIST= CMakeLists.txt dune.module dune-common-config.cmake.in dune-common-version.cmake.in
# don't follow the full GNU-standard
# we need automake 1.9 or newer
AUTOMAKE_OPTIONS = foreign 1.9
SUBDIRS = dune lib doc bin m4 am
SUBDIRS = cmake dune lib doc bin m4 am
# use configured compiler for "make distcheck"
DISTCHECK_CONFIGURE_FLAGS = CXX="$(CXX)" CC="$(CC)" --enable-parallel=@ENABLE_PARALLEL@ MPICC="$(MPICC)"
include $(top_srcdir)/am/global-rules
include $(top_srcdir)/am/top-rules
# Distribute and install config.h.cmake
configdir = $(datadir)/dune-common
dist_config_DATA = config.h.cmake
install(PROGRAMS
checklog
documentation
doxygen
global-rules
headercheck
inkscape.am
latex
no-check-without-lib
sourcescheck
top-rules
webstuff
DESTINATION ${CMAKE_INSTALL_DATADIR}/am
)
# $Id$
EXTRA_DIST = inkscape.am webstuff global-rules sourcescheck \
EXTRA_DIST = CMakeLists.txt inkscape.am webstuff global-rules sourcescheck \
no-check-without-lib latex checklog doxygen top-rules \
headercheck documentation
......
install(PROGRAMS
am2cmake.py
dunedoxynize
duneproject
dunecontrol
mpi-config
dune-autogen
DESTINATION ${CMAKE_INSTALL_BINDIR})
# $Id$
# put scripts into dist-tarball
EXTRA_DIST = duneproject dunecontrol \
EXTRA_DIST = am2cmake.py CMakeLists.txt duneproject dunecontrol \
dunedoxynize \
mpi-config dune-autogen \
xfail-compile-tests
......
This diff is collapsed.
......@@ -165,7 +165,12 @@ load_opts() {
local CMD_FLAGS_FROM_FILE=""
BUILDDIR=$DUNE_BUILDDIR
if test "x$DUNE_OPTS_FILE" != "x"; then
BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)"
# use build dir from opts file if set
OPTS_FILE_BUILDDIR="$(eval BUILDDIR=""; . $DUNE_OPTS_FILE; eval echo \$BUILDDIR)"
if test -n "$OPTS_FILE_BUILDDIR"; then
BUILDDIR="$OPTS_FILE_BUILDDIR"
fi
CMAKE_FLAGS="$(. $DUNE_OPTS_FILE; eval echo \$CMAKE_FLAGS)"
CMD_FLAGS_FROM_FILE="$(eval ${COMMAND}_FLAGS=""; . $DUNE_OPTS_FILE; eval echo \$${COMMAND}_FLAGS)"
fi
if test -n "$CMD_FLAGS_FROM_FILE"; then
......@@ -216,16 +221,17 @@ esac'
}
# list of all dunecontrol commands
COMMANDS="printdeps update autogen configure make all exec status svn"
COMMANDS="printdeps update autogen configure make all exec bexec status svn"
# help string for the commands
printdeps_HELP="print recursive dependencies of a module"
update_HELP="updated all modules from the repository"
autogen_HELP="run the autogen.sh script for each module"
configure_HELP="run configure for each module"
autogen_HELP="run the autogen.sh script for each module. Does nothing, if CMake is activated"
configure_HELP="run configure or cmake for each module"
make_HELP="run make for each module"
all_HELP="\trun 'autogen', 'configure' and 'make' command for each module"
exec_HELP="execute an arbitrary command in each module directory"
exec_HELP="execute an arbitrary command in each module source directory"
bexec_HELP="execute an arbitrary command in each module build directory"
status_HELP="show vc status for all modules"
svn_HELP="\trun svn command for each svn managed module"
......@@ -245,6 +251,8 @@ done
run_default_exec () { bash -c "eval $CMD_FLAGS"; }
run_default_bexec () { bash -c "cd "$BUILDDIR" && eval $CMD_FLAGS"; }
run_default_status () {
local verbose=0
local update=""
......@@ -342,29 +350,39 @@ run_default_update () {
}
run_default_autogen () {
PARAMS="$CMD_FLAGS"
local M4_PATH=""
if test -f configure.ac && \
( test -d .svn || test -d .git || test -d CVS || test -f stamp-vc ); then
sort_modules $FOUND_MODULES
for m in $MODULES; do
path=$(eval "echo \$PATH_$m")
MODULE_PATHS="$MODULE_PATHS$path "
done
if test -f autogen.sh; then
eval echo "WARNING: \$NAME_$module contains obsolete autogen.sh," \
>&2
echo " dune-autogen is used instead." >&2
if test "x$USE_CMAKE" != "xyes" || test ! -e $(eval "echo \$PATH_$module")/CMakeLists.txt ; then
PARAMS="$CMD_FLAGS"
local M4_PATH=""
if test -f configure.ac && \
( test -d .svn || test -d .git || test -d CVS || test -f stamp-vc ); then
sort_modules $FOUND_MODULES
for m in $FOUND_MODULES; do
path=$(eval "echo \$PATH_$m")
MODULE_PATHS="$MODULE_PATHS$path "
done
if test -f autogen.sh; then
eval echo "WARNING: \$NAME_$module contains obsolete autogen.sh," \
>&2
echo " dune-autogen is used instead." >&2
fi
eval "$PREFIX_DIR/bin/dune-autogen" "$MODULE_PATHS" "$PARAMS" || exit 1
else
echo Skipping dune-autogen
fi
eval "$PREFIX_DIR/bin/dune-autogen" "$MODULE_PATHS" "$PARAMS" || exit 1
else
echo Skipping dune-autogen
else
echo Skipping dune-autogen because of CMake
fi
}
run_default_configure () {
PARAMS="$CMD_FLAGS"
if test -x configure; then
if test "x$USE_CMAKE" = "xyes" && test -e $(eval "echo \$PATH_$module")/CMakeLists.txt; then
LOCAL_USE_CMAKE=yes
else
LOCAL_USE_CMAKE=no
fi
echo "LOCAL_USE_CMAKE=$LOCAL_USE_CMAKE $(eval "echo \$PATH_$module")/CMakeLists.txt"
if test -x configure || test "x$LOCAL_USE_CMAKE" = "xyes" ; then
ACLOCAL_FLAGS="-I ."
if test -d "m4"; then
ACLOCAL_FLAGS="$ACLOCAL_FLAGS -I m4"
......@@ -387,20 +405,42 @@ run_default_configure () {
else
PARAMS="$PARAMS \"--with-$name=$path\""
fi
if test "x$USE_CMAKE" = "xyes"; then
if test -d "$path/$BUILDDIR"; then
CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$path/$BUILDDIR\""
else
if test -d "$path/lib/cmake/$name"; then
CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$path/lib/cmake/$name\""
else
CMAKE_PARAMS="$CMAKE_PARAMS \"-D""$name""_DIR=$path\""
fi
fi
fi
done
if test "x$HAVE_duneweb" == "xyes"; then
PARAMS="$PARAMS \"--with-duneweb=$PATH_duneweb\""
fi
PARAMS="$PARAMS ACLOCAL_AMFLAGS=\"$ACLOCAL_FLAGS\""
echo ./configure "$PARAMS"
# create build directory of requested
if test -n "$BUILDDIR"; then
if test "x$LOCAL_USE_CMAKE" = "xyes"; then
test -d "$BUILDDIR" || mkdir "$BUILDDIR"
SRCDIR="$PWD"
cd "$BUILDDIR"
eval "$SRCDIR/configure" "$PARAMS" || exit 1
echo `pwd`
echo "cmake -DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR"
eval cmake "-DBUILD_SHARED_LIBS:BOOL=OFF -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS $SRCDIR"
else
eval ./configure "$PARAMS" || exit 1
echo ./configure "$PARAMS"
# create build directory of requested
if test -n "$BUILDDIR"; then
test -d "$BUILDDIR" || mkdir "$BUILDDIR"
SRCDIR="$PWD"
cd "$BUILDDIR"
eval "$SRCDIR/configure" "$PARAMS" || exit 1
else
eval ./configure "$PARAMS" || exit 1
fi
fi
else
if test -f configure.in || test -f configure.ac; then
......@@ -457,21 +497,22 @@ usage () {
echo " Dependencies are controlled by the $CONTROL files."
echo ""
echo "OPTIONS:"
echo " -h, --help show this help"
echo " --debug enable debug output of this script"
echo " --module=mod only apply the actions on module mod"
echo " and all modules it depends on"
echo " --only=mod only apply the actions on module mod"
echo " and not the modules it depends on"
echo " --current only apply the actions on the current module,"
echo " the one whose source tree we are standing in"
echo " --resume resume a previous run (only consider the modules"
echo " not built successfully on the previous run)"
echo " --skipfirst skip the first module (use with --resume)"
echo " --opts=FILE load default options from FILE"
echo " (see dune-common/doc/example.opts)"
echo " -h, --help show this help"
echo " --debug enable debug output of this script"
echo " --use-cmake use cmake instead autotools of cmake for building"
echo " --module=mod only apply the actions on module mod"
echo " and all modules it depends on"
echo " --only=mod only apply the actions on module mod"
echo " and not the modules it depends on"
echo " --current only apply the actions on the current module,"
echo " the one whose source tree we are standing in"
echo " --resume resume a previous run (only consider the modules"
echo " not built successfully on the previous run)"
echo " --skipfirst skip the first module (use with --resume)"
echo " --opts=FILE load default options from FILE"
echo " (see dune-common/doc/example.opts)"
echo " --builddir=NAME make out-of-source builds in a subdir NAME."
echo " This directory is created inside each module."
echo " This directory is created inside each module."
echo " --[COMMAND]-opts=opts set options for COMMAND"
echo " (this is mainly useful for the 'all' COMMAND)"
echo "COMMANDS:"
......@@ -550,6 +591,7 @@ export ONLY=""
export RESUME_FLAG=no
export REVERSE_FLAG=no
export SKIPFIRST=no
export USE_CMAKE=no
# parse commandline parameters
while test $# -gt 0; do
......@@ -658,6 +700,9 @@ while test $# -gt 0; do
--skipfirst)
export SKIPFIRST=yes
;;
--use-cmake)
export USE_CMAKE=yes
;;
--debug) true ;; # ignore this option, it is handled right at the beginning
--*)
usage
......@@ -673,6 +718,11 @@ while test $# -gt 0; do
shift
done
if test "x$USE_CMAKE" = "xyes" && test -z "$DUNE_BUILDDIR"; then
echo "No build directory provided. Defaulting to the sub directory build-cmake"
export DUNE_BUILDDIR=build-cmake
fi
echo "USE_CMAKE=$USE_CMAKE DUNE_BUILDDIR=$DUNE_BUILDDIR"
# we assume there should be a command...
if test "x$command" = "x"; then
usage
......
......@@ -313,7 +313,7 @@ echo "writing initial files:"
# we need the module with _ instead of - to not confuse automake
fix_and_assign CMODULE $MODULE
NAME=`echo $PROJECT | sed -e 's/dune[_-]//' | tr '-' '_'`
UNAME=`echo $PROJECT | tr '-' '_' | sed 's/\(.*\)/\U\1/'`
################## CONFIGURE.AC ##################
echo "- $PROJECT/configure.ac"
cat > "$PROJECT/configure.ac" <<C_DELIM
......@@ -462,6 +462,32 @@ include \$(top_srcdir)/am/global-rules
M_DELIM
################## CMakeLists.txt ##################
echo " - $PROJECT/CMakeLists.txt"
cat> "$PROJECT/CMakeLists.txt" << M_DELIM
cmake_minimum_required(VERSION 2.8.6)
project($PROJECT CXX)
#find dune-common and set the module path
find_package(dune-common)
list(APPEND CMAKE_MODULE_PATH ${dune-common_MODULE_PATH}
"${CMAKE_SOURCE_DIR}/cmake/modules")
#include the dune macros
include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
add_subdirectory("src")
add_subdirectory("m4")
add_subdirectory("dune")
add_subdirectory("doc")
# finalize the dune project, e.g. generating config.h etc.
finalize_dune_project(GENERATE_CONFIG_H_CMAKE)
M_DELIM
################## STAMP-VC ##################
echo "- $PROJECT/stamp-vc"
echo 'A stamp file to signify that this directory comes from a version control system, not an unpacked tarball' > $PROJECT/stamp-vc
......@@ -494,6 +520,16 @@ echo " Description and URL are missing right now."
mkdir "$PROJECT/src"
################## src/CMakeLists.txt ##################
echo "- $PROJECT/src/CMakeLists.txt"
cat> "$PROJECT/src/CMakeLists.txt" << M_DELIM
add_executable("${CMODULE}" ${CMODULE}.cc)
target_link_dune_default_libraries("${CMODULE}")
M_DELIM
################## src/MAKEFILE.AM ##################
echo "- $PROJECT/src/Makefile.am"
......@@ -588,6 +624,14 @@ EXTRA_DIST = \$(M4FILES)
include \$(top_srcdir)/am/global-rules
CC_DELIM
echo "- $PROJECT/m4/CMakeLists.txt"
cat> "$PROJECT/m4/CMakeLists.txt" << CC_DELIM
install(PROGRAMS $MODULE.m4 DESTINATION share/aclocal)
CC_DELIM
################## M4/PROJECT.M4 ####################
M4_MODULE=`echo $MODULE | tr '[a-z-]' '[A-Z_]'`
echo "- $PROJECT/m4/$MODULE.m4"
......@@ -628,6 +672,12 @@ SUBDIRS = $NAME
include \$(top_srcdir)/am/global-rules
EOF
echo "- $PROJECT/dune/CMakeLists.txt"
cat> $PROJECT/dune/CMakeLists.txt <<EOF
add_subdirectory($NAME)
EOF
################## dune/$NAME/Makefile.am ##############
echo "- $PROJECT/dune/$NAME/Makefile.am"
cat> $PROJECT/dune/$NAME/Makefile.am <<EOF
......@@ -637,6 +687,13 @@ ${NAME}include_HEADERS = ${NAME}.hh
include \$(top_srcdir)/am/global-rules
EOF
echo "- $PROJECT/dune/$NAME/CMakeLists.txt"
cat> $PROJECT/dune/$NAME/CMakeLists.txt <<EOF
#install headers
install(FILES ${NAME}.hh DESTINATION include/dune/$NAME)
EOF
################## dune/$NAME/$NAME.hh #################
echo "- $PROJECT/dune/$NAME/$NAME.hh"
cat> $PROJECT/dune/$NAME/$NAME.hh <<EOF
......@@ -672,6 +729,12 @@ include \$(top_srcdir)/am/webstuff
include \$(top_srcdir)/am/global-rules
CC_DELIM
echo "- $PROJECT/doc/CMakeLists.txt"
cat> "$PROJECT/doc/CMakeLists.txt" << CC_DELIM
add_subdirectory("doxygen")
CC_DELIM
###############################################################
############### The doc/doxygen subdirectory ##################
###############################################################
......@@ -733,7 +796,126 @@ include \$(top_srcdir)/am/global-rules
CC_DELIM
echo "- $PROJECT/doc/doxygen/CMakeLists.txt"
cat> "$PROJECT/doc/doxygen/CMakeLists.txt" << CC_DELIM
# shortcut for creating the Doxyfile.in and Doxyfile
add_doxygen_target()
CC_DELIM
echo "- $PROJECT/config.h.cmake"
cat> "$PROJECT/config.h.cmake" <<EOF
/* begin $NAME
put the definitions for config.h specific to
your project here. Everything above will be
overwritten
*/
/* begin private */
/* Name of package */
#define PACKAGE "@DUNE_MOD_NAME"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "@DUNE_MAINTAINER@"
/* Define to the full name of this package. */
#define PACKAGE_NAME "@DUNE_MOD_NAME@"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "@DUNE_MOD_NAME@ @DUNE_MOD_VERSION@"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "@DUNE_MOD_NAME@"
/* Define to the home page for this package. */
#define PACKAGE_URL "@DUNE_MOD_URL@"
/* Define to the version of this package. */
#define PACKAGE_VERSION "@DUNE_MOD_VERSION@"
/* end private */
/* Define to the version of $PROJECT */
#define ${UNAME}_VERSION "@${UNAME}_VERSION@"
/* Define to the major version of $PROJECT */
#define ${UNAME}_VERSION_MAJOR @${UNAME}_VERSION_MAJOR@
/* Define to the minor version of $PROJECT */
#define ${UNAME}_VERSION_MINOR @${UNAME}_VERSION_MINOR@
/* Define to the revision of $PROJECT */
#define ${UNAME}_VERSION_REVISION @${UNAME}_VERSION_REVISION@
/* end $NAME
Everything below here will be overwritten
*/
EOF
## done
echo "- $PROJECT/$PROJECT""-config.cmake.in"
cat> "$PROJECT/$PROJECT""-config.cmake.in" <<EOF
if(NOT @DUNE_MOD_NAME@_FOUND)
#import the target
#include("@CMAKE_BINARY_DIR@/@DUNE_MOD_NAME@-targets.cmake")
#report other information
set(@DUNE_MOD_NAME@_PREFIX "@CMAKE_SOURCE_DIR@")
set(@DUNE_MOD_NAME@_INCLUDE_DIRS "@CMAKE_SOURCE_DIR@")
set(@DUNE_MOD_NAME@_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
set(@DUNE_MOD_NAME@_LIBRARIES "") # list exported libraries here
set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@")
set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@")
endif(NOT @DUNE_MOD_NAME@_FOUND)
endif(NOT @DUNE_MOD_NAME@_FOUND)
EOF
mkdir "$PROJECT/cmake"
mkdir "$PROJECT/cmake/modules"
mkdir "$PROJECT/cmake/pkg"
echo "- $PROJECT/cmake/pkg/$PROJECT""-config.cmake.in"
cat> "$PROJECT/cmake/pkg/$PROJECT""-config.cmake.in" <<EOF
if(NOT @DUNE_MOD_NAME@_FOUND)
#compute installation prefix relative to this file
get_filename_component(_dir "\${CMAKE_CURRENT_LIST_FILE}" PATH)
get_filename_component(_prefix "\${_dir}/../../.." ABSOLUTE)
#import the target
#include("\${_prefix}/lib/cmake/@DUNE_MOD_NAME@-targets.cmake")
#report other information
set(@DUNE_MOD_NAME@_INCLUDE_DIRS "\${_prefix}/include")
set(@DUNE_MOD_NAME@_CXX_FLAGS "@CMAKE_CXX_FLAGS@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_DEBUG "@CMAKE_CXX_FLAGS_DEBUG@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_MINSIZEREL "@CMAKE_CXX_FLAGS_MINSIZEREL@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELEASE "@CMAKE_CXX_FLAGS_RELEASE@")
set(@DUNE_MOD_NAME@_CXX_FLAGS_RELWITHDEBINFO "@CMAKE_CXX_FLAGS_RELWITHDEBINFO@")
set(@DUNE_MOD_NAME@_MODULE_PATH "@DUNE_INSTALL_MODULEDIR@")
set(@DUNE_MOD_NAME@_LIBRARIES "") # list libraries
set(@DUNE_MOD_NAME@_DEPENDS "@DUNE_DEPENDS@")
set(@DUNE_MOD_NAME@_SUGGESTS "@DUNE_SUGGESTS@")
endif(NOT @DUNE_MOD_NAME@_FOUND)
EOF
echo "- $PROJECT/$PROJECT""-version.cmake.in"
cat> "$PROJECT/$PROJECT""-version.cmake.in" <<EOF
set(PACKAGE_VERSION "@DUNE_MOD_VERSION@")
if(NOT "\${PACKAGE_FIND_VERSION}" VERSION_GREATER "@DUNE_MOD_VERSION@")
set (PACKAGE_VERSION_COMPATIBLE 1) # compatible with older
if ("\${PACKAGE_FIND_VERSION}" VERSION_EQUAL "@DUNE_MOD_VERSION@")
set(PACKAGE_VERSION_EXACT 1) #exact match for this version
endif()
endif()
EOF
echo "- $PROJECT/stamp-regenerate-config-h"
touch $PROJECT/stamp-regenerate-config-h
echo
echo "done."
echo "------------------------------------------"
echo "For further details read the Dune Buildsystem-Howto:"
......
Makefile.in
Makefile
SUBDIRS=modules pkg scripts
Makefile.in
Makefile
set(modules DuneBoost.cmake
DuneCommonMacros.cmake
DuneCxaDemangle.cmake
DuneDoc.cmake
DuneDoxygen.cmake
DuneMacros.cmake
DuneMPI.cmake
DunePkgConfig.cmake
DuneStreams.cmake
DuneTestMacros.cmake
DuneTests.cmake
FindBoostFusion.cmake
FindCXX11Features.cmake
FindGMP.cmake
FindInkscape.cmake
FindMETIS.cmake
FindMProtect.cmake
FindParMETIS.cmake
FindSharedPtr.cmake
LanguageSupport.cmake
UseLATEX.cmake)
install(FILES ${modules} DESTINATION ${DUNE_INSTALL_MODULEDIR})
# Searches for boost and provides the following function:
#
# add_dune_boost_flags(targets)
#
# Adds boost compiler flags and libraries, and activates
# Boost for the specified targets.
find_package(Boost)
set(HAVE_BOOST ${Boost_FOUND})
function(add_dune_boost_flags _targets)
if(Boost_FOUND)
include_directories("${Boost_INCLUDE_DIRS}")
foreach(_target ${_targets})
target_link_libraries(${_target} ${Boost_LIBRARIES})
# The definitions are a hack as we do not seem to know which MPI implementation was
# found.
GET_TARGET_PROPERTY(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
SET_TARGET_PROPERTIES(${_target} PROPERTIES COMPILE_FLAGS
"${_props} -DENABLE_BOOST=1")
endforeach(_target)
endif(Boost_FOUND)
endfunction(add_dune_boost_flags)
# This cmake file holds tests and directives that are executed
# for the module dune-common and have to be executed by
# all dependent modules
#
# Specifically it configure the DUNE debug streams and
# tests whether std::shared_ptr, LAPACK and BLAS are available.
#
include(DuneStreams)
dune_set_minimal_debug_level()
find_package(SharedPtr)
if(Fortran_Works)
# search for lapack
find_package(LAPACK)
set(HAVE_LAPACK ${LAPACK_FOUND})
set(HAVE_BLAS ${BLAS_FOUND})
else(Fortran_Works)
set(HAVE_LAPACK Off)
set(HAVE_BLAS Off)
# Write an empty FC header
file(WRITE ${CMAKE_BINARY_DIR}/FC.h "")
endif(Fortran_Works)
find_package(GMP)
find_package(Inkscape)
include(FindMProtect)
include(DuneBoost)
# Module that checks whether the compiler supports the
# abi::__cxa_demangle function required to
# make the type names returned by typeid() human-readable
#
# Sets the following variable:
# HAVE_CXA_DEMANGLE
#
# perform tests
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <cxxabi.h>
int main(void){
int foobar = 0;
const char *foo = typeid(foobar).name();
int status;
char *demangled = abi::__cxa_demangle( foo, 0, 0, &status );
}" HAVE_CXA_DEMANGLE)
#
# Module that provides a custom target make doc at the top level
# directory and utility macros for creating install directives
# that make sure that the files to be installed are previously
# generated even if make doc was not called.
#
# All documentation (Latex, Doxygen) will be generated during
# make doc.
# It provides the following macros:
#
# create_doc_install(FILENAME TARGETDIR [DEPENDENCY])
#
# creates a target for installing the file FILENAME
# to the directory TARGETDIR.
# If DEPENDENCY is specified, this is a dependency for
# the installation. Otherwise FILENAME becomes the dependency
#
# dune_add_latex_document()
FIND_PACKAGE(LATEX)
FIND_PROGRAM(IMAGEMAGICK_CONVERT convert
DOC "The convert program that comes with ImageMagick (available at http://www.imagemagick.org)."
)
set(LATEX_USABLE "ON")
if(NOT LATEX_COMPILER)
message(WARNING " Need latex to create documentation!")
set(LATEX_USABLE)
endif(NOT LATEX_COMPILER)
if(NOT BIBTEX_COMPILER)
message(WARNING " Need bibtex to create documentation!")
set(LATEX_USABLE)
endif(NOT BIBTEX_COMPILER)
if(NOT MAKEINDEX_COMPILER)
message(WARNING " Need makeindex to create documentation!")
set(LATEX_USABLE)
endif(NOT MAKEINDEX_COMPILER)
if(NOT IMAGEMAGICK_CONVERT)
message(WARNING " Need imagemagick to create latex documentation!")
set(LATEX_USABLE)
endif(NOT IMAGEMAGICK_CONVERT)
if(LATEX_USABLE)
set(LATEX_MANGLE_TARGET_NAMES "ON" CACHE INTERNAL "Mangle target names to allow multiple latex documents")
include(UseLATEX)
endif(LATEX_USABLE)
add_custom_target(doc)
MACRO(create_doc_install filename targetdir)
dune_common_script_dir(SCRIPT_DIR)
get_filename_component(targetfile ${filename} NAME)
# The doc file might be in CMAKE_CURRENT_<SOURCE|BINARY>_DIR
# Depending on whether this is a tarball or not
set(_src_file _src_file-NOTFOUND)
find_file(_src_file ${targetfile} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT _src_file)
set(_src_file ${filename})
set(_need_to_generate TRUE)
endif(NOT _src_file)
set(install_command ${CMAKE_COMMAND} -D FILES=${_src_file} -D DIR=${CMAKE_INSTALL_PREFIX}/${targetdir} -P ${SCRIPT_DIR}/InstallFile.cmake)
# create a custom target for the installation
if("${ARGC}" EQUAL "3" AND _need_to_generate)
set(_depends ${ARGV2})
else("${ARGC}" EQUAL "3" AND _need_to_generate)
set(_depends ${_src_file})
endif("${ARGC}" EQUAL "3" AND _need_to_generate)
add_custom_target(install_${targetfile} ${install_command}
COMMENT "Installing ${filename} to ${targetdir}"
DEPENDS ${_depends})
# When installing, call cmake install with the above install target and add the file to install_manifest.txt
install(CODE "execute_process(COMMAND \"${CMAKE_COMMAND}\" --build \"${CMAKE_BINARY_DIR}\" --target install_${targetfile} )
LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_PREFIX}/${targetdir}/${targetfile})")
ENDMACRO(create_doc_install)
MACRO(dune_add_latex_document tex_file)
# We assume that we always generate a PDF file.
# If the corresponding pdf file already exists in the source tree
# we do not add a rule to build it.
string(REGEX REPLACE "(.+).tex" "\\1.pdf" file ${tex_file})
string(REGEX REPLACE "/" "_" "${CMAKE_CURRENT_SOURCE_DIR}/${file}" filevar ${file})
set(filevar "filevar-NOTFOUND")
find_file(filevar ${tex_file} ${CMAKE_CURRENT_SOURCE_DIR})
message(filevar=${filevar} tex_file=${tex_file} CMAKE_CURRENT_SOURCE_DIR=${CMAKE_CURRENT_SOURCE_DIR})
if(filevar)
if(LATEX_USABLE)
# add rule to create latex document
add_latex_document(${tex_file} ${ARGN})
else(LATEX_USABLE)
message(WARNING "Not adding rule to create ${file} as LaTEX is not usable!")
endif(LATEX_USABLE)
else(filevar)
# Check for the pdf file
set(pdffilevar "pdffilevar-NOTFOUND")
find_file(pdffilevar ${file} ${CMAKE_CURRENT_SOURCE_DIR})
if(NOT pdffilevar)
message(SEND_ERROR "No tex source ${tex_file} and no generated ${file} found!")
endif(NOT pdffilevar)
endif(filevar)
ENDMACRO(dune_add_latex_document tex_file)
# Support building documentation with doxygen.
include(DuneDoxygen)
# Module for building documentation using doxygen.
#
# provides the following macros:
#
# add_doxgen_target
#
# This macro creates a target for building (doxygen_${DUNE_MOD_NAME}) and installing
# (doxygen_install_${DUNE_MOD_NAME}) the generated doxygen documentation.
# The documentation is built during the top-level make doc call. We have added a dependency
# that makes sure it is built before running make install.
#
#
FIND_PACKAGE(Doxygen)
#
# Set DOT_TRUE for the Doxyfile generation.
#
if (NOT DOXYGEN_DOT_FOUND)
set(DOT_TRUE '\#')
endif (NOT DOXYGEN_DOT_FOUND)
add_custom_target(doxygen_install)
#
# prepare_doxyfile()
# This functions adds the necessary routines for the generation of the
# Doxyfile[.in] files needed to doxygen.
MACRO (prepare_doxyfile)
message(STATUS "using ${DOXYSTYLE_FILE} to create doxystyle file")
set(make_doxyfile_command ${CMAKE_COMMAND} -D DOT_TRUE=${DOT_TRUE} -D DUNEWEB_TRUE=\# -D DUNE_MOD_NAME=${DUNE_MOD_NAME} -D DUNE_MOD_VERSION=${DUNE_MOD_VERSION} -D DOXYSTYLE=${DOXYSTYLE_FILE} -D DOXYLOCAL=${CMAKE_CURRENT_SOURCE_DIR}/Doxylocal -D abs_top_srcdir=${CMAKE_SOURCE_DIR} -D srcdir=${CMAKE_CURRENT_SOURCE_DIR} -D top_srcdir=${CMAKE_SOURCE_DIR} -P ${SCRIPT_DIR}/CreateDoxyFile.cmake)
add_custom_command (OUTPUT Doxyfile.in Doxyfile
COMMAND ${make_doxyfile_command} COMMENT "Creating Doxyfile.in")
add_custom_target(Doxyfile DEPENDS Doxyfile.in Doxyfile)
ENDMACRO (prepare_doxyfile)
#
# add_doxgen_target
#
# This macro creates a target for building (doxygen_${DUNE_MOD_NAME}) and installing
# (doxygen_install_${DUNE_MOD_NAME}) the generated doxygen documentation.
# The documentation is built during the top-level make doc call. We have added a dependency
# that make sure it is built before running make install.
MACRO (add_doxygen_target)
dune_common_script_dir(SCRIPT_DIR)
if("${CMAKE_PROJECT_NAME}" STREQUAL "dune-common")
set(DOXYSTYLE_FILE ${CMAKE_CURRENT_SOURCE_DIR}/Doxystyle)
endif("${CMAKE_PROJECT_NAME}" STREQUAL "dune-common")
message(STATUS "Using scripts from ${SCRIPT_DIR} for creating doxygen stuff.")
set(_src_file _src_file-NOTFOUND)
find_file(_src_file index.html ${CMAKE_CURRENT_SOURCE_DIR}/html)
if(_src_file)
set(_src_dir ${CMAKE_CURRENT_SOURCE_DIR})
add_custom_target(doxygen_${DUNE_MOD_NAME})
else(_src_file)
if(DOXYGEN_FOUND)
prepare_doxyfile()
# A custom command that exectutes doxygen
add_custom_command(OUTPUT html COMMAND
${CMAKE_COMMAND} -D DOXYGEN_EXECUTABLE=${DOXYGEN_EXECUTABLE} -P ${SCRIPT_DIR}/RunDoxygen.cmake
COMMENT "Running doxygen documentation. This may take a while"
DEPENDS Doxyfile)
# Create a target for building the doxygen documentation of a module,
# that is run during make doc.
add_custom_target(doxygen_${DUNE_MOD_NAME} DEPENDS html)
add_dependencies(doc doxygen_${DUNE_MOD_NAME})
endif(DOXYGEN_FOUND)
set(_src_dir ${CMAKE_CURRENT_BINARY_DIR})
endif(_src_file)
# Use a cmake call to install the doxygen documentation and create a
# target for it
include(GNUInstallDirs)
# When installing call cmake install with the above install target
install(CODE
"execute_process(COMMAND ${CMAKE_COMMAND} --build ${CMAKE_BINARY_DIR} --target doxygen_${DUNE_MOD_NAME}
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR})
file(GLOB doxygenfiles
GLOB ${_src_dir}/html/*.html
${_src_dir}/html/*.png
${_src_dir}/html/*.css
${_src_dir}/html/*.gif)
set(doxygenfiles \"\${doxygenfiles}\")
foreach(_file \${doxygenfiles})
get_filename_component(_basename \${_file} NAME)
LIST(APPEND CMAKE_INSTALL_MANIFEST_FILES ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen/\${_basename})
endforeach(_file in \${doxygenfiles})
file(INSTALL \${doxygenfiles} DESTINATION ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen)
message(STATUS \"Installed doxygen into ${CMAKE_INSTALL_FULL_DOCDIR}/doxygen\")")
ENDMACRO (add_doxygen_target)
# Searches for MPI and thread support and sets the following
# DUNE specific flags:
#
# MPI_DUNE_COMPILE_FLAGS Compiler flags for MPI applications.
# MPI_DUNE_INCLUDE_PATH Include path for MPI applications.
# MPI_DUNE_LINK_FLAGS Linker flags for MPI applications.
# MPI_DUNE_LIBRARIES Libraries for MPI applications.
#
# The DUNE way to compile MPI applications is to use the CXX
# compiler with MPI flags usually used for C. CXX bindings
# are deactivated to prevent ABI problems.
#
# The following function is defined:
#
# add_dune_mpi_flags(targets)
#
# Adds the above flags and libraries to the specified targets.
#
find_package(MPI)
find_package(Threads)
if(MPI_FOUND)
set(HAVE_MPI MPI_CXX_FOUND)
# We do not support the CXX bindings of MPI
set(MPI_DUNE_COMPILE_FLAGS ${MPI_C_COMPILE_FLAGS} CACHE STRING
"Compile flags used by DUNE when compiling MPI programs")
set(MPI_DUNE_INCLUDE_PATH ${MPI_C_INCLUDE_PATH} CACHE STRING
"Include path used by DUNE when compiling MPI programs")
# There seems to be no target specific include path, use the global one.
include_directories(${MPI_DUNE_INCLUDE_PATH})
set(MPI_DUNE_LINK_FLAGS ${MPI_C_LINK_FLAGS} CACHE STRING
"Linker flags used by DUNE when compiling MPI programs")
set(MPI_DUNE_LIBRARIES ${CMAKE_THREAD_LIBS_INIT} ${MPI_C_LIBRARIES} CACHE STRING
"Libraries used by DUNE when linking MPI programs")
# Check whether the MPI-2 standard is supported
include(CMakePushCheckState)
include(CheckFunctionExists)
cmake_push_check_state()
set(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES};${MPI_DUNE_LIBRARIES})
set(CMAKE_REQUIRED_DEFINITIONS ${CMAKE_REQUIRED_DEFINITIONS} "-DENABLE_MPI=1 -DMPICH_SKIP_MPICXX -DMPIPP_H")
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES};${MPI_DUNE_INCLUDE_PATH})
check_function_exists(MPI_Finalized MPI_2)
cmake_pop_check_state()
endif(MPI_FOUND)
# adds MPI flags to the targets
function(add_dune_mpi_flags)
cmake_parse_arguments(ADD_MPI "SOURCE_ONLY;OBJECT" "" "" ${ARGN})
if(ADD_MPI_SOURCE_ONLY)
set(_prefix SOURCE)
else()
set(_prefix TARGET)
endif()
if(MPI_FOUND)
set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND PROPERTY COMPILE_FLAGS ${MPI_DUNE_COMPILE_FLAGS})
set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND PROPERTY COMPILE_DEFINITIONS ENABLE_MPI=1
MPICH_SKIP_MPICXX MPIPP_H)
if(NOT (ADD_MPI_SOURCE_ONLY OR ADD_MPI_OBJECT))
set_property(${_prefix} ${ADD_MPI_UNPARSED_ARGUMENTS} APPEND_STRING PROPERTY LINK_FLAGS ${MPI_DUNE_LINK_FLAGS})
foreach(target ${ADD_MPI_UNPARSED_ARGUMENTS})
target_link_libraries(${target} ${MPI_DUNE_LIBRARIES})
endforeach(target ${ADD_MPI_UNPARSED_ARGUMENTS})
endif(NOT (ADD_MPI_SOURCE_ONLY OR ADD_MPI_OBJECT))
endif(MPI_FOUND)
endfunction(add_dune_mpi_flags)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment