Commit a51432ed authored by Brad King's avatar Brad King
Browse files

Drop support for lack of explicit template instantiation

VTK no longer supports any compilers that do not support explicit
template instantiation.  Drop our compatibility layer for this case.
parent b55c10e0
# Test whether the compiler supports explicit template instantiation.
# This actually creates a class template instantiation in one source
# file and tries to use it from another. This approach checks that
# both the instantiation syntax and symbol linkage is handled
# properly.
IF(NOT DEFINED VTK_EXPLICIT_TEMPLATES)
MESSAGE(STATUS "Checking support for C++ explicit template instantiation")
FILE(MAKE_DIRECTORY ${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation)
STRING(ASCII 35 POUND)
FILE(WRITE
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation/CMakeLists.txt
"CMAKE_MINIMUM_REQUIRED(VERSION 2.8)\n"
"PROJECT(EXPLICIT)\n"
"ADD_LIBRARY(A A.cxx)\n"
"ADD_EXECUTABLE(B B.cxx)\n"
"TARGET_LINK_LIBRARIES(B A)\n"
)
FILE(WRITE
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation/A.h
"${POUND}ifndef A_h\n"
"${POUND}define A_h\n"
"template <class T> class A { public: static T Method(); };\n"
"${POUND}endif\n"
)
FILE(WRITE
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation/A.cxx
"${POUND}include \"A.h\"\n"
"template <class T> T A<T>::Method() { return 0; }\n"
"template class A<int>;"
)
FILE(WRITE
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation/B.cxx
"${POUND}include \"A.h\"\n"
"int main() { return A<int>::Method(); }\n"
)
TRY_COMPILE(VTK_EXPLICIT_TEMPLATES
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation/Build
${VTK_BINARY_DIR}/CMakeTmp/TestExplicitInstantiation
EXPLICIT OUTPUT_VARIABLE OUTPUT
)
IF(VTK_EXPLICIT_TEMPLATES)
MESSAGE(STATUS "Checking support for C++ explicit template instantiation -- yes")
SET(VTK_EXPLICIT_TEMPLATES 1 CACHE INTERNAL "Support for C++ explict templates")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeOutput.log
"Determining if the C++ compiler supports explict template instantiation "
"passed with the following output:\n"
"${OUTPUT}\n")
ELSE()
MESSAGE(STATUS "Checking support for C++ explicit template instantiation -- no")
SET(VTK_EXPLICIT_TEMPLATES 0 CACHE INTERNAL "Support for C++ explict templates")
FILE(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log
"Determining if the C++ compiler supports explict template instantiation "
"failed with the following output:\n"
"${OUTPUT}\n")
ENDIF()
ENDIF()
......@@ -457,9 +457,6 @@ include(vtkTestTypes)
# Socket tests etc.
#INCLUDE(Parallel/VTKParallelCMakeTests.cmake)
# Check for explicit template instantiation support by compiler.
include(vtkTestExplicitInstantiation)
# Test for atomics and other compiler intrinsics
include(vtkTestBuiltins)
......
......@@ -337,8 +337,6 @@ macro(VTK_PREPARE_CMAKEDEFINE not invar outvar)
endmacro()
vtk_prepare_cmakedefine("" CMAKE_WORDS_BIGENDIAN VTK_WORDS_BIGENDIAN)
vtk_prepare_cmakedefine(NOT VTK_EXPLICIT_TEMPLATES
VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
# Provide version macros through vtkConfigure.h for compatibility.
if(VTK_LEGACY_REMOVE)
......
......@@ -108,13 +108,8 @@ private:
vtkAbstractArray* Array;
};
#if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
# define VTK_ARRAY_ITERATOR_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate< T >
#else
# include "vtkArrayIteratorTemplateImplicit.txx" // needed for templates.
# define VTK_ARRAY_ITERATOR_TEMPLATE_INSTANTIATE(T)
#endif // !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
#define VTK_ARRAY_ITERATOR_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkArrayIteratorTemplate< T >
#endif // !defined(vtkArrayIteratorTemplate_h)
......
......@@ -99,7 +99,6 @@
#define VTK_TYPE_CHAR_IS_SIGNED @VTK_TYPE_CHAR_IS_SIGNED@
/* Compiler features. */
#cmakedefine VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
#cmakedefine VTK_HAVE_GETSOCKNAME_WITH_SOCKLEN_T
#cmakedefine VTK_HAVE_SO_REUSEADDR
......
......@@ -368,13 +368,8 @@ private:
void DeleteArray();
};
#if !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
# define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkDataArrayTemplate< T >
#else
# include "vtkDataArrayTemplateImplicit.txx"
# define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T)
#endif
#define VTK_DATA_ARRAY_TEMPLATE_INSTANTIATE(T) \
template class VTKCOMMONCORE_EXPORT vtkDataArrayTemplate< T >
// This macro is used by the subclasses to create dummy
// declarations for these functions such that the wrapper
......@@ -410,7 +405,7 @@ private:
// This portion must be OUTSIDE the include blockers. Each
// vtkDataArray subclass uses this to give its instantiation of this
// template a DLL interface.
#if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE) && !defined(VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION)
#if defined(VTK_DATA_ARRAY_TEMPLATE_TYPE)
# if defined(VTK_BUILD_SHARED_LIBS) && defined(_MSC_VER)
# pragma warning (push)
# pragma warning (disable: 4091) // warning C4091: 'extern ' :
......
......@@ -15,8 +15,6 @@
#include "vtkImageIterator.txx"
#ifndef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<signed char>;
template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<char>;
template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<int>;
......@@ -36,5 +34,3 @@ template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<unsigned long long>;
template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<__int64>;
template class VTKCOMMONDATAMODEL_EXPORT vtkImageIterator<unsigned __int64>;
#endif
#endif
......@@ -80,9 +80,5 @@ protected:
vtkIdType ContinuousIncrements[3];
};
#ifdef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
#include "vtkImageIterator.txx"
#endif
#endif
// VTK-HeaderTest-Exclude: vtkImageIterator.h
......@@ -12,9 +12,6 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Include blockers needed since vtkImageIterator.h includes this file
// when VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION is defined.
#ifndef vtkImageIterator_txx
#define vtkImageIterator_txx
......
......@@ -30,8 +30,6 @@
#include "vtkImageProgressIterator.txx"
#ifndef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<signed char>;
template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<char>;
template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<int>;
......@@ -51,6 +49,3 @@ template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<unsigned
template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<__int64>;
template class VTKCOMMONEXECUTIONMODEL_EXPORT vtkImageProgressIterator<unsigned __int64>;
#endif
#endif
......@@ -58,9 +58,5 @@ protected:
int ID;
};
#ifdef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
#include "vtkImageProgressIterator.txx"
#endif
#endif
// VTK-HeaderTest-Exclude: vtkImageProgressIterator.h
......@@ -12,8 +12,6 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Include blockers needed since vtkImageProgressIterator.h includes
// this file when VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION is defined.
#ifndef vtkImageProgressIterator_txx
#define vtkImageProgressIterator_txx
......
......@@ -15,8 +15,6 @@
#include "vtkImageStencilIterator.txx"
#ifndef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<signed char>;
template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<char>;
template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<int>;
......@@ -36,5 +34,3 @@ template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<unsigned long long>
template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<__int64>;
template class VTKIMAGINGCORE_EXPORT vtkImageStencilIterator<unsigned __int64>;
#endif
#endif
......@@ -136,9 +136,5 @@ protected:
vtkIdType Target;
};
#ifdef VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION
#include "vtkImageStencilIterator.txx"
#endif
#endif
// VTK-HeaderTest-Exclude: vtkImageStencilIterator.h
......@@ -12,9 +12,6 @@
PURPOSE. See the above copyright notice for more information.
=========================================================================*/
// Include blockers needed since vtkImageStencilIterator.h includes
// this file when VTK_NO_EXPLICIT_TEMPLATE_INSTANTIATION is defined.
#ifndef vtkImageStencilIterator_txx
#define vtkImageStencilIterator_txx
......
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