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
# Locate Intel Threading Building Blocks include paths and libraries
#
# .. cmake_module::
#
# TBB is a little special because there are three different ways to provide it:
#
# * It can be installed using a package manager and just be available on the system include
# and library paths.
# * It can be compiled from source. The package doesn't really provide an installation script
# for this, but expects you to source an environment file called :code:`tbbvars.sh` that updates the
# required variables like :code:`CPATH` etc.
# * TBB is shipped as part of the Intel compilers. This bundled version can be enabled by adding
# :code:`-tbb` to the compiler flags.
#
# This module can find all three types of installations. They are looked for in the following
# order of preference: :code:`tbbvars.sh` file (for a custom installation), system paths and finally
# the built-in version if an Intel compiler is present.
#
# .. note::
# If you provide a tbbvars.sh script (via the CMake variable :ref:`TBB_VARS_SH`), this module will
# not find any libraries installed in the system path! This is on purpose to avoid
# accidental fallbacks.
#
# If the option :ref:`TBB_DEBUG` is set to ON, the module will look for the debug version of TBB. Note that
# this does not work for the built-in library of the Intel Compiler due to linking problems. You can
# however provide the module with the tbbvars.sh from that built-in installation (usually in the
# subdirectory :code:`tbb/` of the Intel compiler root path), which will fix that problem.
#
# Variables used by this module which you may want to set:
#
# :ref:`TBB_VARS_SH`
# Path to the :code:`tbbvars.sh` script
#
# :ref:`TBB_INCLUDE_DIR`
# Path to the include directory with the TBB headers
#
# :ref:`TBB_LIBRARY_DIR`
# Path to the library directory with the TBB libraries
#
# :ref:`TBB_DEBUG`
# Option that turns on TBB debugging
#
# This module supports additional components of TBB that can be listed in the :ref:`find_package` call:
#
# :code:`cpf`
# Use comunity preview edition (links to :code:`libtbb_preview` instead of :code:`libtbb`). cpf
# is not available for the built-in version of the Intel Compiler, but see the note
# on debug mode above for a fix.
#
# :code:`allocator`
# Use TBB's scalable allocator (links to libtbbmalloc).
#
#
# This module sets the following variables:
#
# :code:`TBB_FOUND`
# True if TBB was found and is usable
#
# :code:`TBB_cpf_FOUND`
# True if community preview edition was found and is usable
#
# :code:`TBB_allocator_FOUND`
# True if scalable allocator library was found and is usable
#
# :code:`TBB_INCLUDE_DIRS`
# Path to the TBB include dirs. This variable is empty if the
# internal TBB version of an Intel compiler is in use
#
# :code:`TBB_LIBRARIES`
# List of the TBB libraries that a target must be linked to
#
# :code:`TBB_COMPILE_DEFINITIONS`
# Required compile definitions to use TBB
#
# :code:`TBB_COMPILE_OPTIONS`
# Required compile options to use TBB
#
# :code:`TBB_INTEL_COMPILER_INTERNAL_TBB`
# True if internal TBB version of Intel compiler is in use
#
# In addition, TBB is automatically registered with the :ref:`dune_enable_all_packages` facility. If you
# don't want to use that feature, the module also provides the function :ref:`add_dune_tbb_flags`.
#
# .. cmake_function:: add_dune_tbb_flags
#
# .. cmake_param:: targets
# :positional:
# :single:
# :required:
#
# Adds all flags required to use TBB to the listed targets
#
# .. cmake_variable:: TBB_VARS_SH
#
# May be set to have the :ref:`FindTBB` module look for a :code:`tbbvars.sh` script
#
# .. cmake_variable:: TBB_INCLUDE_DIR
#
# May be set to have the :ref:`FindTBB` module look for TBB includes in custom locations.
#
# .. cmake_variable:: TBB_LIBRARY_DIR
#
# May be set to have the :ref:`FindTBB` module look for TBB libraries in custom locations.
#
# .. cmake_variable:: TBB_DEBUG
#
# May be set to have the :ref:`FindTBB` module look for debug TBB libraries.
#
#[=======================================================================[.rst:
FindTBB
-------
option(
TBB_DEBUG
"Turn on TBB debugging (modifies compiler flags and links against debug version of libraries)"
)
Finds the Threading Building Blocks (TBB) library.
# source for our little test program. We have to compile this multiple times, so
# store it in a variable for DRY and better readability
set(tbb_compile_source "
#include <tbb/tbb.h>
#include <numeric>
This is a fallback implementation in case the TBB library does not provide
itself a corresponding TBBConfig.cmake file.
int main()
{
int x[10] = {0};
tbb::parallel_for(0,10,[&](int i){ x[i] = i; });
return !(std::accumulate(x,x+10,0) == (9*10)/2);
}
")
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
# Function to parse a tbbvars.sh file and extract include and library paths.
# This function relies on the bash shell to source the tbbvars.sh file
function(parse_tbb_vars_sh)
message(STATUS "Taking TBB location from ${TBB_VARS_SH}")
find_package(UnixCommands)
set(tbb_vars_works FALSE)
execute_process(
COMMAND ${BASH} -c ". ${TBB_VARS_SH} > /dev/null"
RESULT_VARIABLE shell_result
OUTPUT_VARIABLE shell_out
)
if (${shell_result} EQUAL 0)
set(tbb_vars_opt "")
set(tbb_vars_works TRUE)
else()
# try script from binary Linux installs that requires an 'intel64' argument
execute_process(
COMMAND ${BASH} -c ". ${TBB_VARS_SH} intel64 >/dev/null"
RESULT_VARIABLE shell_result
OUTPUT_VARIABLE shell_out
)
if (${shell_result} EQUAL 0)
set(tbb_vars_opt "intel64")
set(tbb_vars_works TRUE)
endif()
endif()
if(tbb_vars_works)
execute_process(
COMMAND ${BASH} -c "unset CPATH ; . ${TBB_VARS_SH} ${tbb_vars_opt} >/dev/null && echo -n $CPATH"
RESULT_VARIABLE shell_result
OUTPUT_VARIABLE shell_out
)
find_path(
TBB_INCLUDE_DIR
NAMES tbb/task_scheduler_init.h
PATHS ${shell_out}
DOC "Path to TBB include directory"
NO_DEFAULT_PATH
)
execute_process(
COMMAND ${BASH} -c "unset LIBRARY_PATH ; . ${TBB_VARS_SH} ${tbb_vars_opt} >/dev/null && echo -n $LIBRARY_PATH"
RESULT_VARIABLE shell_result
OUTPUT_VARIABLE shell_out
)
set(
TBB_LIBRARY_DIR ${shell_out}
CACHE PATH "Path to TBB library directory"
)
else()
message(WARNING "Could not parse tbbvars.sh file at {TBB_VARS_SH}")
endif()
endfunction()
# Check whether the user gave us an existing tbbvars.sh file
find_file(
TBB_VARS_SH
tbbvars.sh
DOC "Path to tbbvars.sh script"
NO_DEFAULT_PATH
)
if (TBB_VARS_SH)
parse_tbb_vars_sh()
else()
# Try to find TBB in standard include paths
find_path(
TBB_INCLUDE_DIR
tbb/task_scheduler_init.h
PATHS ENV CPATH
DOC "Path to TBB include directory"
)
# Try to find some version of the TBB library in standard library paths
find_path(
TBB_LIBRARY_DIR
"${CMAKE_SHARED_LIBRARY_PREFIX}tbb_preview${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_SHARED_LIBRARY_PREFIX}tbb${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_SHARED_LIBRARY_PREFIX}tbb_preview_debug${CMAKE_SHARED_LIBRARY_SUFFIX}"
"${CMAKE_SHARED_LIBRARY_PREFIX}tbb_debug${CMAKE_SHARED_LIBRARY_SUFFIX}"
PATHS ENV LIBRARY_PATH
DOC "Path to TBB library directory"
)
message(STATUS "Library dir: ${TBB_LIBRARY_DIR}")
endif()
# helper function to invoke find_library() correctly
# If we are using tbbvars.sh, we exclude system-default library search paths,
# otherwise we leave them in
function(find_tbb_library)
include(CMakeParseArguments)
set(OPTIONS)
set(SINGLEARGS VAR NAME DOC)
set(MULTIARGS)
cmake_parse_arguments(LIB "${OPTIONS}" "${SINGLEARGS}" "${MULTIARGS}" ${ARGN})
if(TBB_VARS_SH)
find_library(
${LIB_VAR}
${LIB_NAME}
PATHS ${TBB_LIBRARY_DIR}
DOC "${LIB_DOC}"
NO_DEFAULT_PATH
)
else()
find_library(
${LIB_VAR}
${LIB_NAME}
PATHS ${TBB_LIBRARY_DIR}
DOC "${LIB_DOC}"
)
endif()
endfunction()
``TBB::tbb``
Imported library to link against if TBB should be used.
Result Variables
^^^^^^^^^^^^^^^^
# we always want to use TBB in C++11 mode
set(TBB_COMPILE_DEFINITIONS _TBB_CPP0X)
This will define the following variables:
``TBB_FOUND``
True if the TBB library was found.
if(TBB_DEBUG)
message(STATUS "Linking against debug version of TBB")
set(tbb_debug_suffix "_debug")
# TBB requires this additional compile definition when used in debug mode
list(APPEND TBB_COMPILE_DEFINITIONS TBB_USE_DEBUG)
else()
set(tbb_debug_suffix "")
endif()
Finding the TBB library
^^^^^^^^^^^^^^^^^^^^^^^
# start looking for components
# We first look for component libraries, because the "special component" cpf
# actually replaces the standard libtbb
Two strategies are implemented for finding the TBB library:
set(TBB_cpf_FOUND FALSE)
set(TBB_allocator_FOUND FALSE)
1. Searching for the TBB cmake config file, typically named
``TBBConfig.cmake``. In recent TBB versions, this file can be
created using a script provided by TBB itself. Simply set the
variable ``TBB_DIR`` to the directory containing the config file
in order to find TBB.
foreach(component ${TBB_FIND_COMPONENTS})
2. Using pkg-config to configure TBB. Therefore it is necessary
to find the ``tbb.pc`` file. Several distributions provide this file
directly. In order to point pkg-config to the location of that file,
simply set the environmental variable ``PKG_CONFIG_PATH`` to include
the directory containing the .pc file, or add this path to the
``CMAKE_PREFIX_PATH``.
if(component STREQUAL "cpf")
find_tbb_library(
VAR TBB_LIBTBB_PREVIEW
NAME "tbb_preview${tbb_debug_suffix}"
DOC "Path to TBB community preview library"
)
if(TBB_LIBTBB_PREVIEW)
list(APPEND TBB_LIBRARIES ${TBB_LIBTBB_PREVIEW})
list(APPEND TBB_COMPILE_DEFINITIONS TBB_PREVIEW_LOCAL_OBSERVER=1)
set(TBB_cpf_FOUND TRUE)
endif()
#]=======================================================================]
elseif(component STREQUAL "allocator")
find_tbb_library(
VAR TBB_LIBTBBMALLOC
NAME "tbbmalloc${tbb_debug_suffix}"
DOC "Path to TBB malloc library"
)
if(TBB_LIBTBBMALLOC)
list(APPEND TBB_LIBRARIES ${TBB_LIBTBBMALLOC})
set(TBB_allocator_FOUND TRUE)
endif()
else()
message(FATAL_ERROR "Unknown TBB component: ${component}")
endif()
endforeach()
# If we could not find libtbb_preview, look for plain libtbb instead
if(NOT TBB_cpf_FOUND)
find_tbb_library(
VAR TBB_LIBTBB
NAME "tbb${tbb_debug_suffix}"
DOC "Path to TBB library"
)
if(TBB_LIBTBB)
list(APPEND TBB_LIBRARIES ${TBB_LIBTBB})
endif()
else()
# This avoids special-casing later on
set(
TBB_LIBTBB ${TBB_LIBTBB_PREVIEW}
CACHE FILEPATH "Path to TBB library"
)
# text for feature summary
include(FeatureSummary)
set_package_properties("TBB" PROPERTIES
DESCRIPTION "Intel's Threading Building Blocks"
)
# first, try to find TBBs cmake configuration
find_package(TBB ${TBB_FIND_VERSION} QUIET CONFIG)
if(TBB_tbb_FOUND)
message(STATUS "Found TBB: using configuration from TBB_DIR=${TBB_DIR} (found version \"${TBB_VERSION}\")")
return()
endif()
# Don't show these to the user, they are just confusing
mark_as_advanced(
TBB_LIBTBB_PREVIEW
TBB_LIBTBB
TBB_LIBTBBMALLOC
)
include(CheckCXXSourceCompiles)
include(CMakePushCheckState)
# make sure this variable always exists; it is only used if we pick the internal
# TBB implementation from an Intel Compiler
set(TBB_COMPILE_OPTIONS "")
set(TBB_INTEL_COMPILER_INTERNAL_TBB OFF)
# We didn't manage to find TBB yet, so try if we can fall back to the one shipped
# as part of Intel's compiler
if ((NOT TBB_LIBTBB) AND("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Intel"))
# This while doesn't work in debug mode because -tbb always injects -ltbb into the linker flags, and that clashes
# with -ltbb_debug
if(NOT TBB_DEBUG)
message(STATUS "Could not find TBB in normal places, trying to fall back to internal version of Intel Compiler")
# We'll just compile a program with -tbb and see whether that works
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_FLAGS -tbb)
foreach(_definition ${TBB_COMPILE_DEFINITIONS})
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${_definition}")
endforeach()
set(CMAKE_REQUIRED_QUIET ON)
check_cxx_source_compiles(
"${tbb_compile_source}"
TBB_INTEL_COMPILER_INTERNAL_TBB
)
if(TBB_INTEL_COMPILER_INTERNAL_TBB)
# yeah, success
set(TBB_COMPILE_OPTIONS -tbb)
# now check components
foreach(component ${TBB_FIND_COMPONENTS})
# again, this doesn't work because of the default -ltbb injected by -tbb
if(component STREQUAL "cpf")
message(STATUS "Cannot link to community preview version when using compiler-internal version of TBB. Please specify the tbbvars.sh script in TBB_VARS_SH")
elseif(component STREQUAL "allocator")
# we'll check for this by trying to link against the library
set(CMAKE_REQUIRED_LIBRARIES tbbmalloc)
check_cxx_source_compiles(
"${tbb_compile_source}"
TBB_INTEL_COMPILER_INTERNAL_TBBMALLOC
)
if(TBB_INTEL_COMPILER_INTERNAL_TBBMALLOC)
list(APPEND TBB_LIBRARIES tbbmalloc)
set(TBB_allocator_FOUND TRUE)
endif()
else()
message(FATAL_ERROR "Unknown TBB component: ${component}")
endif()
endforeach()
# clean up check state
cmake_pop_check_state()
endif()
# second, try to find TBBs pkg-config file
find_package(PkgConfig)
if(PkgConfig_FOUND)
if(TBB_FIND_VERSION)
pkg_check_modules(PkgConfigTBB tbb>=${TBB_FIND_VERSION} QUIET IMPORTED_TARGET GLOBAL)
else()
message(STATUS "Could not find TBB in normal places, and don't know how to fall back to internal version of Intel Compiler for debug version.
You can either turn of the TBB_DEBUG option or point the TBB_VARS_SH variable at the tbbvars.sh script shipped with your compiler.")
pkg_check_modules(PkgConfigTBB tbb QUIET IMPORTED_TARGET GLOBAL)
endif()
endif()
# make sure everything works
cmake_push_check_state(RESET)
set(CMAKE_REQUIRED_INCLUDES ${TBB_INCLUDE_DIR})
foreach(_definition ${TBB_COMPILE_DEFINITIONS})
list(APPEND CMAKE_REQUIRED_DEFINITIONS "-D${_definition}")
endforeach()
set(CMAKE_REQUIRED_FLAGS ${TBB_COMPILE_OPTIONS})
set(CMAKE_REQUIRED_LIBRARIES ${TBB_LIBRARIES})
check_cxx_source_compiles(
"${tbb_compile_source}"
TBB_COMPILE_TEST
)
cmake_pop_check_state()
# we don't want to leak any helper variables
unset(tbb_compile_source)
# provide standard find_package() interface
include(FindPackageHandleStandardArgs)
if(TBB_INTEL_COMPILER_INTERNAL_TBB)
set(TBB_INCLUDE_DIRS "")
set(TBB_LIBRARIES "")
find_package_handle_standard_args(
TBB
REQUIRED_VARS TBB_COMPILE_OPTIONS TBB_COMPILE_TEST
HANDLE_COMPONENTS
)
# check whether the static library was found
if(PkgConfigTBB_STATIC_FOUND)
set(_tbb PkgConfigTBB_STATIC)
else()
set(TBB_INCLUDE_DIRS ${TBB_INCLUDE_DIR})
find_package_handle_standard_args(
TBB
REQUIRED_VARS TBB_INCLUDE_DIRS TBB_LIBRARIES TBB_COMPILE_TEST
HANDLE_COMPONENTS
)
set(_tbb PkgConfigTBB)
endif()
# set variable for config.h
set(HAVE_TBB ${TBB_FOUND})
# perform DUNE-specific setup tasks
if (TBB_FOUND)
set(TBB_CACHE_ALIGNED_ALLOCATOR_ALIGNMENT 128)
message(STATUS "defaulting TBB_CACHE_ALIGNED_ALLOCATOR_ALIGNMENT to 128")
dune_register_package_flags(
COMPILE_DEFINITIONS ENABLE_TBB=1 ${TBB_COMPILE_DEFINITIONS}
COMPILE_OPTIONS ${TBB_COMPILE_OPTIONS}
INCLUDE_DIRS ${TBB_INCLUDE_DIRS}
LIBRARIES ${TBB_LIBRARIES}
)
endif()
# function for adding TBB flags to a list of targets
function(add_dune_tbb_flags _targets)
foreach(_target ${_targets})
target_compile_definitions(${_target} PUBLIC ENABLE_TBB=1)
if(TBB_COMPILE_DEFINITIONS)
target_compile_definitions(${_target} PUBLIC ${TBB_COMPILE_DEFINITIONS})
endif()
if(TBB_COMPILE_OPTIONS)
target_compile_options(${_target} PUBLIC ${TBB_COMPILE_OPTIONS})
endif()
if(TBB_INCLUDE_DIRS)
target_include_directories(${_target} PUBLIC ${TBB_INCLUDE_DIRS})
endif()
if(TBB_LIBRARIES)
target_link_libraries(${_target} PUBLIC ${TBB_LIBRARIES})
endif()
endforeach(_target)
endfunction(add_dune_tbb_flags)
# text for feature summary
set_package_properties("TBB" PROPERTIES
DESCRIPTION "Threading Building Blocks library"
PURPOSE "Parallel programming on multi-core processors")
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args("TBB"
REQUIRED_VARS
${_tbb}_LINK_LIBRARIES ${_tbb}_FOUND PkgConfig_FOUND
VERSION_VAR
${_tbb}_VERSION
FAIL_MESSAGE "Could NOT find TBB (set TBB_DIR to path containing TBBConfig.cmake or set PKG_CONFIG_PATH to include the location of the tbb.pc file)"
)
if(${_tbb}_FOUND AND NOT TARGET TBB::tbb)
add_library(TBB::tbb ALIAS PkgConfig::PkgConfigTBB)
endif()
\ No newline at end of file
......@@ -4,5 +4,5 @@ Author: The Dune Core developers
Maintainer: dune-devel@lists.dune-project.org
Description: Basis infrastructure for all Dune modules
URL: https://gitlab.dune-project.org/core/dune-common
Python-Requires: portalocker numpy
Python-Requires: portalocker numpy wheel
Whitespace-Hook: Yes
......@@ -34,22 +34,25 @@ namespace Dune
typedef const typename FieldTraits< typename DenseMatVecTraits<M>::value_type >::real_type real_type;
};
/*
/**
work around a problem of FieldMatrix/FieldVector,
there is no unique way to obtain the size of a class
\deprecated VectorSize is deprecated; please call the 'size()' method directly instead.
This will be removed after Dune 2.8.
*/
template<class K, int N, int M> class FieldMatrix;
template<class K, int N> class FieldVector;
namespace {
template<class V>
struct DUNE_DEPRECATED_MSG("VectorSize is deprecated; please call the 'size()' method directly instead") VectorSize
struct [[deprecated("VectorSize is deprecated; please call the 'size()' method directly instead")]] VectorSize
{
static typename V::size_type size(const V & v) { return v.size(); }
};
DUNE_NO_DEPRECATED_BEGIN
template<class K, int N>
struct DUNE_DEPRECATED_MSG("VectorSize is deprecated; please call the 'size()' method directly instead") VectorSize< const FieldVector<K,N> >
struct [[deprecated("VectorSize is deprecated; please call the 'size()' method directly instead")]] VectorSize< const FieldVector<K,N> >
{
typedef FieldVector<K,N> V;
static typename V::size_type size(const V & v)
......
......@@ -13,73 +13,9 @@
#if defined(DOXYGEN) || !defined(HAS_ATTRIBUTE_DEPRECATED)
//! Mark some entity as deprecated
/**
* \code
*#include <dune/common/deprecated.hh>
* \endcode
*
* This is a preprocessor define which can be used to mark functions,
* typedefs, enums and other stuff deprecated. If something is marked
* deprecated, users are advised to migrate to the new interface, since it
* will probably be removed in the next release of Dune.
*
* DUNE_DEPRECATED currently works with g++ and clang++. For other compilers it will
* be defined empty. This way the user will not get any deprecation warning,
* but at least his code still compiles (well, until the next Dune release,
* that is).
*
* Here are some examples how to mark different stuff deprecated:
* - Classes
* \code
class DUNE_DEPRECATED Class {}; // 1)
class Class {} DUNE_DEPRECATED; // 2)
* \endcode
* Both forms do not work properly with g++-4.1: no deprecation warning
* will be given, although the code still compiles. 1) should be preferred
* over 2) since 2) does not work with clang++-1.1 (again, no warning given
* but code still compiles, works with clang++-3.1)
* - Template classes
* \code
template<class T>
class DUNE_DEPRECATED Class {}; // 1)
template<class T>
class Class {} DUNE_DEPRECATED; // 2)
* \endcode
* This works works with g++ >=4.3 only; g++-4.1 and
* clang++ compile the code without warning in both cases. Furthermore,
* the warning is only triggered when copying an object of that template
* class, neither making a typedef nor simply creating such an object emit
* the warning. It is thus recommended that some essential class member be
* marked deprecated as well, if possible.
* - Member constants
* \code
template<typename T> struct Class {
static const int c0 DUNE_DEPRECATED = 0;
static const int DUNE_DEPRECATED c1 = 1;
};
* \endcode
* Works with g++-4.1, g++ >=4.3 and clang++3.1.
* No warning but clean compile with clang++-1.1.
* - Member enumerators
* \code
template<typename T> struct Class {
enum enumeration { enumerator = 0 };
};
* \endcode
* No form of deprecation is known that does not trigger an error on most
* compilers.
* - Member functions
* \code
template<typename T> struct Class {
void frob() DUNE_DEPRECATED {}
}; // 1)
template<typename T> struct Class {
void DUNE_DEPRECATED frob() {}
}; // 2)
template<typename T> struct Class {
DUNE_DEPRECATED void frob() {}
}; // 3)
* \endcode
* With g++ only 2) emits a warning for templated member functions.
* \deprecated Use C++14's \code[[deprecated]]\endcode instead. It will be
* removed after Dune 2.8. Be aware that it must be sometimes placed at
* different position in the code.
*/
#define DUNE_DEPRECATED
#else // defined(HAS_ATTRIBUTE_DEPRECATED)
......@@ -89,82 +25,9 @@
#if defined(DOXYGEN) || !defined(HAS_ATTRIBUTE_DEPRECATED_MSG)
//! Mark some entity as deprecated
/**
* \code
*#include <dune/common/deprecated.hh>
* \endcode
*
* This is a preprocessor define which can be used to mark functions,
* typedefs, enums and other stuff deprecated and to also specify a
* hint what replaces the given functionality. If something is marked
* deprecated, users are advised to migrate to the new interface,
* since it will probably be removed in the next release of Dune.
*
* DUNE_DEPRECATED_MSG currently works only for compilers which
* support the attribute __attribute__((deprecated("message")). For
* other compilers it will be defined empty. This way the user will
* not get any deprecation warning, but at least his code still
* compiles (well, until the next Dune release, that is).
*
* Here are some examples how to mark different stuff deprecated:
* - Classes
* \code
class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1)
class Class {} DUNE_DEPRECATED_MSG("In the future, please use 'Glass'"); // 2)
* \endcode
* For both forms, deprecation warnings and the additional hint "In
* the future, please use 'Glass'" will be printed on compilers
* which support it (e.g. G++ >= 4.5.0, clang++ >= 1.1). For compilers
* which support deprecating but do not take an additional hint
* (e.g. G++ < 4.5.0), only the deprecation warning is printed, and
* finally compilers which do not support deprecation of code won't
* print anything, but the code will still compile. 1) should be
* preferred over 2) since 2) does not work with clang++-1.1
* (again, no warning will be given but code still compiles)
* - Template classes
* \code
template<class T>
class DUNE_DEPRECATED_MSG("In the future, please use 'Glass'") Class {}; // 1)
template<class T>
class Class {} DUNE_DEPRECATED_MSG("In the future, please use 'Glass'"); // 2)
* \endcode
* This works works with g++ >= 4.5, clang++ until at least version
* 1.1 will compile the code without warning in both cases.
* Furthermore, the warning is only triggered when copying an
* object of that template class, neither making a typedef nor
* simply creating such an object emit the warning. It is thus
* recommended that some essential class member be marked
* deprecated as well, if possible.
* - Member constants
* \code
template<typename T> struct Class {
static const int c0 DUNE_DEPRECATED_MSG("c2 is the new hype") = 0;
static const int DUNE_DEPRECATED_MSG("c2 is the new hype") c1 = 1;
};
* \endcode
* Works without printing the hint on g++-4.1, g++-4.3, g++-4.4 and
* fully on g++ >= 4.5. Works for clang++-3.1.
* No warning but clean compile with clang++-1.1.
* - Member enumerators
* \code
template<typename T> struct Class {
enum enumeration { enumerator = 0 };
};
* \endcode
* No form of deprecation is known that does not trigger an error on most
* compilers.
* - Member functions
* \code
template<typename T> struct Class {
void frob() DUNE_DEPRECATED_MSG("use frog") {}
}; // 1)
template<typename T> struct Class {
void DUNE_DEPRECATED_MSG("use frog") frob() {}
}; // 2)
template<typename T> struct Class {
DUNE_DEPRECATED_MSG("use frog") void frob() {}
}; // 3)
* \endcode
* With g++ only 2) emits a warning for templated member functions.
* \deprecated Use C++14's \code[[deprecated(msg)]]\endcode instead. It
* will be removed after Dune 2.8. Be aware that it must be sometimes
* placed at different position in the code.
*/
#define DUNE_DEPRECATED_MSG(text) DUNE_DEPRECATED
#else // defined(HAS_ATTRIBUTE_DEPRECATED_MSG)
......
......@@ -19,7 +19,6 @@
#include <utility>
#include <dune/common/classname.hh>
#include <dune/common/deprecated.hh>
#include <dune/common/hybridutilities.hh>
#include <dune/common/rangeutilities.hh>
#include <dune/common/simd/io.hh>
......@@ -145,7 +144,7 @@ namespace Dune {
template<class...>
constexpr bool debugTypes(std::true_type) { return true; }
template<class... Types>
DUNE_DEPRECATED
[[deprecated]]
constexpr bool debugTypes(std::false_type) { return false; }
} // namespace Impl
......@@ -321,8 +320,8 @@ namespace Dune {
}
template<class V>
DUNE_DEPRECATED_MSG("Warning: please include bool in the Rebinds for "
"simd type V, as Masks are not checked otherwise.")
[[deprecated("Warning: please include bool in the Rebinds for "
"simd type V, as Masks are not checked otherwise.")]]
void warnMissingMaskRebind(std::true_type) {}
template<class V>
void warnMissingMaskRebind(std::false_type) {}
......
......@@ -10,6 +10,7 @@
#include "config.h"
#endif
#include <dune/common/deprecated.hh>
#include <dune/common/shared_ptr.hh>
#include <cstdlib>
......
......@@ -5,6 +5,7 @@
#include "config.h"
#endif
#include <dune/common/deprecated.hh>
#include <dune/common/to_unique_ptr.hh>
#include <dune/common/test/testsuite.hh>
......
......@@ -6,8 +6,6 @@
#include <memory>
#include <dune/common/deprecated.hh>
namespace Dune
{
/// \brief An owning pointer wrapper that can be assigned to (smart) pointers. Cannot be copied.
......@@ -67,8 +65,10 @@ namespace Dune
// Conversion operators:
//@{
/// Convert to underlying pointer, releases the stored pointer. NOTE: deprecated
DUNE_DEPRECATED_MSG("Cast to raw pointer is deprecated. Use std::unique_ptr or std::shared_ptr instead.")
/// Convert to underlying pointer, releases the stored pointer.
/// \deprecated Cast to raw pointer is deprecated. Use std::unique_ptr or std::shared_ptr instead.
/// Will be removed after Dune 2.8
[[deprecated("Cast to raw pointer is deprecated. Use std::unique_ptr or std::shared_ptr instead.")]]
operator pointer() noexcept { return Super::release(); }
/// Convert to unique_ptr, invalidates the stored pointer
......
......@@ -8,8 +8,6 @@
#include <utility>
#include <vector>
#include <dune/common/deprecated.hh>
namespace Dune
{
......@@ -196,7 +194,7 @@ namespace Dune
* Internally, this is just a forward to `std::is_floating_point<T>`.
*/
template <typename T>
struct DUNE_DEPRECATED_MSG("Has been renamed to 'HasNaN'.") has_nan
struct [[deprecated("Has been renamed to 'HasNaN'.")]] has_nan
: HasNaN<T> {};
#if defined(DOXYGEN) or HAVE_IS_INDEXABLE_SUPPORT
......@@ -319,7 +317,7 @@ namespace Dune
* are problems with GCC 4.4 and 4.5.
*/
template<typename T, typename I = std::size_t>
struct DUNE_DEPRECATED_MSG("Has been renamed to 'IsIndexable'.") is_indexable
struct [[deprecated("Has been renamed to 'IsIndexable'.")]] is_indexable
: public IsIndexable<T,I> {};
#ifndef DOXYGEN
......@@ -365,7 +363,7 @@ namespace Dune
\deprecated is_range is deprecated, use `Dune::IsIterable` instead
*/
template<typename T, typename = void>
struct DUNE_DEPRECATED_MSG("Has been renamed to 'IsIterable'.") is_range
struct [[deprecated("Has been renamed to 'IsIterable'.")]] is_range
: public IsIterable<T> {};
#ifndef DOXYGEN
......
dune_python_add_test(NAME pythontests
COMMAND ${PYTHON_EXECUTABLE} pythontests.py
SCRIPT pythontests.py
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
LABELS quick)
dune_add_test(SOURCES test_embed1.cc
LINK_LIBRARIES ${DUNE_LIBS} ${PYTHON_LIBRARIES}
LINK_LIBRARIES ${DUNE_LIBS} ${Python3_LIBRARIES}
LABELS quick
)
add_executable(test_embed2 EXCLUDE_FROM_ALL test_embed2.cc)
target_link_libraries(test_embed2 PUBLIC ${DUNE_LIBS} ${PYTHON_LIBRARIES})
target_link_libraries(test_embed2 PUBLIC ${DUNE_LIBS} ${Python3_LIBRARIES})
# the following should apparently work but doesn't target_link_libraries(test_embed2 PRIVATE Python3::Python)
......@@ -69,6 +69,10 @@ parse_control() {
echo "ERROR: $CONTROL files $1 contains an invalid Module entry" >&2
exit 1
fi
# don't include the generated `dune-py` module in the dependency list
if test "$module" = "dune_py" ; then
return
fi
# read dune.module file
local deps="$($GREP "^[BLANK]*Depends:" "$1" | cut -d ':' -f2 | eval $PARSER_TRIM)"
local sugs="$($GREP "^[BLANK]*Suggests:" "$1" | cut -d ':' -f2 | eval $PARSER_TRIM)"
......@@ -228,6 +232,10 @@ setup_control_path() {
local TMP=""
# foreach dir in $@
while read dir; do
if ! test -e "$dir"; then
echo "ERROR: The path \"$dir\" given in DUNE_CONTROL_PATH does not exist."
exit 1
fi
TMP=$TMP:"$(canonicalname "$dir")"
done <<EOF
$(echo $DUNE_CONTROL_PATH | sed -e 's/:\+/:/g' | tr ':' '\n')
......
add_subdirectory(dune)
configure_file(setup.py.in setup.py)
configure_file(pyproject.toml.in pyproject.toml)
......@@ -16,12 +16,12 @@ if __name__ == "dune.common.module":
from dune.common.utility import buffer_to_str
from dune.common import project
from dune.packagemetadata import Version, VersionRequirement,\
Description, cmakeFlags
Description, cmakeFlags, cmakeArguments
else:
from utility import buffer_to_str
import project
from packagemetadata import Version, VersionRequirement,\
Description, cmakeFlags
Description, cmakeFlags, cmakeArguments
logger = logging.getLogger(__name__)
......@@ -113,7 +113,7 @@ def resolve_order(deps):
def resolve(m):
if m not in order:
for d in deps[m]:
for d, r in deps[m].depends:
if d not in order:
resolve(d)
order.append(m)
......@@ -209,12 +209,13 @@ def get_module_path():
return path
def select_modules(modules=None):
def select_modules(modules=None, module=None):
"""choose one version of each module from a list of modules
Args:
modules (optional): List of (description, dir) pairs
If not given, the find_modules(get_module_path()) is used
module (optional):
Returns:
pair of dictionaries mapping module name to unique description and directory respectively
......@@ -254,26 +255,20 @@ def default_build_dir(srcdir, module=None, builddir=None):
return os.path.join(srcdir, builddir)
def configure_module(srcdir, builddir, prefix_dirs, definitions=None):
def configure_module(srcdir, builddir, prefix_dirs, cmake_args=None):
"""configure a given module by running CMake
Args:
srcdir: source directory of module
builddir: build directory for module (may equal srcdir for in-source builds)
prefix_dirs: dictionary mapping dependent modules to their prefix
definitions (optional): dictionary of additional CMake definitions
cmake_args (optional): list of additional CMake flags
Returns:
Output of CMake command
"""
args = [ get_cmake_command() ]
if definitions is None:
pass
elif isinstance(definitions, dict):
args += ['-D' + key + '=' + value + '' for key, value in definitions.items() if value]
args += [key + '' for key, value in definitions.items() if not value]
else:
raise ValueError('definitions must be a dictionary.')
args += cmakeArguments(cmake_args)
args += ['-D' + module + '_DIR=' + dir for module, dir in prefix_dirs.items()]
args.append(srcdir)
if not os.path.isdir(builddir):
......@@ -381,7 +376,7 @@ def make_dune_py_module(dune_py_dir=None, deps=None):
if deps is None:
modules, _ = select_modules()
deps = modules.values()
deps = modules.keys()
description = Description(module='dune-py', version=get_dune_py_version(), maintainer='dune@lists.dune-project.org', depends=list(deps))
logger.debug('dune-py will depend on ' + ' '.join([m[0] + (' ' + str(c) if c else '') for m, c in description.depends]))
......@@ -397,16 +392,17 @@ def make_dune_py_module(dune_py_dir=None, deps=None):
raise RuntimeError('"' + dune_py_dir + '" contains a different version of the dune-py module.')
logger.info('Using dune-py module in ' + dune_py_dir)
def build_dune_py_module(dune_py_dir=None, definitions=None, build_args=None, builddir=None):
def build_dune_py_module(dune_py_dir=None, cmake_args=None, build_args=None, builddir=None, deps=None):
if dune_py_dir is None:
dune_py_dir = get_dune_py_dir()
if definitions is None:
definitions = cmakeFlags()
if cmake_args is None:
cmake_args = cmakeFlags()
modules, dirs = select_modules()
deps = resolve_dependencies(modules, None)
if deps is None:
deps = resolve_dependencies(modules)
desc = Description(module='dune-py', version=get_dune_py_version(), maintainer='dune@lists.dune-project.org', depends=list(modules.values()))
desc = Description(module='dune-py', version=get_dune_py_version(), maintainer='dune@lists.dune-project.org', depends=list(deps))
with open(os.path.join(dune_py_dir, 'dune.module'), 'w') as file:
file.write(repr(desc))
......@@ -424,7 +420,7 @@ def build_dune_py_module(dune_py_dir=None, definitions=None, build_args=None, bu
else:
prefix[name] = default_build_dir(dir, name, builddir)
output = configure_module(dune_py_dir, dune_py_dir, {d: prefix[d] for d in deps}, definitions)
output = configure_module(dune_py_dir, dune_py_dir, {d: prefix[d] for d in deps}, cmake_args)
output += build_module(dune_py_dir, build_args)
return output
......
......@@ -101,22 +101,29 @@ class VersionRequirement:
else:
return ''
class Description:
def __init__(self, fileName=None, **kwargs):
data = kwargs.copy()
valid_entries = ['Module','Maintainer','Version','Maintainer',
'Depends','Suggests',
'Whitespace-Hook',
'Author','Description','URL']
if fileName is not None:
with io.open(fileName, 'r', encoding='utf-8') as file:
import re
for line in file:
line = line.strip()
if not line or line[ 0 ] == '#':
continue
pos = line.find(':')
if pos < 0:
raise ValueError('Invalid key:value pair (' + line + ').')
data[line[:pos].strip().lower()] = line[pos+1:].strip()
m = re.search(r'^(\w+):(.*)', line)
if m:
key = m.group(1)
val = m.group(2)
if not key in valid_entries:
raise ValueError('Invalid dune.module entry %s (%s).' % (key,fileName))
data[key.lower()] = val.strip()
try:
self.name = data['module']
except KeyError:
......@@ -232,9 +239,21 @@ class Data:
def asPythonRequirementString(self, requirements):
return [(r[0]+str(r[1])).replace("("," ").replace(")","").replace(" ","") for r in requirements]
def cmakeArguments(cmakeArgs):
if cmakeArgs is None:
return []
elif isinstance(cmakeArgs, list):
return cmakeArgs
elif isinstance(cmakeArgs, dict):
args = ['-D' + key + '=' + value + '' for key, value in cmakeArgs.items() if value]
args += [key + '' for key, value in cmakeArgs.items() if not value]
return args
else:
raise ValueError('definitions must be a list or a dictionary.')
def cmakeFlags():
# defaults
flags = dict([
flags = cmakeArguments(dict([
('CMAKE_BUILD_TYPE','Release'),
('CMAKE_INSTALL_RPATH_USE_LINK_PATH','TRUE'),
('DUNE_ENABLE_PYTHONBINDINGS','TRUE'),
......@@ -243,31 +262,20 @@ def cmakeFlags():
('CMAKE_DISABLE_FIND_PACKAGE_LATEX','TRUE'),
('CMAKE_DISABLE_FIND_PACKAGE_Doxygen','TRUE'),
('INKSCAPE','FALSE')
])
]))
# test environment for additional flags
cmakeFlags = os.environ.get('DUNE_CMAKE_FLAGS')
if cmakeFlags is None:
cmakeFlags = os.environ.get('CMAKE_FLAGS')
# split flags and store in dict
add = {}
# split cmakeFlags and add them to flags
if cmakeFlags is not None:
for arg in shlex.split(cmakeFlags):
try:
key, value = arg.split('=', 1)
if key.startswith('-D'):
key = key[2:]
except ValueError:
key, value = arg, None
add[key] = value
flags.update(add)
flags += shlex.split(cmakeFlags)
return flags
def metaData(version=None, dependencyCheck=True):
data = Data(version)
flags = cmakeFlags()
cmake_flags = ['-D' + key + '=' + value + '' for key, value in flags.items() if value]
cmake_flags += [key + '' for key, value in flags.items() if not value]
cmake_flags = cmakeFlags()
# check if all dependencies are listed in pyproject.toml
if dependencyCheck:
......
[build-system]
requires = ["setuptools", "wheel"]