From d8d6fd17416742bf866c30528e90f1aa79092368 Mon Sep 17 00:00:00 2001 From: Robert Maynard Date: Fri, 16 Dec 2016 16:51:04 -0500 Subject: [PATCH] StorageTags are now always exported to resolve future dynamic_cast issues. Class that need to be passed across dynamic library boundaries such as DynamicArrayHandle need to be properly export. One of 'tricks' of this is that templated classes such as PolymorphicArrayHandleContainer need the Type and Storage types to have public visibility. This makes sure that all vtkm storage tags have public visibility so in the future we can transfer dynamic array handles across libraries. --- CMake/VTKmConfigureComponents.cmake | 2 +- CMake/VTKmMacros.cmake | 22 ++++++++++++++----- vtkm/cont/ArrayHandle.h | 2 +- vtkm/cont/ArrayHandleCartesianProduct.h | 2 +- vtkm/cont/ArrayHandleCompositeVector.h | 2 +- vtkm/cont/ArrayHandleGroupVec.h | 2 +- vtkm/cont/ArrayHandleGroupVecVariable.h | 2 +- vtkm/cont/ArrayHandlePermutation.h | 2 +- vtkm/cont/ArrayHandleStreaming.h | 2 +- vtkm/cont/ArrayHandleTransform.h | 2 +- vtkm/cont/ArrayHandleZip.h | 2 +- vtkm/cont/CellSetListTag.h | 16 +++++++------- vtkm/cont/DynamicArrayHandle.h | 4 ++-- vtkm/cont/DynamicCellSet.h | 2 +- vtkm/cont/Storage.h | 4 ++-- vtkm/cont/StorageBasic.h | 2 +- vtkm/cont/StorageImplicit.h | 2 +- vtkm/cont/StorageListTag.h | 2 +- vtkm/cont/cuda/ArrayHandleCuda.h | 2 +- .../internal/SimplePolymorphicContainer.h | 4 +++- vtkm/cont/internal/StorageError.h | 3 ++- 21 files changed, 49 insertions(+), 34 deletions(-) diff --git a/CMake/VTKmConfigureComponents.cmake b/CMake/VTKmConfigureComponents.cmake index b927bf9f2..6c0577b7f 100644 --- a/CMake/VTKmConfigureComponents.cmake +++ b/CMake/VTKmConfigureComponents.cmake @@ -110,7 +110,7 @@ macro(vtkm_configure_component_Base) vtkm_finish_configure_component(Base DEPENDENT_VARIABLES VTKm_base_vtkm_target_FOUND - ADD_LIBRARIES vtkm + ADD_LIBRARIES vtkm vtkm_cont ) endmacro() diff --git a/CMake/VTKmMacros.cmake b/CMake/VTKmMacros.cmake index 3167f81ea..23c19726e 100755 --- a/CMake/VTKmMacros.cmake +++ b/CMake/VTKmMacros.cmake @@ -630,7 +630,13 @@ function(vtkm_library) set_property(TARGET ${lib_name} APPEND PROPERTY INCLUDE_DIRECTORIES ${VTKm_INCLUDE_DIRS} ) - target_link_libraries(${lib_name} ${VTKm_LIBRARIES}) + set(lib_subset) + foreach(lib ${VTKm_LIBRARIES}) + if(NOT lib STREQUAL lib_name) + list(APPEND lib_subset ${lib}) + endif() + endforeach() + target_link_libraries(${lib_name} ${lib_subset}) set(cxx_args ${VTKm_COMPILE_OPTIONS}) separate_arguments(cxx_args) @@ -660,11 +666,17 @@ function(vtkm_library) #template classes. This string(TOUPPER ${lib_name} BASE_NAME_UPPER) set(EXPORT_MACRO_NAME "${BASE_NAME_UPPER}") - set(EXPORT_IS_BUILT_STATIC false) + + set(EXPORT_IS_BUILT_STATIC 0) + get_target_property(is_static ${lib_name} TYPE) + if(${is_static} STREQUAL "STATIC_LIBRARY") + #If we are building statically set the define symbol + set(EXPORT_IS_BUILT_STATIC 1) + endif() + unset(is_static) + get_target_property(EXPORT_IMPORT_CONDITION ${lib_name} DEFINE_SYMBOL) if(NOT EXPORT_IMPORT_CONDITION) - #If we are building statically set the define symbol - set(EXPORT_IS_BUILT_STATIC true) #set EXPORT_IMPORT_CONDITION to what the DEFINE_SYMBOL would be when #building shared set(EXPORT_IMPORT_CONDITION ${lib_name}_EXPORTS) @@ -676,8 +688,8 @@ function(vtkm_library) @ONLY) unset(EXPORT_MACRO_NAME) - unset(EXPORT_IMPORT_CONDITION) unset(EXPORT_IS_BUILT_STATIC) + unset(EXPORT_IMPORT_CONDITION) install(TARGETS ${lib_name} EXPORT ${VTKm_EXPORT_NAME} diff --git a/vtkm/cont/ArrayHandle.h b/vtkm/cont/ArrayHandle.h index 23b566907..f8d9ff614 100644 --- a/vtkm/cont/ArrayHandle.h +++ b/vtkm/cont/ArrayHandle.h @@ -221,7 +221,7 @@ struct GetTypeInParentheses template< typename T, typename StorageTag_ = VTKM_DEFAULT_STORAGE_TAG> -class ArrayHandle : public internal::ArrayHandleBase +class VTKM_ALWAYS_EXPORT ArrayHandle : public internal::ArrayHandleBase { private: typedef vtkm::cont::internal::ArrayHandleExecutionManagerBase diff --git a/vtkm/cont/ArrayHandleCartesianProduct.h b/vtkm/cont/ArrayHandleCartesianProduct.h index 3d938154e..8af324950 100644 --- a/vtkm/cont/ArrayHandleCartesianProduct.h +++ b/vtkm/cont/ArrayHandleCartesianProduct.h @@ -151,7 +151,7 @@ namespace cont { namespace internal { template -struct StorageTagCartesianProduct { }; +struct VTKM_ALWAYS_EXPORT StorageTagCartesianProduct { }; /// This helper struct defines the value type for a zip container containing /// the given two array handles. diff --git a/vtkm/cont/ArrayHandleCompositeVector.h b/vtkm/cont/ArrayHandleCompositeVector.h index 7aa3e91ed..bff6aa229 100644 --- a/vtkm/cont/ArrayHandleCompositeVector.h +++ b/vtkm/cont/ArrayHandleCompositeVector.h @@ -219,7 +219,7 @@ private: }; template -struct StorageTagCompositeVector { }; +struct VTKM_ALWAYS_EXPORT StorageTagCompositeVector { }; /// A convenience class that provides a typedef to the appropriate tag for /// a composite storage. diff --git a/vtkm/cont/ArrayHandleGroupVec.h b/vtkm/cont/ArrayHandleGroupVec.h index 6e9d0d490..47f3bd9b6 100644 --- a/vtkm/cont/ArrayHandleGroupVec.h +++ b/vtkm/cont/ArrayHandleGroupVec.h @@ -115,7 +115,7 @@ namespace cont { namespace internal { template -struct StorageTagGroupVec { }; +struct VTKM_ALWAYS_EXPORT StorageTagGroupVec { }; template diff --git a/vtkm/cont/ArrayHandleGroupVecVariable.h b/vtkm/cont/ArrayHandleGroupVecVariable.h index e40fc71eb..298c1c7b1 100644 --- a/vtkm/cont/ArrayHandleGroupVecVariable.h +++ b/vtkm/cont/ArrayHandleGroupVecVariable.h @@ -180,7 +180,7 @@ namespace cont { namespace internal { template -struct StorageTagGroupVecVariable { }; +struct VTKM_ALWAYS_EXPORT StorageTagGroupVecVariable { }; template class Storage< diff --git a/vtkm/cont/ArrayHandlePermutation.h b/vtkm/cont/ArrayHandlePermutation.h index 0ec8f6b93..a55874cc8 100644 --- a/vtkm/cont/ArrayHandlePermutation.h +++ b/vtkm/cont/ArrayHandlePermutation.h @@ -104,7 +104,7 @@ namespace cont { namespace internal { template -struct StorageTagPermutation { }; +struct VTKM_ALWAYS_EXPORT StorageTagPermutation { }; template class Storage< diff --git a/vtkm/cont/ArrayHandleStreaming.h b/vtkm/cont/ArrayHandleStreaming.h index 524c259ef..8c6db915d 100644 --- a/vtkm/cont/ArrayHandleStreaming.h +++ b/vtkm/cont/ArrayHandleStreaming.h @@ -97,7 +97,7 @@ private: } // internal template -struct StorageTagStreaming { }; +struct VTKM_ALWAYS_EXPORT StorageTagStreaming { }; namespace internal { diff --git a/vtkm/cont/ArrayHandleTransform.h b/vtkm/cont/ArrayHandleTransform.h index 54870674f..23101c3e5 100644 --- a/vtkm/cont/ArrayHandleTransform.h +++ b/vtkm/cont/ArrayHandleTransform.h @@ -155,7 +155,7 @@ namespace internal { template -struct StorageTagTransform {}; +struct VTKM_ALWAYS_EXPORT StorageTagTransform {}; template class Storage > diff --git a/vtkm/cont/ArrayHandleZip.h b/vtkm/cont/ArrayHandleZip.h index 6ced6c7ca..ee2ab2d73 100644 --- a/vtkm/cont/ArrayHandleZip.h +++ b/vtkm/cont/ArrayHandleZip.h @@ -101,7 +101,7 @@ namespace cont { namespace internal { template -struct StorageTagZip { }; +struct VTKM_ALWAYS_EXPORT StorageTagZip { }; /// This helper struct defines the value type for a zip container containing /// the given two array handles. diff --git a/vtkm/cont/CellSetListTag.h b/vtkm/cont/CellSetListTag.h index 6e620271f..87d5cd10c 100644 --- a/vtkm/cont/CellSetListTag.h +++ b/vtkm/cont/CellSetListTag.h @@ -33,20 +33,20 @@ namespace vtkm { namespace cont { -struct CellSetListTagStructured1D +struct VTKM_ALWAYS_EXPORT CellSetListTagStructured1D : vtkm::ListTagBase > { }; -struct CellSetListTagStructured2D +struct VTKM_ALWAYS_EXPORT CellSetListTagStructured2D : vtkm::ListTagBase > { }; -struct CellSetListTagStructured3D +struct VTKM_ALWAYS_EXPORT CellSetListTagStructured3D : vtkm::ListTagBase > { }; template -struct CellSetListTagExplicit +struct VTKM_ALWAYS_EXPORT CellSetListTagExplicit : vtkm::ListTagBase< vtkm::cont::CellSetExplicit< ShapeStorageTag, @@ -54,11 +54,11 @@ struct CellSetListTagExplicit ConnectivityStorageTag, OffsetsStorageTag> > { }; -struct CellSetListTagExplicitDefault +struct VTKM_ALWAYS_EXPORT CellSetListTagExplicitDefault : CellSetListTagExplicit<> { }; -struct CellSetListTagCommon +struct VTKM_ALWAYS_EXPORT CellSetListTagCommon : vtkm::ListTagBase< vtkm::cont::CellSetStructured<2>, vtkm::cont::CellSetStructured<3>, @@ -66,13 +66,13 @@ struct CellSetListTagCommon vtkm::cont::CellSetSingleType<> > { }; -struct CellSetListTagStructured +struct VTKM_ALWAYS_EXPORT CellSetListTagStructured : vtkm::ListTagBase< vtkm::cont::CellSetStructured<2>, vtkm::cont::CellSetStructured<3> > { }; -struct CellSetListTagUnstructured +struct VTKM_ALWAYS_EXPORT CellSetListTagUnstructured : vtkm::ListTagBase< vtkm::cont::CellSetExplicit<>, vtkm::cont::CellSetSingleType<> diff --git a/vtkm/cont/DynamicArrayHandle.h b/vtkm/cont/DynamicArrayHandle.h index 81e913f8f..3ef439d0f 100644 --- a/vtkm/cont/DynamicArrayHandle.h +++ b/vtkm/cont/DynamicArrayHandle.h @@ -63,7 +63,7 @@ struct PolymorphicArrayHandleContainerBase /// simple questions about the object. /// template -struct PolymorphicArrayHandleContainer +struct VTKM_ALWAYS_EXPORT PolymorphicArrayHandleContainer : public PolymorphicArrayHandleContainerBase { typedef vtkm::cont::ArrayHandle ArrayHandleType; @@ -184,7 +184,7 @@ DynamicArrayHandleTryCast( /// lists. /// template -class DynamicArrayHandleBase +class VTKM_ALWAYS_EXPORT DynamicArrayHandleBase { public: VTKM_CONT diff --git a/vtkm/cont/DynamicCellSet.h b/vtkm/cont/DynamicCellSet.h index ebf6cfdfd..cc6232db0 100644 --- a/vtkm/cont/DynamicCellSet.h +++ b/vtkm/cont/DynamicCellSet.h @@ -116,7 +116,7 @@ DynamicCellSetTryCast( /// with the default cell set list. /// template -class DynamicCellSetBase +class VTKM_ALWAYS_EXPORT DynamicCellSetBase { VTKM_IS_LIST_TAG(CellSetList); public: diff --git a/vtkm/cont/Storage.h b/vtkm/cont/Storage.h index aea85163a..96fa8d50e 100644 --- a/vtkm/cont/Storage.h +++ b/vtkm/cont/Storage.h @@ -55,11 +55,11 @@ namespace cont { /// StorageTagBasic. /// /// To implement your own StorageTag, you first must create a tag class (an -/// empty struct) defining your tag (i.e. struct StorageTagMyAlloc { };). Then +/// empty struct) defining your tag (i.e. struct VTKM_ALWAYS_EXPORT StorageTagMyAlloc { };). Then /// provide a partial template specialization of vtkm::cont::internal::Storage /// for your new tag. /// -struct StorageTag___ { }; +struct VTKM_ALWAYS_EXPORT StorageTag___ { }; #endif // VTKM_DOXYGEN_ONLY namespace internal { diff --git a/vtkm/cont/StorageBasic.h b/vtkm/cont/StorageBasic.h index e2ea527f5..8abad9690 100755 --- a/vtkm/cont/StorageBasic.h +++ b/vtkm/cont/StorageBasic.h @@ -58,7 +58,7 @@ namespace vtkm { namespace cont { /// A tag for the basic implementation of a Storage object. -struct StorageTagBasic { }; +struct VTKM_ALWAYS_EXPORT StorageTagBasic { }; namespace internal { diff --git a/vtkm/cont/StorageImplicit.h b/vtkm/cont/StorageImplicit.h index aec40826b..773cbd7ff 100644 --- a/vtkm/cont/StorageImplicit.h +++ b/vtkm/cont/StorageImplicit.h @@ -42,7 +42,7 @@ namespace cont { /// any operation that tries to modify it. /// template -struct StorageTagImplicit +struct VTKM_ALWAYS_EXPORT StorageTagImplicit { typedef ArrayPortalType PortalType; }; diff --git a/vtkm/cont/StorageListTag.h b/vtkm/cont/StorageListTag.h index 790377f70..c1d752e8a 100644 --- a/vtkm/cont/StorageListTag.h +++ b/vtkm/cont/StorageListTag.h @@ -32,7 +32,7 @@ namespace vtkm { namespace cont { -struct StorageListTagBasic +struct VTKM_ALWAYS_EXPORT StorageListTagBasic : vtkm::ListTagBase { }; } diff --git a/vtkm/cont/cuda/ArrayHandleCuda.h b/vtkm/cont/cuda/ArrayHandleCuda.h index d5b6fe2f3..0498f14f4 100644 --- a/vtkm/cont/cuda/ArrayHandleCuda.h +++ b/vtkm/cont/cuda/ArrayHandleCuda.h @@ -39,7 +39,7 @@ namespace vtkm { namespace cont { namespace cuda { -struct StorageTagCuda { }; +struct VTKM_ALWAYS_EXPORT StorageTagCuda { }; } // namespace cuda } // namespace cont diff --git a/vtkm/cont/internal/SimplePolymorphicContainer.h b/vtkm/cont/internal/SimplePolymorphicContainer.h index 63f29be00..509ca9131 100644 --- a/vtkm/cont/internal/SimplePolymorphicContainer.h +++ b/vtkm/cont/internal/SimplePolymorphicContainer.h @@ -20,6 +20,8 @@ #ifndef vtk_m_cont_internal_SimplePolymorphicContainer_h #define vtk_m_cont_internal_SimplePolymorphicContainer_h +#include + #include #include @@ -49,7 +51,7 @@ struct SimplePolymorphicContainerBase { /// allows for safer dynamic downcasts. /// template -struct SimplePolymorphicContainer : public SimplePolymorphicContainerBase +struct VTKM_ALWAYS_EXPORT SimplePolymorphicContainer : public SimplePolymorphicContainerBase { T Item; diff --git a/vtkm/cont/internal/StorageError.h b/vtkm/cont/internal/StorageError.h index c2965c946..b623ba3e6 100644 --- a/vtkm/cont/internal/StorageError.h +++ b/vtkm/cont/internal/StorageError.h @@ -20,6 +20,7 @@ #ifndef vtkm_cont_internal_StorageError_h #define vtkm_cont_internal_StorageError_h +#include namespace vtkm { namespace cont { @@ -30,7 +31,7 @@ namespace internal { /// point, you have to specify an appropriate Storage or else get a compile /// error. /// -struct StorageTagError +struct VTKM_ALWAYS_EXPORT StorageTagError { // Not implemented. };