#
#
# Usage:
-# DEAL_II_ADD_TEST(category test_name comparison_file [ARGN])
+# DEAL_II_ADD_TEST(category test_name comparison_file)
#
# This macro assumes that a source file "./tests/category/<test_name>.cc"
# as well as the comparison file "<comparison_file>" is available in the
STRING(TOUPPER ${_expect} _expect)
ENDIF()
+ #
+ # Determine for which build types a test should be defined:
+ #
+
FOREACH(_build ${DEAL_II_BUILD_TYPES})
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc
)
- ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL ${_test_name}.cc
+ ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL
+ ${_test_name}.cc
${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc
)
+ DEAL_II_SETUP_TARGET(${_target} ${_build})
+ TARGET_LINK_LIBRARIES(${_target}
+ ${TARGET_LIBRARIES} ${TARGET_LIBRARIES_${_build}}
+ )
SET_TARGET_PROPERTIES(${_target} PROPERTIES
- LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
- COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
- LINKER_LANGUAGE "CXX"
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_target}"
)
- SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
- INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}"
- )
- SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
- COMPILE_DEFINITIONS
- SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}"
- )
- TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_${_build}})
+
ENDIF()
#
## ---------------------------------------------------------------------
##
-## Copyright (C) 2012 - 2014 by the deal.II authors
+## Copyright (C) 2012 - 2015 by the deal.II authors
##
## This file is part of the deal.II library.
##
#
# Usage:
# DEAL_II_SETUP_TARGET(target)
+# DEAL_II_SETUP_TARGET(target DEBUG|RELEASE)
#
# This appends necessary include directories, linker flags, compile
# definitions and the deal.II library link interface to the given target.
#
-# The current CMAKE_BUILD_TYPE is respected by setting the appropriate
-# debug or release variants (if available).
+# If no "DEBUG" or "RELEASE" keyword is specified after the target, the
+# current CMAKE_BUILD_TYPE determines which compiler and linker flags as
+# well as compile definitions to use and against which deal.II library it
+# should be linked against.
+#
+# If the requested build type is not availabe (e.g. DEBUG request but
+# deal.II was compiled with release mode only), the other available will be
+# used instead.
#
MACRO(DEAL_II_SETUP_TARGET _target)
#
# Append build type dependent flags and definitions.
#
-
- #
- # For this we obey the behaviour of the "optimized" and "debug"
- # keywords and this is a bit tricky:
+ # Every build type that (case insensitively) matches "debug" is
+ # considered a debug build:
#
- # If the global property DEBUG_CONFIGURATIONS is set all build types that
- # (case insensitively) match one of the listed build types is considered
- # a "debug" build. The rest is "optimized".
+ SET(_on_debug_build FALSE)
+ STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
+ IF("${_cmake_build_type}" MATCHES "debug")
+ SET(_on_debug_build TRUE)
+ ENDIF()
+
#
- # Otherwise every build type that (case insensitively) matches "debug" is
- # considered a debug build.
+ # Override _on_debug_build if ${ARGN} is set:
#
- GET_PROPERTY(_debug_configurations_set
- GLOBAL PROPERTY DEBUG_CONFIGURATIONS SET
- )
- IF(_debug_configurations_set)
- STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
- GET_PROPERTY(_debug_configurations
- GLOBAL PROPERTY DEBUG_CONFIGURATIONS
- )
- FOREACH(_debug_type ${_debug_configurations})
- STRING(TOLOWER "${_debug_type}" _debug_type)
- IF("${_cmake_build_type}" STREQUAL "${_debug_type}")
- SET(_on_debug_build TRUE)
- BREAK()
- ENDIF()
- ENDFOREACH()
- ELSE()
- STRING(TOLOWER "${CMAKE_BUILD_TYPE}" _cmake_build_type)
- IF("${_cmake_build_type}" STREQUAL "debug")
- SET(_on_debug_build TRUE)
- ENDIF()
+ IF("${ARGN}" MATCHES "^DEBUG$")
+ SET(_on_debug_build TRUE)
+ ELSEIF ("${ARGN}" MATCHES "^RELEASE$")
+ SET(_on_debug_build FALSE)
ENDIF()
#
# We can only append DEBUG link flags and compile definitions if deal.II
- # was build with Debug or DebugRelease build type. So test for this:
+ # was built with the Debug or DebugRelease build type. So test for this:
#
- IF( _on_debug_build
- AND DEAL_II_BUILD_TYPE MATCHES "Debug" )
+ IF(_on_debug_build AND DEAL_II_BUILD_TYPE MATCHES "Debug")
SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
LINK_FLAGS " ${DEAL_II_LINKER_FLAGS_DEBUG}"
)
#
GET_PROPERTY(_type TARGET ${_target} PROPERTY TYPE)
IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY")
- TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET})
+ IF(_on_debug_build AND DEAL_II_BUILD_TYPE MATCHES "Debug")
+ TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_DEBUG})
+ ELSE()
+ TARGET_LINK_LIBRARIES(${_target} ${DEAL_II_TARGET_RELEASE})
+ ENDIF()
ENDIF()
#