diff options
author | Brad King <brad.king@kitware.com> | 2005-04-15 13:54:03 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2005-04-15 13:54:03 (GMT) |
commit | 6c68c8147532bbc07e467b6e80cbfbee07b99f26 (patch) | |
tree | 2748e864e7b3f90576e20153ee7eb53107938abe | |
parent | 4caefef37eb2f23948d915a6d33447ef4e6243c1 (diff) | |
download | CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.zip CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.tar.gz CMake-6c68c8147532bbc07e467b6e80cbfbee07b99f26.tar.bz2 |
ENH: Added KWSys try-compiles KWSYS_STL_HAS_ITERATOR_TRAITS, KWSYS_STL_HAS_ITERATOR_CATEGORY, KWSYS_STL_HAS___ITERATOR_CATEGORY, and KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE to get the hash table to compile on old HP and Sun compilers.
-rw-r--r-- | Source/kwsys/CMakeLists.txt | 30 | ||||
-rw-r--r-- | Source/kwsys/Configure.hxx.in | 16 | ||||
-rw-r--r-- | Source/kwsys/hash_map.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/hash_set.hxx.in | 4 | ||||
-rw-r--r-- | Source/kwsys/hashtable.hxx.in | 54 | ||||
-rw-r--r-- | Source/kwsys/kwsysPlatformCxxTests.cxx | 24 | ||||
-rwxr-xr-x | bootstrap | 65 |
7 files changed, 170 insertions, 27 deletions
diff --git a/Source/kwsys/CMakeLists.txt b/Source/kwsys/CMakeLists.txt index 6423089..3e2dee8 100644 --- a/Source/kwsys/CMakeLists.txt +++ b/Source/kwsys/CMakeLists.txt @@ -182,10 +182,32 @@ SET(KWSYS_PLATFORM_CXX_TEST_DEFINES -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}) KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_STRING_HAVE_NEQ_CHAR "Checking whether stl string has operator!= for char*" DIRECT) -KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND - "Checking for rebind member of stl allocator" DIRECT) -KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT - "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_TRAITS + "Checking whether stl has iterator_traits" DIRECT) +IF(KWSYS_STL_HAS_ITERATOR_TRAITS) + SET(KWSYS_STL_HAS_ITERATOR_CATEGORY 0) + SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) +ELSE(KWSYS_STL_HAS_ITERATOR_TRAITS) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ITERATOR_CATEGORY + "Checking whether stl has old iterator_category" DIRECT) + IF(KWSYS_STL_HAS_ITERATOR_CATEGORY) + SET(KWSYS_STL_HAS___ITERATOR_CATEGORY 0) + ELSE(KWSYS_STL_HAS_ITERATOR_CATEGORY) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS___ITERATOR_CATEGORY + "Checking whether stl has internal __iterator_category" DIRECT) + ENDIF(KWSYS_STL_HAS_ITERATOR_CATEGORY) +ENDIF(KWSYS_STL_HAS_ITERATOR_TRAITS) +KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE + "Checking whether stl has old non-template allocator" DIRECT) +IF(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) + SET(KWSYS_STL_HAS_ALLOCATOR_REBIND 0) + SET(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT 0) +ELSE(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_REBIND + "Checking for rebind member of stl allocator" DIRECT) + KWSYS_PLATFORM_CXX_TEST(KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT + "Checking for non-standard argument to stl allocator<>::max_size" DIRECT) +ENDIF(KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE) IF(KWSYS_IOS_USE_ANSI) # ANSI streams always have string operators. SET(KWSYS_STL_STRING_HAVE_OSTREAM 1) diff --git a/Source/kwsys/Configure.hxx.in b/Source/kwsys/Configure.hxx.in index 3cddb34..5b9268c 100644 --- a/Source/kwsys/Configure.hxx.in +++ b/Source/kwsys/Configure.hxx.in @@ -96,6 +96,18 @@ # define @KWSYS_NAMESPACE@_CXX_DECL_TYPENAME typename #endif +/* Whether the stl has iterator_traits. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS @KWSYS_STL_HAS_ITERATOR_TRAITS@ + +/* Whether the stl has iterator_category. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY @KWSYS_STL_HAS_ITERATOR_CATEGORY@ + +/* Whether the stl has __iterator_category. */ +#define @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY @KWSYS_STL_HAS___ITERATOR_CATEGORY@ + +/* Whether the stl allocator is not a template. */ +#define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@ + /* Whether the stl allocator has rebind. */ #define @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND @KWSYS_STL_HAS_ALLOCATOR_REBIND@ @@ -132,6 +144,10 @@ # define KWSYS_STL_HAS_ALLOCATOR_REBIND @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_REBIND # define KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT # define KWSYS_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP @KWSYS_NAMESPACE@_CXX_HAS_ARGUMENT_DEPENDENT_LOOKUP +# define KWSYS_STL_HAS_ITERATOR_TRAITS @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS +# define KWSYS_STL_HAS_ITERATOR_CATEGORY @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY +# define KWSYS_STL_HAS___ITERATOR_CATEGORY @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY +# define KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE #endif #endif diff --git a/Source/kwsys/hash_map.hxx.in b/Source/kwsys/hash_map.hxx.in index d0ff1bd..e73080a 100644 --- a/Source/kwsys/hash_map.hxx.in +++ b/Source/kwsys/hash_map.hxx.in @@ -71,7 +71,7 @@ struct hash_select1st: template <class _Key, class _Tp, class _HashFcn = hash<_Key>, class _EqualKey = kwsys_stl::equal_to<_Key>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_map; template <class _Key, class _Tp, class _HashFn, class _EqKey, class _Alloc> @@ -263,7 +263,7 @@ swap(hash_map<_Key,_Tp,_HashFcn,_EqlKey,_Alloc>& __hm1, template <class _Key, class _Tp, class _HashFcn = hash<_Key>, class _EqualKey = kwsys_stl::equal_to<_Key>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_multimap; template <class _Key, class _Tp, class _HF, class _EqKey, class _Alloc> diff --git a/Source/kwsys/hash_set.hxx.in b/Source/kwsys/hash_set.hxx.in index e627f5d..554e31b 100644 --- a/Source/kwsys/hash_set.hxx.in +++ b/Source/kwsys/hash_set.hxx.in @@ -69,7 +69,7 @@ struct _Identity : public kwsys_stl::unary_function<_Tp,_Tp> template <class _Value, class _HashFcn = hash<_Value>, class _EqualKey = kwsys_stl::equal_to<_Value>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_set; template <class _Value, class _HashFcn, class _EqualKey, class _Alloc> @@ -257,7 +257,7 @@ swap(hash_set<_Val,_HashFcn,_EqualKey,_Alloc>& __hs1, template <class _Value, class _HashFcn = hash<_Value>, class _EqualKey = kwsys_stl::equal_to<_Value>, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hash_multiset; template <class _Val, class _HashFcn, class _EqualKey, class _Alloc> diff --git a/Source/kwsys/hashtable.hxx.in b/Source/kwsys/hashtable.hxx.in index cb2f19f..5d989d9 100644 --- a/Source/kwsys/hashtable.hxx.in +++ b/Source/kwsys/hashtable.hxx.in @@ -54,6 +54,12 @@ # pragma warning (disable:4786) #endif +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE +# define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) kwsys_stl::allocator +#else +# define @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(T) kwsys_stl::allocator< T > +#endif + namespace @KWSYS_NAMESPACE@ { @@ -72,8 +78,13 @@ class hash_allocator: public hash_allocator_base private: // Store the real allocator privately. typedef Alloc alloc_type; +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + typedef char alloc_value_type; + typedef void* alloc_pointer; +#else typedef typename alloc_type::value_type alloc_value_type; typedef typename alloc_type::pointer alloc_pointer; +#endif alloc_type alloc_; public: @@ -97,11 +108,17 @@ public: # endif pointer address(reference x) const { return &x; } const_pointer address(const_reference x) const { return &x; } - pointer allocate(size_type n=1, kwsys_stl::allocator<void>::const_pointer hint = 0) +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + typedef void* void_pointer; + typedef const void* const_void_pointer; +#else + typedef kwsys_stl::allocator<void>::pointer void_pointer; + typedef kwsys_stl::allocator<void>::const_pointer const_void_pointer; +#endif + pointer allocate(size_type n=1, const_void_pointer hint = 0) { if(n) { - typedef kwsys_stl::allocator<void>::pointer void_pointer; return static_cast<pointer>( static_cast<void*>( @@ -116,7 +133,12 @@ public: { if(n) { - alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), n*chunk()); +#if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_NONTEMPLATE + alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p))); +#else + alloc_.deallocate(static_cast<alloc_pointer>(static_cast<void*>(p)), + n*chunk()); +#endif } } #if @KWSYS_NAMESPACE@_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT @@ -151,7 +173,7 @@ struct _Hashtable_node template <class _Val, class _Key, class _HashFcn, class _ExtractKey, class _EqualKey, - class _Alloc = kwsys_stl::allocator<char> > + class _Alloc = @KWSYS_NAMESPACE@_HASH_DEFAULT_ALLOCATOR(char) > class hashtable; template <class _Val, class _Key, class _HashFcn, @@ -459,21 +481,31 @@ public: kwsys_stl::pair<iterator, bool> insert_unique_noresize(const value_type& __obj); iterator insert_equal_noresize(const value_type& __obj); -#if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES +#if @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_TRAITS +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + typename kwsys_stl::iterator_traits< T >::iterator_category() +#elif @KWSYS_NAMESPACE@_STL_HAS_ITERATOR_CATEGORY +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + kwsys_stl::iterator_category( I ) +#elif @KWSYS_NAMESPACE@_STL_HAS___ITERATOR_CATEGORY +# define @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(T,I) \ + kwsys_stl::__iterator_category( I ) +#endif + +#if @KWSYS_NAMESPACE@_CXX_HAS_MEMBER_TEMPLATES && \ + defined(@KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY) template <class _InputIterator> void insert_unique(_InputIterator __f, _InputIterator __l) { - typedef typename kwsys_stl::iterator_traits<_InputIterator>::iterator_category - iterator_category; - insert_unique(__f, __l, iterator_category()); + insert_unique(__f, __l, + @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); } template <class _InputIterator> void insert_equal(_InputIterator __f, _InputIterator __l) { - typedef typename kwsys_stl::iterator_traits<_InputIterator>::iterator_category - iterator_category; - insert_equal(__f, __l, iterator_category()); + insert_equal(__f, __l, + @KWSYS_NAMESPACE@_HASH_ITERATOR_CATEGORY(_InputIterator, __f)); } template <class _InputIterator> diff --git a/Source/kwsys/kwsysPlatformCxxTests.cxx b/Source/kwsys/kwsysPlatformCxxTests.cxx index 9edbfc0..a8b3d6f 100644 --- a/Source/kwsys/kwsysPlatformCxxTests.cxx +++ b/Source/kwsys/kwsysPlatformCxxTests.cxx @@ -122,6 +122,30 @@ int main() } #endif +#ifdef TEST_KWSYS_STL_HAS_ITERATOR_TRAITS +#include <iterator> +void f(kwsys_stl::iterator_traits<int*>::iterator_category const&) {} +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS_ITERATOR_CATEGORY +#include <iterator> +void f(int* x) { kwsys_stl::iterator_category(x); } +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS___ITERATOR_CATEGORY +#include <iterator> +void f(int* x) { kwsys_stl::__iterator_category(x); } +int main() { return 0; } +#endif + +#ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE +#include <memory> +void f(kwsys_stl::allocator const&) {} +int main() { return 0; } +#endif + #ifdef TEST_KWSYS_STL_HAS_ALLOCATOR_REBIND #include <memory> template <class T, class Alloc> @@ -203,6 +203,10 @@ cmake_kwsys_config_replace_string () s/@KWSYS_STL_STRING_HAVE_ISTREAM@/${KWSYS_STL_STRING_HAVE_ISTREAM}/g; s/@KWSYS_STL_STRING_HAVE_OSTREAM@/${KWSYS_STL_STRING_HAVE_OSTREAM}/g; s/@KWSYS_STL_STRING_HAVE_NEQ_CHAR@/${KWSYS_STL_STRING_HAVE_NEQ_CHAR}/g; + s/@KWSYS_STL_HAS_ITERATOR_TRAITS@/${KWSYS_STL_HAS_ITERATOR_TRAITS}/g; + s/@KWSYS_STL_HAS_ITERATOR_CATEGORY@/${KWSYS_STL_HAS_ITERATOR_CATEGORY}/g; + s/@KWSYS_STL_HAS___ITERATOR_CATEGORY@/${KWSYS_STL_HAS___ITERATOR_CATEGORY}/g; + s/@KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE@/${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}/g; s/@KWSYS_STL_HAS_ALLOCATOR_REBIND@/${KWSYS_STL_HAS_ALLOCATOR_REBIND}/g; s/@KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT@/${KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT}/g; s/@KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS@/${KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS}/g; @@ -717,6 +721,10 @@ KWSYS_IOS_USE_ANSI=0 KWSYS_STL_HAVE_STD=0 KWSYS_STAT_HAS_ST_MTIM=0 KWSYS_STL_STRING_HAVE_NEQ_CHAR=0 +KWSYS_STL_HAS_ITERATOR_TRAITS=0 +KWSYS_STL_HAS_ITERATOR_CATEGORY=0 +KWSYS_STL_HAS___ITERATOR_CATEGORY=0 +KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=0 KWSYS_STL_HAS_ALLOCATOR_REBIND=0 KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=0 KWSYS_CXX_HAS_NULL_TEMPLATE_ARGS=0 @@ -796,21 +804,62 @@ else fi if cmake_try_run "${cmake_cxx_compiler}" \ - "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_TRAITS -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then - KWSYS_STL_HAS_ALLOCATOR_REBIND=1 - echo "${cmake_cxx_compiler} has allocator<>::rebind<>" + KWSYS_STL_HAS_ITERATOR_TRAITS=1 + echo "${cmake_cxx_compiler} has stl iterator_traits" else - echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>" + echo "${cmake_cxx_compiler} does not have stl iterator_traits" +fi + +if [ "x${KWSYS_STL_HAS_ITERATOR_TRAITS}" = "x0" ]; then + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS_ITERATOR_CATEGORY=1 + echo "${cmake_cxx_compiler} has old iterator_category" + else + echo "${cmake_cxx_compiler} does not have old iterator_category" + fi + if [ "x${KWSYS_STL_HAS_ITERATOR_CATEGORY}" = "x0" ]; then + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS___ITERATOR_CATEGORY -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS___ITERATOR_CATEGORY=1 + echo "${cmake_cxx_compiler} has old __iterator_category" + else + echo "${cmake_cxx_compiler} does not have old __iterator_category" + fi + fi fi if cmake_try_run "${cmake_cxx_compiler}" \ - "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then - KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1 - echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument" + KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE=1 + echo "${cmake_cxx_compiler} has old non-template allocator" else - echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument" + echo "${cmake_cxx_compiler} does not have old non-template allocator" +fi + +if [ "x${KWSYS_STL_HAS_ALLOCATOR_NONTEMPLATE}" = "x0" ]; then + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_REBIND -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS_ALLOCATOR_REBIND=1 + echo "${cmake_cxx_compiler} has allocator<>::rebind<>" + else + echo "${cmake_cxx_compiler} does not have allocator<>::rebind<>" + fi + + if cmake_try_run "${cmake_cxx_compiler}" \ + "${cmake_cxx_flags} -DTEST_KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT -DKWSYS_STL_HAVE_STD=${KWSYS_STL_HAVE_STD}" \ + "${cmake_source_dir}/Source/kwsys/kwsysPlatformCxxTests.cxx" >> cmake_bootstrap.log 2>&1; then + KWSYS_STL_HAS_ALLOCATOR_MAX_SIZE_ARGUMENT=1 + echo "${cmake_cxx_compiler} has non-standard allocator<>::max_size argument" + else + echo "${cmake_cxx_compiler} does not have non-standard allocator<>::max_size argument" + fi fi if cmake_try_run "${cmake_cxx_compiler}" \ |