Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • jakub.both/dune-common
  • samuel.burbulla/dune-common
  • patrick.jaap/dune-common
  • tobias.leibner/dune-common
  • alexander.mueller/dune-common
  • pipping/dune-common
  • Xinyun.Li/dune-common
  • felix.schindler/dune-common
  • simon.praetorius/dune-common
  • ani.anciaux-sedrakian/dune-common
  • henrik.stolzmann/dune-common
  • matthew.t.collins/dune-common
  • liam.keegan/dune-common
  • felix.mueller/dune-common
  • ansgar/dune-common
  • dominic/dune-common
  • lars.lubkoll/dune-common
  • exadune/dune-common
  • felix.gruber/dune-common
  • govind.sahai/dune-common
  • michael.sghaier/dune-common
  • core/dune-common
  • kilian.weishaupt/dune-common
  • markus.blatt/dune-common
  • joscha.podlesny/dune-common
  • tobias.meyer.andersen/dune-common
  • andreas.thune/dune-common
  • lars.bilke/dune-common
  • daniel.kienle/dune-common
  • lukas.renelt/dune-common
  • smuething/dune-common
  • stephan.hilb/dune-common
  • tkoch/dune-common
  • nils.dreier/dune-common
  • rene.milk/dune-common
  • lasse.hinrichsen/dune-common
  • yunus.sevinchan/dune-common
  • lisa_julia.nebel/dune-common
  • claus-justus.heine/dune-common
  • lorenzo.cerrone/dune-common
  • eduardo.bueno/dune-common
41 results
Show changes
Commits on Source (89)
Showing
with 646 additions and 136 deletions
......@@ -12,7 +12,7 @@ semantic.cache
# Stuff to ignore in this directory only
/aclocal.m4
/autom4te.cache/
/build-cmake/
/build-*/
/compile
/config.guess
/config.h
......
......@@ -717,8 +717,7 @@ run_default_configure () {
cd "$ABS_BUILDDIR"
# check for libtool libs, which might break modules depending on this module
test -n "`find . -name \*.la`" && \
echo "Error: your build directory $ABS_BUILDDIR contains libtool built libraries, please cleanup" && \
exit 1
echo "Warning: your build directory $ABS_BUILDDIR contains libtool built libraries, please cleanup"
echo "$PREPARAMS $CMAKE -DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\""
eval $PREPARAMS $CMAKE "-DCMAKE_MODULE_PATH=\"$CMAKE_MODULE_PATH\" $CMAKE_PARAMS $CMAKE_FLAGS \"$SRCDIR\"" || exit 1
else
......
......@@ -181,10 +181,15 @@ PROJECT="$1"
DEPENDENCIES="$2"
VERSION="$3"
MAINTAINER="$4"
ENABLE_ALL="$5"
################## READ OPTIONS ##################
while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
# Track minimum CMake version
CMAKE_MINIMUM_REQUIRED=2.8.6
while [ -z $PROJECT ]; do
read -p "1) Name of your new Project? (e.g.: dune-grid): " PROJECT
if echo "$MODULES" | grep -q ^$PROJECT$; then
......@@ -225,14 +230,30 @@ while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
while [ -z "$MAINTAINER" ]; do
read -p "4) Maintainer's email address? " MAINTAINER
done
while [ "$ENABLE_ALL" != "y" -a "$ENABLE_ALL" != "Y" ]; do
read -p "5) Enable all found packages? (WE strongly recommend yes, unless you know exactly what you are doing) [y/N]" ENABLE_ALL
while [ "$ENABLE_ALL" != "y" -a "$ENABLE_ALL" != "Y" -a "$ENABLE_ALL" != "n" -a "$ENABLE_ALL" != "N" ]; do
echo "5) Enable all available packages? (Choose 'y' if you don't understand the question, but see warning below.)"
read -p " WARNING: If you enable this option, your module will require at least CMake 2.8.12 to build. You can check your version with 'cmake --version' [y/N]" ENABLE_ALL
done
# canonicalize contents of ENABLE_ALL
ENABLE_ALL=$(tr '[:upper:]' '[:lower:]' <<< "$ENABLE_ALL")
# set newer CMake minimum version if ENABLE_ALL is true
if [ 'y' == "$ENABLE_ALL" ] ; then
CMAKE_MINIMUM_REQUIRED=2.8.12
fi
echo
echo "creating Project \"$PROJECT\", version $VERSION "
echo "which depends on \"$DEPENDENCIES\""
echo "with maintainer \"$MAINTAINER\""
if [ "y" == "$ENABLE_ALL" ] ; then
echo "and new, automatic external package handling based on dune_enable_all_packages()."
else
echo "and old external package handling (you need to manually add external dependencies to each target in CMakeLists.txt)."
fi
echo "Minimum required CMake version for building this project: ${CMAKE_MINIMUM_REQUIRED}"
echo
read -p "Are these informations correct? [y/N] " DATACORRECT
# reset data if necessary
......@@ -243,7 +264,14 @@ while [ "$DATACORRECT" != "y" -a "$DATACORRECT" != "Y" ]; do
MAINTAINER=""
ENABLE_ALL=""
fi
done
done
# canonicalize contents of ENABLE_ALL
ENABLE_ALL=$(tr '[:upper:]' '[:lower:]' <<< "$ENABLE_ALL")
echo
echo "A sample code $MODULE.cc is generated in the \"$PROJECT\" directory."
......@@ -373,7 +401,7 @@ Preparing the Sources
Additional to the software mentioned in README you'll need the
following programs installed on your system:
cmake >= 2.8.6
cmake >= ${CMAKE_MINIMUM_REQUIRED}
or if you use the old autoconf build system:
......@@ -486,7 +514,7 @@ M_DELIM
################## CMakeLists.txt ##################
echo "- $PROJECT/CMakeLists.txt"
cat> "$PROJECT/CMakeLists.txt" << M_DELIM
cmake_minimum_required(VERSION 2.8.6)
cmake_minimum_required(VERSION ${CMAKE_MINIMUM_REQUIRED})
project($PROJECT CXX)
if(NOT (dune-common_DIR OR dune-common_ROOT OR
......@@ -506,7 +534,7 @@ include(DuneMacros)
# start a dune project with information from dune.module
dune_project()
M_DELIM
if test ! -z "$ENABLE_ALL"; then
if [ 'y' == "$ENABLE_ALL" ] ; then
cat>> "$PROJECT/CMakeLists.txt" << M_DELIM
dune_enable_all_packages()
M_DELIM
......@@ -662,6 +690,9 @@ M_DELIM
################## PROJECT.CC ##################
echo "- $PROJECT/src/$MODULE.cc"
cat> "$PROJECT/src/$MODULE.cc" << CC_DELIM
// -*- tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
// vi: set et ts=4 sw=2 sts=2:
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
......
......@@ -9,7 +9,7 @@
function(add_dune_ptscotch_flags _targets)
if(PTSCOTCH_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY})
target_link_libraries(${_target} ${PTSCOTCH_LIBRARY} ${SCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY})
GET_TARGET_PROPERTY(_props ${_target} INCLUDE_DIRECTORIES)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
SET_TARGET_PROPERTIES(${_target} PROPERTIES INCLUDE_DIRECTORIES
......
# module providing convenience methods for compiling
# binaries with SuiteSparse support
#
# Provides the following functions:
#
# add_dune_suitsparse_flags(target1 target2...)
#
# adds SuiteSparse flags to the targets for compilation and linking
function(add_dune_suitesparse_flags _targets)
if(SUITESPARSE_FOUND)
foreach(_target ${_targets})
target_link_libraries(${_target} ${SUITESPARSE_DUNE_LIBRARIES})
get_target_property(_props ${_target} COMPILE_FLAGS)
string(REPLACE "_props-NOTFOUND" "" _props "${_props}")
set_target_properties(${_target} PROPERTIES COMPILE_FLAGS
"${_props} ${SUITESPARSE_DUNE_COMPILE_FLAGS} -DENABLE_SUITESPARSE=1")
endforeach(_target ${_targets})
endif(SUITESPARSE_FOUND)
endfunction(add_dune_suitesparse_flags)
......@@ -3,6 +3,7 @@ set(modules
AddMETISFlags.cmake
AddParMETISFlags.cmake
AddPTScotchFlags.cmake
AddSuiteSparseFlags.cmake
AddUMFPackFlags.cmake
CheckCXX11Features.cmake
DuneBoost.cmake
......@@ -26,10 +27,12 @@ set(modules
FindMProtect.cmake
FindParMETIS.cmake
FindPTScotch.cmake
FindSuiteSparse.cmake
FindThreadsCMake31.cmake
FindUMFPack.cmake
Headercheck.cmake
LanguageSupport.cmake
OverloadCompilerFlags.cmake
UseInkscape.cmake
UseLATEX.cmake)
set(test_programs CheckForPthreads.c)
......
......@@ -60,7 +60,33 @@ check_cxx_source_compiles("
return 0;
}
" HAVE_NULLPTR
)
)
if(HAVE_NULLPTR)
check_cxx_source_compiles("
#include <cstddef>
int main(void)
{
std::nullptr_t npt = nullptr;
return 0;
}
" HAVE_NULLPTR_T
)
if (NOT HAVE_NULLPTR_T)
if(${CMAKE_CXX_COMPILER_ID} STREQUAL "Intel")
message(FATAL_ERROR "Your compiler supports the 'nullptr' keyword, but not the type std::nullptr_t.
You are using an Intel compiler, where this error is typically caused by an outdated underlying system GCC.
Check if 'gcc --version' gives you at least GCC 4.6, otherwise please install a newer GCC and point your Intel compiler at it using the '-gcc-name' or '-gxx-name' options (see 'man icc' for further details)."
)
else()
message(FATAL_ERROR "Your compiler supports the 'nullptr' keyword, but not the type std::nullptr_t.
THIS SHOULD NOT HAPPEN FOR YOUR COMPILER!
Please submit a bug at https://dune-project.org/flyspray/"
)
endif()
endif()
endif()
# __attribute__((unused))
check_cxx_source_compiles("
......@@ -278,8 +304,16 @@ if(${CMAKE_VERSION} VERSION_LESS "3.1")
else()
find_package(Threads)
endif()
set(STDTHREAD_LINK_FLAGS "${CMAKE_THREAD_LIBS_INIT}"
CACHE STRING "Linker flags needed to get working C++11 threads support")
# see whether threading needs -no-as-needed
if(EXISTS /etc/dpkg/origins/ubuntu)
set(NO_AS_NEEDED "-Wl,-no-as-needed ")
else(EXISTS /etc/dpkg/origins/ubuntu)
set(NO_AS_NEEDED "")
endif(EXISTS /etc/dpkg/origins/ubuntu)
set(STDTHREAD_LINK_FLAGS "${NO_AS_NEEDED}${CMAKE_THREAD_LIBS_INIT}"
CACHE STRING "Linker flags needed to get working C++11 threads support. On Ubuntu it may be necessary to include -Wl,-no-as-needed (see FS#1650).")
# set linker flags
#
......
......@@ -8,7 +8,8 @@
# perform tests
include(CheckCXXSourceCompiles)
CHECK_CXX_SOURCE_COMPILES("#include <cxxabi.h>
CHECK_CXX_SOURCE_COMPILES("#include <typeinfo>
#include <cxxabi.h>
int main(void){
int foobar = 0;
const char *foo = typeid(foobar).name();
......
# This module provides the macros necessary for a simplified CMake build system
# This module provides the functions necessary for a simplified CMake build system
#
# The dune build system relies on the user to choose and add the compile and link flags
# The DUNE build system relies on the user to choose and add the compile and link flags
# necessary to build an executable. While this offers full control to the user, it
# is an error-prone procedure.
#
# Alternatively, users may use this modules macros to simply add the compile flags for all
# found external modules to all executables in a module. Likewise, all found libraries are
# Alternatively, users may use the functions in this module to simply add the compile flags for all
# found external modules to all executables in a DUNE module. Likewise, all found libraries are
# linked to all targets.
#
# This module provides the following macros:
# This module provides the following functions:
#
# dune_enable_all_packages(INCLUDE_DIRS [include_dirs]
# COMPILE_DEFINITIONS [compile_definitions]
# COMPILE_OPTIONS [compile_options]
# MODULE_LIBRARIES [libraries]
# [VERBOSE] [APPEND]
# )
#
# Adds all flags and all libraries to all executables that are subsequently added in the directory
# from where this macro is called and from all its subdirectories (recursively).
# If used, this macro MUST be called in the top level CMakeLists.txt BEFORE adding any subdirectories!
# from where this function is called and from all its subdirectories (recursively).
# If used, this function MUST be called in the top level CMakeLists.txt BEFORE adding any subdirectories!
# You can optionally add additional include dirs and compile definitions that will also be applied to
# all targets in the module.
# Finally, if your module contains libraries as well as programs and if the programs should automatically
......@@ -29,40 +30,61 @@
# versions handle linking (in particular CMP022 and CMP038). You can later add source files to the library
# anywhere in the source tree by calling dune_library_add_sources().
#
# Warning: dune_enable_all_packages() requires CMake 2.8.12+. If you call this function with an older version
# of CMake, the build will fail with a fatal error. DO NOT enable this feature if your module needs
# to compile on machines with an older version of CMake.
# Warning: The library feature requires CMake 3.1+. If you use the feature with older versions, CMake
# will emit a fatal error. Moreover, it will issue a warning if the cmake_minimum_required()
# version is older than 3.1.
# Note: If you want to use dune_enable_all_packages() with an older version of CMake and your DUNE mdule
# creates its own library, you have to manually create the library in the top-level CMakeLists.txt
# file using dune_add_library() (with all sources listed within that call), use
# dune_target_enable_all_packages() to add all packages to the library and finally list that library
# under LIBRARIES in the call to dune_register_package_flags(). See dune-pdelab for an example of
# how to do this correctly.
#
# For a description of the APPEND option, see the documentation of dune_register_package_flags().
# With the VERBOSE option being set, the list of flags is printed during configure.
#
# dune_register_package_flags(COMPILE_DEFINITIONS flags
# INCLUDE_DIRS includes
# LIBRARIES libs
# [APPEND]
# )
#
# To implement above feature, the compile flags, include paths and link flags of all
# found packages must be registered with this macro. This macro is only necessary for people
# that do link against additional libraries which are not supported by the dune core modules.
# Call this at the end of every find module. If you are using an external find module which
# you cannot alter, call it after the call find_package().
# The APPEND parameter appends the given flags to the global list instead of prepending.
# Only use it, if you know what you are doing.
# With the VERBOSE option set, the list of flags is printed during configure.
#
#
# dune_target_enable_all_packages(TARGETS [target] ...)
#
# Adds all currently registered package flags (see dune_register_package_flags()) to the given targets.
# This function is mainly intended to help write DUNE modules that want to use dune_enable_all_packages() and
# define their own libraries, but need to be compatible with CMake < 3.1.
#
# Note: Just like dune_enable_all_packages(), this function requires CMake 2.8.12+.
#
#
# dune_register_package_flags(COMPILE_DEFINITIONS [flags]
# COMPILE_OPTIONS [options]
# INCLUDE_DIRS {includes]
# LIBRARIES [libs]
# [APPEND]
# )
#
# To correctly implement the automatic handling of external libraries, the compile flags, include paths and link
# flags of all found packages must be registered with this function. This function is only necessary for people that
# want to write their own FindFooBar CMake modules to link against additional libraries which are not supported by
# the DUNE core modules. Call this function at the end of every find module. If you are using an external FindFoo
# module which you cannot alter, call it after the call to find_package(foo).
# The APPEND parameter appends the given flags to the global list instead of prepending. Only use it, if you know
# what you are doing.
#
#
# dune_library_add_sources(module_library
# SOURCES [sources]
# )
#
# Adds the source files listed in [sources] to the module library module_library created by an earlier
# call to dune_enable_all_packages.
# Adds the source files listed in [sources] to the DUNE module library module_library created by an earlier
# call to dune_enable_all_packages() in the current DUNE module.
#
function(dune_register_package_flags)
include(CMakeParseArguments)
set(OPTIONS APPEND)
set(SINGLEARGS)
set(MULTIARGS COMPILE_DEFINITIONS INCLUDE_DIRS LIBRARIES)
set(MULTIARGS COMPILE_DEFINITIONS COMPILE_OPTIONS INCLUDE_DIRS LIBRARIES)
cmake_parse_arguments(REGISTRY "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN})
if(REGISTRY_UNPARSED_ARGUMENTS)
......@@ -73,18 +95,31 @@ function(dune_register_package_flags)
set_property(GLOBAL APPEND PROPERTY ALL_PKG_INCS "${REGISTRY_INCLUDE_DIRS}")
set_property(GLOBAL APPEND PROPERTY ALL_PKG_LIBS "${REGISTRY_LIBRARIES}")
set_property(GLOBAL APPEND PROPERTY ALL_PKG_DEFS "${REGISTRY_COMPILE_DEFINITIONS}")
set_property(GLOBAL APPEND PROPERTY ALL_PKG_OPTS "${REGISTRY_COMPILE_OPTIONS}")
else(REGISTRY_APPEND)
get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS)
get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS)
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS)
set_property(GLOBAL PROPERTY ALL_PKG_INCS "${REGISTRY_INCLUDE_DIRS}" "${all_incs}")
set_property(GLOBAL PROPERTY ALL_PKG_LIBS "${REGISTRY_LIBRARIES}" "${all_libs}")
set_property(GLOBAL PROPERTY ALL_PKG_DEFS "${REGISTRY_COMPILE_DEFINITIONS}" "${all_defs}")
set_property(GLOBAL PROPERTY ALL_PKG_OPTS "${REGISTRY_COMPILE_OPTIONS}" "${all_opts}")
endif(REGISTRY_APPEND)
endfunction(dune_register_package_flags)
macro(dune_enable_all_packages)
function(dune_enable_all_packages)
if (CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "dune_enable_all_packages() needs CMake 2.8.12+")
elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(WARNING
"You are using dune_enable_all_packages().
This requires at least CMake 2.8.12, but your Dune module only requires ${CMAKE_MINIMUM_REQUIRED_VERSION}.
Update the cmake_minimum_required() call in your main CMakeLists.txt file to get rid of this warning.")
endif()
include(CMakeParseArguments)
set(OPTIONS APPEND VERBOSE)
set(SINGLEARGS)
......@@ -115,7 +150,7 @@ macro(dune_enable_all_packages)
# handle additional compile definitions specified in dune_enable_all_packages
if(DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS)
if(DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS)
if(DUNE_ENABLE_ALL_PACKAGES_APPEND)
set_property(GLOBAL APPEND PROPERTY ALL_PKG_DEFS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_DEFINITIONS}")
else(DUNE_ENABLE_ALL_PACKAGES_APPEND)
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
......@@ -125,14 +160,37 @@ macro(dune_enable_all_packages)
# add compile definitions to all targets in module
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
foreach(def ${all_defs})
add_definitions("-D${def}")
endforeach(def in ${all_defs})
# We have to do this in a loop because add_definitions() is kind of broken: even though it is supposed
# to be *the* function for adding compile definitions, it does not prepend "-D" (as opposed to
# target_compile_definitions(), which does). Well, whatever...
foreach(_definition ${all_defs})
if(_definition)
add_definitions("-D${_definition}")
endif()
endforeach()
# verbose output of compile definitions
if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
message("Compile definitions for this project: ${all_defs}")
endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
# handle additional compile options specified in dune_enable_all_packages
if(DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS)
if(DUNE_ENABLE_ALL_PACKAGES_APPEND)
set_property(GLOBAL APPEND PROPERTY ALL_PKG_OPTS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS}")
else(DUNE_ENABLE_ALL_PACKAGES_APPEND)
get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS)
set_property(GLOBAL PROPERTY ALL_PKG_OPTS "${DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS}" "${all_opts}")
endif(DUNE_ENABLE_ALL_PACKAGES_APPEND)
endif(DUNE_ENABLE_ALL_PACKAGES_COMPILE_OPTIONS)
# add compile options to all targets in module
get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS)
add_compile_options(${all_opts})
# verbose output of compile definitions
if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
message("Compile options for this project: ${all_opts}")
endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
# handle libraries
# this is a little tricky because the libraries defined within the current module require special
# handling to avoid tripping over CMake policies CMP022 and CMP038
......@@ -178,6 +236,14 @@ Update the cmake_minimum_required() call in your main CMakeLists.txt file to get
# ...and add it to all future targets in the module
link_libraries(${module_lib})
endforeach(module_lib ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES})
# export the DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES variable to the parent scope
# this is required to make dune_library_add_sources() work (see further down)
set(
DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES
${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES}
PARENT_SCOPE
)
endif(DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES)
if(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
......@@ -185,10 +251,38 @@ Update the cmake_minimum_required() call in your main CMakeLists.txt file to get
message("Libraries for this project: ${all_libs}")
endif(DUNE_ENABLE_ALL_PACKAGES_VERBOSE)
endmacro(dune_enable_all_packages)
endfunction(dune_enable_all_packages)
function(dune_target_enable_all_packages)
if (CMAKE_VERSION VERSION_LESS 2.8.12)
message(FATAL_ERROR "dune_target_enable_all_packages() needs CMake 2.8.12+")
elseif(CMAKE_MINIMUM_REQUIRED_VERSION VERSION_LESS 2.8.12)
message(WARNING
"You are using dune_target_enable_all_packages().
This requires at least CMake 2.8.12, but your Dune module only requires ${CMAKE_MINIMUM_REQUIRED_VERSION}.
Update the cmake_minimum_required() call in your main CMakeLists.txt file to get rid of this warning.")
endif()
foreach(_target ${ARGN})
get_property(all_incs GLOBAL PROPERTY ALL_PKG_INCS)
target_include_directories(${_target} PUBLIC ${all_incs})
get_property(all_defs GLOBAL PROPERTY ALL_PKG_DEFS)
target_compile_definitions(${_target} PUBLIC ${all_defs})
get_property(all_opts GLOBAL PROPERTY ALL_PKG_OPTS)
target_compile_options(${_target} PUBLIC ${all_opts})
get_property(all_libs GLOBAL PROPERTY ALL_PKG_LIBS)
target_link_libraries(${_target} PUBLIC ${DUNE_LIBS} ${all_libs})
endforeach()
endfunction(dune_target_enable_all_packages)
macro(dune_library_add_sources lib)
function(dune_library_add_sources lib)
# This only works for CMAKE 3.1+ because target_sources() - which we use to add sources to the
# libraries after creating them - was added in that version
......@@ -207,7 +301,6 @@ macro(dune_library_add_sources lib)
"Attempt to add sources to library ${lib}, which has not been defined in dune_enable_all_packages.
List of libraries defined in dune_enable_all_packages: ${DUNE_ENABLE_ALL_PACKAGES_MODULE_LIBRARIES}")
endif()
unset(lib_defined)
include(CMakeParseArguments)
cmake_parse_arguments(DUNE_LIBRARY_ADD_SOURCES "" "" "SOURCES" ${ARGN})
......@@ -219,4 +312,4 @@ List of libraries defined in dune_enable_all_packages: ${DUNE_ENABLE_ALL_PACKAGE
foreach(source ${DUNE_LIBRARY_ADD_SOURCES_SOURCES})
target_sources(${lib} PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/${source})
endforeach()
endmacro()
endfunction()
......@@ -76,10 +76,17 @@
# library BASENAME
#
# Make CMake use rpath on OS X
if(POLICY CMP0042)
# this policy only needed for CMake older then 2.8.12
cmake_policy(SET CMP0042 NEW)
endif()
enable_language(C) # Enable C to skip CXX bindings for some tests.
include(FeatureSummary)
include(DuneEnableAllPackages)
include(OverloadCompilerFlags)
include(DuneSymlinkOrCopy)
......@@ -212,9 +219,9 @@ macro(find_dune_package module)
set(DUNE_${module}_FOUND ${${module}_FOUND})
endmacro(find_dune_package module)
macro(extract_line HEADER OUTPUT FILE_CONTENT)
set(REGEX "${HEADER}[ ]*[^\n]+")
string(REGEX MATCH ${REGEX} OUTPUT1 "${FILE_CONTENT}")
macro(extract_line HEADER OUTPUT FILE_NAME)
set(REGEX "^${HEADER}[ ]*[^\\n]+")
file(STRINGS "${FILE_NAME}" OUTPUT1 REGEX "${REGEX}")
if(OUTPUT1)
set(REGEX "^[ ]*${HEADER}[ ]*(.+)[ ]*$")
string(REGEX REPLACE ${REGEX} "\\1" ${OUTPUT} "${OUTPUT1}")
......@@ -278,10 +285,8 @@ endfunction(extract_major_minor_version version_string varname)
# add dune-common version from dune.module to config.h
# optional second argument is verbosity
macro(dune_module_information MODULE_DIR)
file(READ "${MODULE_DIR}/dune.module" DUNE_MODULE)
# find version strings
extract_line("Version:" MODULE_LINE "${DUNE_MODULE}")
extract_line("Version:" MODULE_LINE "${MODULE_DIR}/dune.module")
if(NOT MODULE_LINE MATCHES ".+")
message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a version.")
endif(NOT MODULE_LINE MATCHES ".+")
......@@ -291,19 +296,19 @@ macro(dune_module_information MODULE_DIR)
# find strings for module name, maintainer
# 1. Check for line starting with Module
extract_line("Module:" DUNE_MOD_NAME "${DUNE_MODULE}")
extract_line("Module:" DUNE_MOD_NAME "${MODULE_DIR}/dune.module")
if(NOT DUNE_MOD_NAME)
message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a module name.")
endif(NOT DUNE_MOD_NAME)
# 2. Check for line starting with Maintainer
extract_line("Maintainer:" DUNE_MAINTAINER "${DUNE_MODULE}")
extract_line("Maintainer:" DUNE_MAINTAINER "${MODULE_DIR}/dune.module")
if(NOT DUNE_MAINTAINER)
message(FATAL_ERROR "${MODULE_DIR}/dune.module is missing a maintainer.")
endif(NOT DUNE_MAINTAINER)
# 3. Check for line starting with Depends
extract_line("Depends:" ${DUNE_MOD_NAME}_DEPENDS "${DUNE_MODULE}")
extract_line("Depends:" ${DUNE_MOD_NAME}_DEPENDS "${MODULE_DIR}/dune.module")
if(${DUNE_MOD_NAME}_DEPENDS)
split_module_version(${${DUNE_MOD_NAME}_DEPENDS} ${DUNE_MOD_NAME}_DEPENDS_MODULE ${DUNE_MOD_NAME}_DEPENDS_VERSION)
foreach(_mod ${${DUNE_MOD_NAME}_DEPENDS})
......@@ -316,7 +321,7 @@ macro(dune_module_information MODULE_DIR)
endif(${DUNE_MOD_NAME}_DEPENDS)
# 4. Check for line starting with Suggests
extract_line("Suggests:" ${DUNE_MOD_NAME}_SUGGESTS "${DUNE_MODULE}")
extract_line("Suggests:" ${DUNE_MOD_NAME}_SUGGESTS "${MODULE_DIR}/dune.module")
if(${DUNE_MOD_NAME}_SUGGESTS)
split_module_version(${${DUNE_MOD_NAME}_SUGGESTS} ${DUNE_MOD_NAME}_SUGGESTS_MODULE ${DUNE_MOD_NAME}_SUGGESTS_VERSION)
convert_deps_to_list(${DUNE_MOD_NAME}_SUGGESTS)
......@@ -417,9 +422,9 @@ macro(dune_create_dependency_leafs depends depends_versions suggests suggests_ve
endmacro(dune_create_dependency_leafs)
macro(dune_create_dependency_tree)
if(${dune-common_MODULE_PATH})
list(REMOVE_ITEM CMAKE_MODULE_PATH ${dune-common_MODULE_PATH})
endif(${dune-common_MODULE_PATH})
if(dune-common_MODULE_PATH)
list(REMOVE_ITEM CMAKE_MODULE_PATH "${dune-common_MODULE_PATH}")
endif(dune-common_MODULE_PATH)
list(FIND CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/modules start)
set(ALL_DEPENDENCIES "")
if(${ProjectName}_DEPENDS_MODULE OR ${ProjectName}_SUGGESTS_MODULE)
......@@ -546,6 +551,9 @@ macro(dune_project)
message(FATAL_ERROR "You need to specify an absolute path to your compiler instead of just the compiler name. cmake >= 3.0 fixes this issue.")
endif()
# check if CXX flag overloading has been enabled (see OverloadCompilerFlags.cmake)
initialize_compiler_script()
# extract information from dune.module
dune_module_information(${CMAKE_SOURCE_DIR})
set(ProjectName "${DUNE_MOD_NAME}")
......@@ -556,6 +564,14 @@ macro(dune_project)
set(ProjectVersionRevision "${DUNE_VERSION_REVISION}")
set(ProjectMaintainerEmail "${DUNE_MAINTAINER}")
# check whether this module has been explicitly disabled through the cmake flags.
# If so, stop the build. This is necessary because dunecontrol does not parse
# the given CMake flags for a disabled Dune modules.
if(CMAKE_DISABLE_FIND_PACKAGE_${ProjectName})
message("Module ${ProjectName} has been explicitly disabled through the cmake flags. Skipping build.")
return()
endif()
define_property(GLOBAL PROPERTY DUNE_MODULE_LIBRARIES
BRIEF_DOCS "List of libraries of the module. DO NOT EDIT!"
FULL_DOCS "List of libraries of the module. Used to generate CMake's package configuration files. DO NOT EDIT!")
......@@ -638,6 +654,8 @@ macro(dune_project)
# activate testing the DUNE way
include(DuneTests)
# enable this way of testing by default
set(DUNE_TEST_MAGIC ON)
# activate pkg-config
include(DunePkgConfig)
......@@ -669,13 +687,6 @@ macro(dune_project)
include(Headercheck)
setup_headercheck()
# check whether the user wants to append compile flags upon calling make
if(ALLOW_EXTRA_CXXFLAGS AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*"))
file(WRITE ${CMAKE_BINARY_DIR}/compiler.sh
"#!/bin/bash\nif [ -n \"$VERBOSE\" ] ; then\necho 1>&2 \"Additional flags: \$EXTRA_CXXFLAGS\"\nfi\nexec ${CMAKE_CXX_COMPILER} \"\$@\" \$EXTRA_CXXFLAGS")
exec_program(chmod ARGS "+x ${CMAKE_BINARY_DIR}/compiler.sh")
set(CMAKE_CXX_COMPILER ${CMAKE_BINARY_DIR}/compiler.sh)
endif()
endmacro(dune_project)
# create a new config.h file and overwrite the existing one
......@@ -873,11 +884,18 @@ endif()
configure_file(config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
endif("${ARGC}" EQUAL "1")
test_dep()
# add dependiencies to target "test"
if(DUNE_TEST_MAGIC)
test_dep()
endif()
include(CPack)
feature_summary(WHAT ALL)
# check if CXX flag overloading has been enabled
# and write compiler script (see OverloadCompilerFlags.cmake)
finalize_compiler_script()
endmacro(finalize_dune_project)
macro(target_link_dune_default_libraries _target)
......
......@@ -27,16 +27,16 @@
# in the source tree. This file will be copied
# to the build tree.
#
# dune_symlink_to_source_tree()
# dune_symlink_to_source_tree([NAME name])
#
# add a symlink called src_dir to all directories in the build tree.
# add a symlink called NAME to all directories in the build tree (defaults to src_dir).
# That symlink points to the corresponding directory in the source tree.
# Call the macro from the toplevel CMakeLists.txt file of your project.
# You can also call it from some other directory, creating only symlinks
# in that directory and all directories below. A warning is issued on
# Windows systems.
#
# dune_symlink_to_source_files(files)
# dune_symlink_to_source_files(FILES files)
#
# add symlinks to the build tree, which point to files in the source tree.
# Foreach file given in "files", a symlink of that name is created in the
......@@ -63,7 +63,14 @@ macro(dune_add_copy_dependency target file_name)
add_dependencies(${target} "${target}_copy_${file_name}")
endmacro(dune_add_copy_dependency)
macro(dune_symlink_to_source_tree)
function(dune_symlink_to_source_tree)
# parse arguments
include(CMakeParseArguments)
cmake_parse_arguments(ARG "" "NAME" "" ${ARGN})
if(NOT ARG_NAME)
set(ARG_NAME "src_dir")
endif()
# check for Windows to issue a warning
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING)
......@@ -78,15 +85,22 @@ macro(dune_symlink_to_source_tree)
foreach(f ${files})
get_filename_component(dir ${f} DIRECTORY)
if(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/${dir}" "${CMAKE_BINARY_DIR}/${dir}/src_dir")
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_SOURCE_DIR}/${dir}" "${CMAKE_BINARY_DIR}/${dir}/${ARG_NAME}")
endif(NOT "${CMAKE_SOURCE_DIR}/${dir}" MATCHES "${CMAKE_BINARY_DIR}/*")
endforeach()
endif()
endmacro(dune_symlink_to_source_tree)
endfunction(dune_symlink_to_source_tree)
function(dune_symlink_to_source_files)
# parse arguments
include(CMakeParseArguments)
cmake_parse_arguments(ARG "" "" "FILES" ${ARGN})
if(ARG_UNPARSED_ARGUMENTS)
message(WARNING "You are using dune_symlink_to_source_files without named arguments (or have typos in your named arguments)!")
endif()
macro(dune_symlink_to_source_files files)
# create symlinks for all given files
foreach(f ${files})
foreach(f ${ARG_FILES})
# check for Windows to issue a warning
if(${CMAKE_SYSTEM_NAME} STREQUAL "Windows")
if(NOT DEFINED DUNE_WINDOWS_SYMLINK_WARNING)
......@@ -99,4 +113,4 @@ macro(dune_symlink_to_source_files files)
execute_process(COMMAND ${CMAKE_COMMAND} "-E" "create_symlink" "${CMAKE_CURRENT_SOURCE_DIR}/${f}" "${CMAKE_CURRENT_BINARY_DIR}/${f}")
endif()
endforeach()
endmacro(dune_symlink_to_source_files files)
endfunction(dune_symlink_to_source_files)
......@@ -47,8 +47,10 @@ endmacro(get_directory_test_target _target _dir)
# E.g. for dune/istl/test the target will be dune_istl_test.
#
macro(add_directory_test_target _target)
get_directory_test_target(${_target} "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(${${_target}})
dune_common_script_dir(SCRIPT_DIR)
configure_file(${SCRIPT_DIR}/BuildTests.cmake.in BuildTests.cmake @ONLY)
if(DUNE_TEST_MAGIC)
get_directory_test_target(${_target} "${CMAKE_CURRENT_BINARY_DIR}")
add_custom_target(${${_target}})
dune_common_script_dir(SCRIPT_DIR)
configure_file(${SCRIPT_DIR}/BuildTests.cmake.in BuildTests.cmake @ONLY)
endif()
endmacro(add_directory_test_target)
......@@ -7,7 +7,7 @@
#
include(DuneBoost)
if(BOOST_FOUND)
if(HAVE_DUNE_BOOST)
message(STATUS "Checking whether the Boost::FUSION library is available.")
check_cxx_source_compiles("
\#include <boost/fusion/container.hpp>
......@@ -18,6 +18,6 @@ int main(){
if(HAVE_BOOST_FUSION)
message(STATUS "Boost::FUSION is available")
endif(HAVE_BOOST_FUSION)
else(BOOST_FOUND)
else()
message(STATUS "Skipping check for Boost::FUSION as Boost is not available.")
endif(BOOST_FOUND)
endif()
......@@ -21,7 +21,7 @@
include(DuneMPI)
macro(_search_pt_lib libvar libname doc)
find_library(${libvar} ${libname}
PATHS ${PTSCOTCH_ROOT} PATH_SUFFIXES ${PATH_SUFFIXES}
PATHS ${PTSCOTCH_ROOT} ${PTSCOTCH_ROOT}/lib PATH_SUFFIXES ${PATH_SUFFIXES}
NO_DEFAULT_PATH
DOC "${doc}")
find_library(${libvar} ${libname})
......@@ -39,7 +39,7 @@ set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${MPI_DUNE_INCLUDE_PATH})
set(CMAKE_REQUIRED_FLAGS "${CMAKE_REQUIRED_FLAGS} ${MPI_DUNE_COMPILE_FLAGS}")
find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h
PATHS ${PTSCOTCH_ROOT}
PATHS ${PTSCOTCH_ROOT} ${PTSCOTCH_ROOT}/include
PATH_SUFFIXES ${PATH_SUFFIXES}
NO_DEFAULT_PATH
DOC "Include directory of PT-Scotch")
......@@ -47,6 +47,7 @@ find_path(PTSCOTCH_INCLUDE_DIR ptscotch.h
PATH_SUFFIXES ${PATH_SUFFIXES})
_search_pt_lib(PTSCOTCH_LIBRARY ptscotch "The main PT-Scotch library.")
_search_pt_lib(SCOTCH_LIBRARY scotch "The Scotch library.")
_search_pt_lib(PTSCOTCHERR_LIBRARY ptscotcherr "The PT-Scotch error library.")
# behave like a CMake module is supposed to behave
......@@ -56,6 +57,7 @@ find_package_handle_standard_args(
DEFAULT_MSG
PTSCOTCH_INCLUDE_DIR
PTSCOTCH_LIBRARY
SCOTCH_LIBRARY
PTSCOTCHERR_LIBRARY
)
#restore old values
......@@ -63,7 +65,7 @@ cmake_pop_check_state()
if(PTSCOTCH_FOUND)
set(PTSCOTCH_INCLUDE_DIRS ${PTSCOTCH_INCLUDE_DIR})
set(PTSCOTCH_LIBRARIES ${PTSCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY} ${MPI_DUNE_LIBRARIES}
set(PTSCOTCH_LIBRARIES ${PTSCOTCH_LIBRARY} ${SCOTCH_LIBRARY} ${PTSCOTCHERR_LIBRARY} ${MPI_DUNE_LIBRARIES}
CACHE FILEPATH "All libraries needed to link programs using PT-Scotch")
set(PTSCOCH_LINK_FLAGS "${DUNE_MPI_LINK_FLAGS}"
CACHE STRING "PT-Scotch link flags")
......
# Module that checks whether SuiteSparse is available.
#
# Synopsis:
# find_package(SuiteSparse COMPONENTS component1 [component2 ...])
#
# Components are:
# amd, btf, camd, ccolamd, cholmod, colamd, cxsparse,
# klu, ldl, RBio, spqr, umfpack
#
# Variables used by this module which you may want to set:
# SUITESPARSE_ROOT Path list to search for SuiteSparse
#
# Sets the following result variables:
#
# SUITESPARSE_FOUND Whether SuiteSparse was found and usable in the desired setting
# SUITESPARSE_INCLUDE_DIRS Path to the SuiteSparse include dirs
# SUITESPARSE_LIBRARIES Name of the SuiteSparse libraries
# SUITESPARSE_<COMPONENT>_FOUND Whether <COMPONENT> was found as part of SuiteSparse
find_package(BLAS QUIET REQUIRED)
if(NOT BLAS_FOUND)
message(WARNING "SuiteSparse requires BLAS which was not found, skipping the test.")
return()
endif()
# look for desired componenents
set(SUITESPARSE_COMPONENTS ${SuiteSparse_FIND_COMPONENTS})
# resolve inter-component dependencies
list(FIND SUITESPARSE_COMPONENTS "umfpack" WILL_USE_UMFPACK)
if(NOT WILL_USE_UMFPACK EQUAL -1)
list(APPEND SUITESPARSE_COMPONENTS amd cholmod)
endif()
list(FIND SUITESPARSE_COMPONENTS "cholmod" WILL_USE_CHOLMOD)
if(NOT WILL_USE_CHOLMOD EQUAL -1)
list(APPEND SUITESPARSE_COMPONENTS amd camd colamd ccolamd)
endif()
if(SUITESPARSE_COMPONENTS)
list(REMOVE_DUPLICATES SUITESPARSE_COMPONENTS)
endif()
set(ready TRUE)
foreach(modname ${SUITESPARSE_COMPONENTS})
dune_module_to_uppercase(MODNAME ${modname})
if(NOT SUITESPARSE_${MODNAME}_FOUND)
set(ready FALSE)
endif()
endforeach()
if(ready)
return()
endif()
# find SuiteSparse config:
# look for library at positions given by the user
find_library(SUITESPARSE_CONFIG_LIB
NAMES "suitesparseconfig"
PATHS ${SUITESPARSE_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "Lib"
NO_DEFAULT_PATH
)
# now also include the deafult paths
find_library(SUITESPARSE_CONFIG_LIB
NAMES "suitesparseconfig"
PATH_SUFFIXES "lib" "lib32" "lib64" "Lib"
)
#look for header files at positions given by the user
find_path(SUITESPARSE_INCLUDE_DIR
NAMES "SuiteSparse_config.h"
PATHS ${SUITESPARSE_ROOT}
PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(SUITESPARSE_INCLUDE_DIR
NAMES "SuiteSparse_config.h"
PATHS ${SUITESPARSE_ROOT}
PATH_SUFFIXES "SuiteSparse_config" "SuiteSparse_config/include" "suitesparse" "include" "src" "SuiteSparse_config/Include"
)
foreach(modname ${SUITESPARSE_COMPONENTS})
dune_module_to_uppercase(MODNAME ${modname})
#look for library at positions given by the user
find_library(${MODNAME}_LIBRARY
NAMES "${modname}"
PATHS ${SUITESPARSE_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "${MODNAME}" "${MODNAME}/Lib"
NO_DEFAULT_PATH
)
#now also include the deafult paths
find_library(${MODNAME}_LIBRARY
NAMES "${modname}"
PATH_SUFFIXES "lib" "lib32" "lib64" "${MODNAME}" "${MODNAME}/Lib"
)
#look for header files at positions given by the user
find_path(${MODNAME}_INCLUDE_DIR
NAMES "${modname}.h"
PATHS ${SUITESPARSE_ROOT}
PATH_SUFFIXES "${modname}" "include/${modname}" "suitesparse" "include" "src" "${MODNAME}" "${MODNAME}/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(${MODNAME}_INCLUDE_DIR
NAMES "${modname}.h"
PATH_SUFFIXES "${modname}" "include/${modname}" "suitesparse" "include" "${MODNAME}" "${MODNAME}/Include"
)
endforeach()
# resolve inter-modular dependencies
# CHOLMOD requires AMD, COLAMD; CAMD and CCOLAMD are optional
if(CHOLMOD_LIBRARY)
if(NOT (AMD_LIBRARY AND COLAMD_LIBRARY))
message(WARNING "CHOLMOD requires AMD and COLAMD which were not found, skipping the test.")
return()
endif()
list(APPEND CHOLMOD_LIBRARY ${AMD_LIBRARY} ${COLAMD_LIBRARY})
if(CAMD_LIBRARY)
list(APPEND CHOLMOD_LIBRARY ${CAMD_LIBRARY})
endif()
if(CCOLAMD_LIBRARY)
list(APPEND CHOLMOD_LIBRARY ${CCOLAMD_LIBRARY})
endif()
list(REVERSE CHOLMOD_LIBRARY)
# remove duplicates
list(REMOVE_DUPLICATES CHOLMOD_LIBRARY)
list(REVERSE CHOLMOD_LIBRARY)
endif()
# UMFPack requires AMD, can depend on CHOLMOD
if(UMFPACK_LIBRARY)
# check wether cholmod was found
if(CHOLMOD_LIBRARY)
list(APPEND UMFPACK_LIBRARY ${CHOLMOD_LIBRARY})
else()
list(APPEND UMFPACK_LIBRARY ${AMD_LIBRARY})
endif()
list(REVERSE UMFPACK_LIBRARY)
# remove duplicates
list(REMOVE_DUPLICATES UMFPACK_LIBRARY)
list(REVERSE UMFPACK_LIBRARY)
endif()
set(SUITESPARSE_FOUND TRUE)
# check wether everything was found
foreach(modname ${SUITESPARSE_COMPONENTS})
dune_module_to_uppercase(MODNAME ${modname})
set(SUITESPARSE_${MODNAME}_FOUND TRUE)
if(${MODNAME}_LIBRARY AND ${MODNAME}_INCLUDE_DIR)
list(APPEND SUITESPARSE_INCLUDE_DIR "${${MODNAME}_INCLUDE_DIR}")
list(APPEND SUITESPARSE_LIBRARY "${${MODNAME}_LIBRARY}")
else()
set(SUITESPARSE_FOUND FALSE)
endif()
set(HAVE_SUITESPARSE_${MODNAME} 1)
mark_as_advanced(HAVE_SUITESPARSE_${MODNAME})
mark_as_advanced(SUITESPARSE_${MODNAME}_FOUND)
endforeach()
list(APPEND SUITESPARSE_LIBRARY ${SUITESPARSE_CONFIG_LIB})
# make them unique
if(SUITESPARSE_INCLUDE_DIR)
list(REMOVE_DUPLICATES SUITESPARSE_INCLUDE_DIR)
endif()
if(SUITESPARSE_LIBRARY)
list(REVERSE SUITESPARSE_LIBRARY)
list(REMOVE_DUPLICATES SUITESPARSE_LIBRARY)
list(REVERSE SUITESPARSE_LIBRARY)
endif()
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
"SuiteSparse"
DEFAULT_MSG
SUITESPARSE_INCLUDE_DIR
SUITESPARSE_LIBRARY
)
mark_as_advanced(SUITESPARSE_INCLUDE_DIR SUITESPARSE_LIBRARY)
# if both headers and library are found, store results
if(SUITESPARSE_FOUND)
set(SUITESPARSE_LIBRARIES ${SUITESPARSE_LIBRARY})
set(SUITESPARSE_INCLUDE_DIRS ${SUITESPARSE_INCLUDE_DIR})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of SuiteSparse succeded:\n"
"Include directory: ${SUITESPARSE_INCLUDE_DIRS}\n"
"Library directory: ${SUITESPARSE_LIBRARIES}\n\n")
set(SUITESPARSE_COMPILER_FLAGS)
foreach(dir ${SUITESPARSE_INCLUDE_DIRS})
set(SUITESPARSE_COMPILER_FLAGS "${SUITESPARSE_COMPILER_FLAGS} -I${dir}/")
endforeach()
set(SUITESPARSE_DUNE_COMPILE_FLAGS ${SUITESPARSE_COMPILER_FLAGS}
CACHE STRING "Compile Flags used by DUNE when compiling with SuiteSparse programs")
set(SUITESPARSE_DUNE_LIBRARIES ${BLAS_LIBRARIES} ${SUITESPARSE_LIBRARIES}
CACHE STRING "Libraries used by DUNE when linking SuiteSparse programs")
else()
# log errornous result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKES_FILES_DIRECTORY}/CMakeError.log
"Determing location of SuiteSparse failed:\n"
"Include directory: ${SUITESPARSE_INCLUDE_DIRS}\n"
"Library directory: ${SUITESPARSE_LIBRARIES}\n\n")
endif()
#set HAVE_SUITESPARSE for config.h
set(HAVE_SUITESPARSE ${SUITESPARSE_FOUND})
# register all SuiteSparse related flags
if(SUITESPARSE_FOUND)
dune_register_package_flags(
COMPILE_DEFINITION "ENABLE_SUITESPARSE=1"
LIBRARIES "${SUITESPARSE_LIBRARIES}"
INCLUDE_DIRS "${SUITESPARSE_INCLUDE_DIRS}")
endif()
......@@ -10,55 +10,15 @@
# UMFPACK_LIBRARIES Name of the UMFPack libraries
#
find_package(BLAS QUIET REQUIRED)
if(NOT BLAS_FOUND)
message(WARNING "UMFPack requires BLAS which was not found, skipping the test.")
return()
endif()
find_library(AMD_LIBRARY
NAMES "amd"
PATHS ${UMFPACK_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "AMD" "AMD/Lib"
NO_DEFAULT_PATH
)
include( FindSuiteSparse )
find_package( SuiteSparse COMPONENTS umfpack )
find_library(AMD_LIBRARY
NAMES "amd"
PATH_SUFFIXES "lib" "lib32" "lib64" "AMD" "AMD/Lib"
)
if(NOT AMD_LIBRARY)
message(WARNING "UMFPack requires AMD (approximate minimum degree ordering) which was not found, skipping the test.")
return()
if( SUITESPARSE_FOUND )
set( UMFPACK_FOUND TRUE )
set( UMFPACK_INCLUDE_DIR ${SUITESPARSE_INCLUDE_DIR} )
set( UMFPACK_LIBRARY ${SUITESPARSE_LIBRARY} )
endif()
#look for header files at positions given by the user
find_path(UMFPACK_INCLUDE_DIR
NAMES "umfpack.h"
PATHS ${UMFPACK_ROOT}
PATH_SUFFIXES "umfpack" "include/umfpack" "suitesparse" "include" "src" "UMFPACK" "UMFPACK/Include"
NO_DEFAULT_PATH
)
#now also look for default paths
find_path(UMFPACK_INCLUDE_DIR
NAMES "umfpack.h"
PATH_SUFFIXES "umfpack" "include/umfpack" "suitesparse" "include" "UMFPACK" "UMFPACK/Include"
)
#look for library at positions given by the user
find_library(UMFPACK_LIBRARY
NAMES "umfpack"
PATHS ${UMFPACK_ROOT}
PATH_SUFFIXES "lib" "lib32" "lib64" "UMFPACK" "UMFPACK/Lib"
NO_DEFAULT_PATH
)
#now also include the deafult paths
find_library(UMFPACK_LIBRARY
NAMES "umfpack"
PATH_SUFFIXES "lib" "lib32" "lib64" "UMFPACK" "UMFPACK/Lib"
)
# behave like a CMake module is supposed to behave
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(
......@@ -72,14 +32,16 @@ mark_as_advanced(UMFPACK_INCLUDE_DIR UMFPACK_LIBRARY)
# if both headers and library are found, store results
if(UMFPACK_FOUND)
set(UMFPACK_INCLUDE_DIRS ${UMFPACK_INCLUDE_DIR})
foreach( dir ${UMFPACK_INCLUDE_DIR} )
list( APPEND UMFPACK_INCLUDE_FLAGS "-I${dir}/ " )
endforeach()
set(UMFPACK_LIBRARIES ${UMFPACK_LIBRARY})
# log result
file(APPEND ${CMAKE_BINARY_DIR}${CMAKE_FILES_DIRECTORY}/CMakeOutput.log
"Determining location of UMFPack succeded:\n"
"Include directory: ${UMFPACK_INCLUDE_DIRS}\n"
"Library directory: ${UMFPACK_LIBRARIES}\n\n")
set(UMFPACK_DUNE_COMPILE_FLAGS "-I${UMFPACK_INCLUDE_DIRS}"
set(UMFPACK_DUNE_COMPILE_FLAGS "${UMFPACK_INCLUDE_FLAGS}"
CACHE STRING "Compile Flags used by DUNE when compiling with UMFPack programs")
set(UMFPACK_DUNE_LIBRARIES ${UMFPACK_LIBRARIES} ${BLAS_LIBRARIES} ${AMD_LIBRARY}
CACHE STRING "Libraries used by DUNE when linking UMFPack programs")
......@@ -93,6 +55,7 @@ endif(UMFPACK_FOUND)
#set HAVE_UMFPACK for config.h
set(HAVE_UMFPACK ${UMFPACK_FOUND})
set(HAVE_SUITESPARSE_UMFPACK ${UMFPACK_FOUND})
# register all umfpack related flags
if(UMFPACK_FOUND)
......
......@@ -30,6 +30,7 @@ MODULES = \
FindUMFPack.cmake \
Headercheck.cmake \
LanguageSupport.cmake \
OverloadCompilerFlags.cmake \
UseInkscape.cmake \
UseLATEX.cmake
......
# check whether the user wants to overload compile flags upon calling make
#
# Provides the following macros:
#
# initialize_compiler_script() : needs to be called before further flags are added to CMAKE_CXX_FLAGS
# finalize_compiler_script() : needs to be called at the end of the cmake macros, e.g. in finalize_dune_project
#
# By default this feature is disabled. Use -DALLOW_CXXFLAGS_OVERWRITE=ON to activate.
# Then the following is possible:
#
# make CXXFLAGS="your flags" GRIDTYPE="grid type"
#
# GRIDTYPE can be anything defined in config.h via the dune_define_gridtype macro from dune-grid.
# Furthermore any CPP variable of the form -DVAR=VALUE can be overloaded on the command line.
#
# Note: If you don't know what this is or what it's good for, don't use it.
#
option(ALLOW_CXXFLAGS_OVERWRITE OFF)
# check whether the user wants to append compile flags upon calling make
if(ALLOW_EXTRA_CXXFLAGS AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*"))
message("ALLOW_EXTRA_CXXFLAGS is deprecated, please use -DALLOW_CXXFLAGS_OVERWRITE=ON")
set(ALLOW_CXXFLAGS_OVERWRITE ON)
endif()
macro(find_extended_unix_commands)
include(FindUnixCommands)
find_program (GREP_PROGRAM grep)
if(NOT GREP_PROGRAM)
message( SEND_ERROR "grep not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
find_program (SED_PROGRAM sed)
if(NOT SED_PROGRAM)
message( SEND_ERROR "sed not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
find_program (CUT_PROGRAM cut)
if(NOT CUT_PROGRAM)
message( SEND_ERROR "cut not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
find_program (ENV_PROGRAM env)
if(NOT ENV_PROGRAM)
message( SEND_ERROR "env not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
find_program (ECHO_PROGRAM echo)
if(NOT ECHO_PROGRAM)
message( SEND_ERROR "echo not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
find_program (CHMOD_PROGRAM chmod)
if(NOT CHMOD_PROGRAM)
message( SEND_ERROR "chmod not found, please disable ALLOW_CXXFLAGS_OVERWRITE")
endif()
mark_as_advanced(GREP_PROGRAM)
mark_as_advanced(SED_PROGRAM)
mark_as_advanced(CUT_PROGRAM)
mark_as_advanced(ENV_PROGRAM)
mark_as_advanced(ECHO_PROGRAM)
mark_as_advanced(CHMOD_PROGRAM)
endmacro(find_extended_unix_commands)
# init compiler script and store CXX flags
macro(initialize_compiler_script)
if(ALLOW_CXXFLAGS_OVERWRITE AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*"))
# check for unix commands necessary
find_extended_unix_commands()
# set CXXFLAGS as environment variable
set( DEFAULT_CXXFLAGS ${CMAKE_CXX_FLAGS})
set( CMAKE_CXX_FLAGS "" )
set( DEFAULT_CXX_COMPILER ${CMAKE_CXX_COMPILER} )
set( COMPILER_SCRIPT_FILE "#!${BASH}\nexec ${CMAKE_CXX_COMPILER} \"\$@\"")
file(WRITE ${CMAKE_BINARY_DIR}/compiler.sh "${COMPILER_SCRIPT_FILE}")
exec_program(${CHMOD_PROGRAM} ARGS "+x ${CMAKE_BINARY_DIR}/compiler.sh")
set(CMAKE_CXX_COMPILER ${CMAKE_BINARY_DIR}/compiler.sh)
endif()
endmacro()
# finalize compiler script and write it
macro(finalize_compiler_script)
if(ALLOW_CXXFLAGS_OVERWRITE AND (${CMAKE_GENERATOR} MATCHES ".*Unix Makefiles.*"))
set( COMPILER_SCRIPT_FILE "#!${BASH}\nSED=${SED_PROGRAM}\nGREP=${GREP_PROGRAM}")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nCUT=${CUT_PROGRAM}\nENV=${ENV_PROGRAM}\nECHO=${ECHO_PROGRAM}")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n# store flags\nFLAGS=\"\$@\"")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nMAKE_EXECUTABLE_NEW=0\n")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$CXXFLAGS\" == \"\" ]; then\n # default CXX flags\n CXXFLAGS=\"${DEFAULT_CXXFLAGS}\"\nfi\n")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nGRIDS=\nCONFIG_H=${CMAKE_BINARY_DIR}/config.h")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nif [ \"\$GRIDTYPE\" != \"\" ]; then")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n GRIDS=`\$GREP \"defined USED_[A-Z_]*_GRIDTYPE\" \$CONFIG_H | \$SED 's/\\(.*defined USED\\_\\)\\(.*\\)\\(\\_GRIDTYPE*\\)/\\2/g'`\nfi\n")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nOLDFLAGS=\$FLAGS\nFLAGS=")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nfor FLAG in \$OLDFLAGS; do")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n NEWFLAG=\$FLAG\n VARNAME=`\$ECHO \$FLAG | \$GREP \"\\-D\" | \$SED 's/-D//g'`")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n for GRID in \$GRIDS; do\n if [ \"\$VARNAME\" == \"\$GRID\" ]; then\n NEWFLAG=\"-D\$GRIDTYPE\"\n break\n fi\n done")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n VARNAME=`\$ECHO \$VARNAME | \$GREP \"=\" | \$CUT -d \"=\" -f 1`")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n if [ \"\$VARNAME\" != \"\" ]; then\n VAR=`\$ENV | \$GREP \$VARNAME`\n if [ \"\$VAR\" != \"\" ]; then")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n # add variable from environment to flags list\n NEWFLAG=\"-D\$VARNAME=\${!VARNAME}\"\n fi\n fi")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n FLAGS=\"\$FLAGS \$NEWFLAG\"\ndone")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\n\$ECHO \"${DEFAULT_CXX_COMPILER} \$CXXFLAGS \$FLAGS\"")
set( COMPILER_SCRIPT_FILE "${COMPILER_SCRIPT_FILE}\nexec ${DEFAULT_CXX_COMPILER} \$CXXFLAGS \$FLAGS")
file(WRITE ${CMAKE_BINARY_DIR}/compiler.sh "${COMPILER_SCRIPT_FILE}")
endif()
endmacro()
......@@ -125,6 +125,9 @@
/* Define to if the UMFPack library is available */
#cmakedefine HAVE_UMFPACK ENABLE_UMFPACK
/* Define to 1 if the SuiteSparse library is available */
#cmakedefine HAVE_SUITESPARSE ENABLE_SUITESPARSE
/* Define to ENABLE_PARMETIS if you have the Parmetis library.
This is only true if MPI was found
by configure _and_ if the application uses the PARMETIS_CPPFLAGS */
......
dune_add_latex_document(buildsystem.tex FATHER_TARGET doc DEFAULT_PDF INPUTS ../Makefile.am ../../configure.ac ../example.opts)
create_doc_install(${CMAKE_CURRENT_BINARY_DIR}/buildsystem.pdf ${CMAKE_INSTALL_DOCDIR}/buildsystem)
dune_add_latex_document(cmakefaq.tex FATHER_TARGET doc DEFAULT_PDF)
create_doc_install(${CMAKE_CURRENT_BINARY_DIR}/cmakefaq.pdf ${CMAKE_INSTALL_DOCDIR}/buildsystem)