SET(DEAL_II_LIBRARIES "@CONFIG_LIBRARIES@")
+#
+# Information about CUDA configuration
+#
+
+SET(DEAL_II_CUDA_TOOLKIT_ROOT_DIR "@CUDA_TOOLKIT_ROOT_DIR@")
+SET(DEAL_II_CUDA_COMPILER "@CMAKE_CUDA_COMPILER@")
+
+# used for all cuda targets:
+SET(DEAL_II_CUDA_FLAGS "@DEAL_II_CUDA_FLAGS@")
+
+# _additionally_ used for debug targets:
+SET(DEAL_II_CUDA_FLAGS_DEBUG "@DEAL_II_CUDA_FLAGS_DEBUG@")
+
+# _additionally_ used for release targets:
+SET(DEAL_II_CUDA_FLAGS_RELEASE "@DEAL_II_CUDA_FLAGS_RELEASE@")
+
+
#
# Information about library targets and feature configuration
#
#
# A small wrapper around ADD_LIBRARY that will define a target for each
-# build type specified in DEAL_II_BUILD_TYPES
+# build type specified in DEAL_II_BUILD_TYPES. Only compatible with object
+# targets (as used in the build system).
#
# It is assumed that the desired compilation configuration is set via
-# DEAL_II_LINKER_FLAGS_${build}
# DEAL_II_CXX_FLAGS_${build}
# DEAL_II_DEFINITIONS_${build}
#
# as well as the global (for all build types)
-# DEAL_II_LINKER_FLAGS
# DEAL_II_CXX_FLAGS
# DEAL_II_DEFINITIONS
#
${ARGN}
)
-
- #
- # Work around a problem in CUDA_WARP_SRCS that doesn't take empty list
- # elements lightly...
- #
- SET(_definitions
- ${DEAL_II_DEFINITIONS}
- ${DEAL_II_DEFINITIONS_${_build}}
- )
-
SET_TARGET_PROPERTIES(${_library}_${_build_lowercase} PROPERTIES
- LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
- COMPILE_DEFINITIONS "${_definitions}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
LINKER_LANGUAGE "CXX"
)
- SET_PROPERTY(GLOBAL APPEND PROPERTY DEAL_II_OBJECTS_${_build}
- "$<TARGET_OBJECTS:${_library}_${_build_lowercase}>"
- )
+ IF(CMAKE_VERSION VERSION_LESS 3.9)
- #
- # Cuda specific target setup:
- #
- IF(DEAL_II_WITH_CUDA)
-
- #
- # CUDA_WRAP_SRCS does not automatically pick up host compiler flags
- # from the target, so we have to feed relevant flags ourselves
- #
- # Furthermore, C++14 is not yet supported, so filter the flag:
- #
- STRING(REPLACE "-std=c++14" "-std=c++11" CMAKE_CXX_FLAGS
- "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ SET_TARGET_PROPERTIES(${_library}_${_build_lowercase} PROPERTIES
+ COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
)
- CUDA_WRAP_SRCS(${_library}_${_build_lowercase}
- OBJ _generated_cuda_files ${ARGN} SHARED
- )
- SET(CMAKE_CXX_FLAGS "")
+ ELSE()
- ADD_CUSTOM_TARGET(${_library}_${_build_lowercase}_cuda
- DEPENDS
- ${_generated_cuda_files}
- )
- ADD_DEPENDENCIES(${_library}_${_build_lowercase}
- ${_library}_${_build_lowercase}_cuda
+ SET(_flags "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_flags)
+ TARGET_COMPILE_OPTIONS(${_library}_${_build_lowercase} PUBLIC
+ $<$<COMPILE_LANGUAGE:CXX>:${_flags}>
)
- SET_PROPERTY(GLOBAL APPEND PROPERTY DEAL_II_OBJECTS_${_build}
- "${_generated_cuda_files}"
+ TARGET_COMPILE_DEFINITIONS(${_library}_${_build_lowercase}
+ PUBLIC ${DEAL_II_DEFINITIONS} ${DEAL_II_DEFINITIONS_${_build}}
)
+
+ IF(DEAL_II_WITH_CUDA)
+ #
+ # Add cxx compiler and cuda compilation flags to cuda source files:
+ #
+
+ SET(_cuda_flags "${DEAL_II_CUDA_FLAGS} ${DEAL_II_CUDA_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_cuda_flags)
+
+ #
+ # Workaround: cuda will split every compiler option with a comma
+ # (','), so remove all compiler flags that contain a comma:
+ #
+ STRING(REGEX REPLACE "[^ ]*,[^ ]*" "" _cxx_flags
+ "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ )
+
+ TARGET_COMPILE_OPTIONS(${_library}_${_build_lowercase} PUBLIC
+ $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler "${_cxx_flags}">
+ $<$<COMPILE_LANGUAGE:CUDA>:${_cuda_flags}>
+ )
+
+ SET_TARGET_PROPERTIES(${_library}_${_build_lowercase} PROPERTIES
+ CUDA_SEPARABLE_COMPILATION TRUE
+ )
+ ENDIF()
+
ENDIF()
+ SET_PROPERTY(GLOBAL APPEND PROPERTY DEAL_II_OBJECTS_${_build}
+ "$<TARGET_OBJECTS:${_library}_${_build_lowercase}>"
+ )
ENDFOREACH()
ENDMACRO()
OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc
COMMAND touch ${CMAKE_CURRENT_BINARY_DIR}/${_target}/interrupt_guard.cc
)
-
- IF(DEAL_II_WITH_CUDA)
- FIND_PACKAGE(CUDA)
- CUDA_INCLUDE_DIRECTORIES("${DEAL_II_INCLUDE_DIRS}")
- CUDA_WRAP_SRCS( ${_target} OBJ _generated_files ${_source_file} )
- ENDIF()
+
ADD_EXECUTABLE(${_target} EXCLUDE_FROM_ALL
${_generated_files}
SET_TARGET_PROPERTIES(${_target} PROPERTIES
LINK_FLAGS "${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
- COMPILE_DEFINITIONS "${DEAL_II_DEFINITIONS};${DEAL_II_DEFINITIONS_${_build}}"
- COMPILE_FLAGS "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
LINKER_LANGUAGE "CXX"
- RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/${_test_short}"
+ RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}"
)
SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
INCLUDE_DIRECTORIES
${DEAL_II_INCLUDE_DIRS}
)
+ IF(CMAKE_VERSION VERSION_LESS 3.9)
+ SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
+ COMPILE_FLAGS " ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ )
+ SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
+ COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
+ )
+
+ ELSE()
+
+ SET(_flags "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_flags)
+ TARGET_COMPILE_OPTIONS(${_target} PUBLIC
+ $<$<COMPILE_LANGUAGE:CXX>:${_flags}>
+ )
+
+ TARGET_COMPILE_DEFINITIONS(${_target}
+ PUBLIC ${DEAL_II_DEFINITIONS} ${DEAL_II_DEFINITIONS_${_build}}
+ )
+
+ IF(DEAL_II_WITH_CUDA)
+ #
+ # Add cxx compiler and cuda compilation flags to cuda source files:
+ #
+
+ SET(_cuda_flags "${DEAL_II_CUDA_FLAGS} ${DEAL_II_CUDA_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_cuda_flags)
+
+ #
+ # Workaround: cuda will split every compiler option with a comma
+ # (','), so remove all compiler flags that contain a comma:
+ #
+ STRING(REGEX REPLACE "[^ ]*,[^ ]*" "" _cxx_flags
+ "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ )
+
+ TARGET_COMPILE_OPTIONS(${_target} PUBLIC
+ $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler "${_cxx_flags}">
+ $<$<COMPILE_LANGUAGE:CUDA>:${_cuda_flags}>
+ )
+
+ SET_TARGET_PROPERTIES(${_target} PROPERTIES
+ CUDA_SEPARABLE_COMPILATION TRUE
+ )
+ ENDIF()
+ ENDIF()
+
GET_PROPERTY(_type TARGET ${_target} PROPERTY TYPE)
IF(NOT "${_type}" STREQUAL "OBJECT_LIBRARY")
TARGET_LINK_LIBRARIES(${_target}
)
ENDIF()
-
#
# We can only append DEBUG link flags and compile definitions if deal.II
# was built with the Debug or DebugRelease build type. So test for this:
SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
INCLUDE_DIRECTORIES "${DEAL_II_INCLUDE_DIRS}"
)
- SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
- COMPILE_FLAGS " ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
- )
SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
LINK_FLAGS " ${DEAL_II_LINKER_FLAGS} ${DEAL_II_LINKER_FLAGS_${_build}}"
)
- SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
- COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
- )
+
+ IF(CMAKE_VERSION VERSION_LESS 3.9)
+ SET_PROPERTY(TARGET ${_target} APPEND_STRING PROPERTY
+ COMPILE_FLAGS " ${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ )
+ SET_PROPERTY(TARGET ${_target} APPEND PROPERTY
+ COMPILE_DEFINITIONS "${DEAL_II_USER_DEFINITIONS};${DEAL_II_USER_DEFINITIONS_${_build}}"
+ )
+
+ ELSE()
+
+ SET(_flags "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_flags)
+ TARGET_COMPILE_OPTIONS(${_target} PUBLIC
+ $<$<COMPILE_LANGUAGE:CXX>:${_flags}>
+ )
+
+ TARGET_COMPILE_DEFINITIONS(${_target}
+ PUBLIC ${DEAL_II_DEFINITIONS} ${DEAL_II_DEFINITIONS_${_build}}
+ )
+
+ IF(DEAL_II_WITH_CUDA)
+ #
+ # Add cxx compiler and cuda compilation flags to cuda source files:
+ #
+
+ SET(_cuda_flags "${DEAL_II_CUDA_FLAGS} ${DEAL_II_CUDA_FLAGS_${_build}}")
+ SEPARATE_ARGUMENTS(_cuda_flags)
+
+ #
+ # Workaround: cuda will split every compiler option with a comma
+ # (','), so remove all compiler flags that contain a comma:
+ #
+ STRING(REGEX REPLACE "[^ ]*,[^ ]*" "" _cxx_flags
+ "${DEAL_II_CXX_FLAGS} ${DEAL_II_CXX_FLAGS_${_build}}"
+ )
+
+ TARGET_COMPILE_OPTIONS(${_target} PUBLIC
+ $<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler "${_cxx_flags}">
+ $<$<COMPILE_LANGUAGE:CUDA>:${_cuda_flags}>
+ )
+
+ SET_TARGET_PROPERTIES(${_target} PROPERTIES
+ CUDA_SEPARABLE_COMPILATION TRUE
+ )
+ ENDIF()
+ ENDIF()
#
# Set up the link interface:
SET(${_var} "${${_var}}" CACHE STRING "" FORCE)
ENDFOREACH()
+IF(DEAL_II_WITH_CUDA)
+ PROJECT(blubb)
+ SET(CUDA_TOOLKIT_ROOT_DIR "${DEAL_II_CUDA_TOOLKIT_ROOT_DIR}")
+ FIND_PACKAGE(CUDA REQUIRED)
+ ENABLE_LANGUAGE(CUDA)
+ENDIF()
+
#
# A custom target that does absolutely nothing. It is used in the main
# project to trigger a "make rebuild_cache" if necessary.