Export CUDA static library requirements properly

This is a work around while we wait on requiring CMake 3.15 for all
cuda builds. At that point we can replace this with setting
`requires_static_builds` as part of the EXPORT_PROPERTIES of the
vtkm_cuda target.

This has been tested with the ascent proxy
This commit is contained in:
Robert Maynard 2019-08-27 13:34:49 -04:00
parent 6b0614e577
commit a65afa11ba
3 changed files with 8 additions and 3 deletions

@ -98,6 +98,7 @@ endif()
# EXPORT_PROPERTIES of the vtkm_cuda target
if(VTKm_ENABLE_CUDA AND VTKM_FROM_INSTALL_DIR)
set_target_properties(vtkm::cuda PROPERTIES cuda_architecture_flags "@VTKm_CUDA_Architecture_Flags@")
set_target_properties(vtkm::cuda PROPERTIES requires_static_builds TRUE)
endif()
# VTKm requires some CMake Find modules not included with CMake, so

@ -121,14 +121,18 @@ if(VTKm_ENABLE_CUDA)
set_target_properties(vtkm_cuda PROPERTIES EXPORT_NAME vtkm::cuda)
install(TARGETS vtkm_cuda EXPORT ${VTKm_EXPORT_NAME})
# Reserve `INTERFACE_REQUIRES_STATIC_BUILDS` to potential work around issues
# Reserve `requires_static_builds` to potential work around issues
# where VTK-m doesn't work when building shared as virtual functions fail
# inside device code. We don't want to force BUILD_SHARED_LIBS to a specific
# value as that could impact other projects that embed VTK-m. Instead what
# we do is make sure that libraries built by vtkm_library() are static
# if they use CUDA
#
# This needs to be lower-case for the property to be properly exported
# CMake 3.15 we can add `requires_static_builds` to the EXPORT_PROPERTIES
# target property to have this automatically exported for us
set_target_properties(vtkm_cuda PROPERTIES
INTERFACE_REQUIRES_STATIC_BUILDS TRUE
requires_static_builds TRUE
)

@ -207,7 +207,7 @@ function(vtkm_add_target_information uses_vtkm_target)
# dynamic library boundaries.
if(TARGET vtkm::cuda)
get_target_property(lib_type ${uses_vtkm_target} TYPE)
get_target_property(requires_static vtkm::cuda INTERFACE_REQUIRES_STATIC_BUILDS)
get_target_property(requires_static vtkm::cuda requires_static_builds)
if(requires_static AND ${lib_type} STREQUAL "SHARED_LIBRARY" AND VTKm_TI_EXTENDS_VTKM)
#We provide different error messages based on if we are building VTK-m