Commit 158f4ab5 authored by Kenneth Leiter's avatar Kenneth Leiter

COMP: Add support for newer versions of boost.

shared_dynamic_cast was deprecated and removed from newer versions of boost
as dynamic_pointer_cast provides the same functionality. Check at
configure time whether shared_dynamic_cast exists and if not, then
provide our own implementation that uses dynamic_pointer_cast.
parent 76a9b916
project(XdmfCore)
cmake_minimum_required(VERSION 2.6)
include(CheckCXXSourceCompiles)
include(SetUpVersion)
if(VERSION_CONTROL_AUTOUPDATE OR
NOT EXISTS ${CMAKE_BINARY_DIR}/XdmfVersion.hpp)
VersionCreate("Xdmf" "2" "XDMFCORE_EXPORT" "XdmfCore.hpp")
......@@ -66,6 +68,25 @@ if(LIBXML2_FOUND)
set(XDMF_BINARIES ${XDMF_BINARIES} ${LIBXML2_BINARY_DIRS})
endif(LIBXML2_FOUND)
# Perform compile-time checks and generate XdmfConfig.hpp
unset(HAVE_BOOST_SHARED_DYNAMIC_CAST CACHE)
set(CMAKE_REQUIRED_INCLUDES ${CMAKE_REQUIRED_INCLUDES} ${Boost_INCLUDE_DIRS})
check_cxx_source_compiles("
#include <boost/shared_ptr.hpp>
struct Base { virtual ~Base(){} };
struct Derived : public Base {};
int main(int ac, char * av)
{
boost::shared_ptr<Base> ptr(new Base());
boost::shared_dynamic_cast<Derived>(ptr);
}
"
HAVE_BOOST_SHARED_DYNAMIC_CAST)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/XdmfConfig.hpp.in
${CMAKE_BINARY_DIR}/XdmfConfig.hpp)
set(XdmfCoreSources
XdmfArray
XdmfArrayType
......
/*****************************************************************************/
/* XDMF */
/* eXtensible Data Model and Format */
/* */
/* Id : XdmfConfig.hpp */
/* */
/* Author: */
/* Kenneth Leiter */
/* kenneth.leiter@arl.army.mil */
/* US Army Research Laboratory */
/* Aberdeen Proving Ground, MD */
/* */
/* Copyright @ 2011 US Army Research Laboratory */
/* All Rights Reserved */
/* See Copyright.txt for details */
/* */
/* This software is distributed WITHOUT ANY WARRANTY; without */
/* even the implied warranty of MERCHANTABILITY or FITNESS */
/* FOR A PARTICULAR PURPOSE. See the above copyright notice */
/* for more information. */
/* */
/*****************************************************************************/
#ifndef XDMFCONFIG_HPP_
#define XDMFCONFIG_HPP_
#cmakedefine HAVE_BOOST_SHARED_DYNAMIC_CAST
#endif /* XDMFSHAREDPTR_HPP_ */
......@@ -24,9 +24,24 @@
#ifndef XDMFSHAREDPTR_HPP_
#define XDMFSHAREDPTR_HPP_
#include "XdmfConfig.hpp"
#include <boost/shared_ptr.hpp>
using boost::shared_dynamic_cast;
using boost::shared_ptr;
#ifdef HAVE_BOOST_SHARED_DYNAMIC_CAST
using boost::shared_dynamic_cast;
#else
using boost::dynamic_pointer_cast;
template <typename T, typename U>
shared_ptr<T> shared_dynamic_cast(shared_ptr<U> const & r)
{
return dynamic_pointer_cast<T>(r);
}
#endif /* HAVE_BOOST_SHARED_DYNAMIC_CAST */
#endif /* XDMFSHAREDPTR_HPP_ */
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