Commit deb4946a authored by Robert Maynard's avatar Robert Maynard

Make sure vtk-m libraries under CUDA 8 are always built statically

parent 9c496e5d
......@@ -134,6 +134,17 @@ if(VTKm_ENABLE_CUDA AND NOT TARGET vtkm::cuda)
add_library(vtkm::cuda UNKNOWN IMPORTED GLOBAL)
endif()
# Workaround issue with CUDA 8.X where virtual don't work when building
# VTK-m as shared. 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
if(CMAKE_CUDA_COMPILER_VERSION VERSION_LESS 9.0)
set_target_properties(vtkm::cuda PROPERTIES REQUIRES_STATIC_BUILDS TRUE)
else()
set_target_properties(vtkm::cuda PROPERTIES REQUIRES_STATIC_BUILDS FALSE)
endif()
set_target_properties(vtkm::cuda PROPERTIES
INTERFACE_COMPILE_OPTIONS $<$<COMPILE_LANGUAGE:CUDA>:--expt-relaxed-constexpr>
)
......
......@@ -282,16 +282,31 @@ function(vtkm_library)
endif()
set(lib_name ${VTKm_LIB_NAME})
if(VTKm_LIB_STATIC)
set(VTKm_LIB_type STATIC)
else()
if(VTKm_LIB_SHARED)
set(VTKm_LIB_type SHARED)
endif()
#if cuda requires static libaries force
#them no matter what
if(TARGET vtkm::cuda)
get_target_property(force_static vtkm::cuda REQUIRES_STATIC_BUILDS)
if(force_static)
set(VTKm_LIB_type STATIC)
message("Forcing ${lib_name} to be built statically as we are using CUDA 8.X, which doesn't support virtuals sufficiently in dynamic libraries.")
endif()
endif()
endif()
if(TARGET vtkm::cuda)
vtkm_compile_as_cuda(cu_srcs ${VTKm_LIB_WRAP_FOR_CUDA})
set(VTKm_LIB_WRAP_FOR_CUDA ${cu_srcs})
endif()
if(VTKm_LIB_STATIC)
set(VTKm_LIB_type STATIC)
elseif(VTKm_LIB_SHARED)
set(VTKm_LIB_type SHARED)
endif()
add_library(${lib_name}
${VTKm_LIB_type}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment