From c997c8f4931cde3ede1b51905c10c4d9c442e630 Mon Sep 17 00:00:00 2001 From: Michael Andreen Date: Wed, 19 Dec 2007 14:40:04 +0100 Subject: [PATCH] Check for TR1 or Boost The build system now checks for TR1 or Boost for a shared_ptr implementation instead of assuming that TR1 is present. --- src/CMakeLists.txt | 13 +++++++++++++ src/model.h | 4 ++-- src/shared_ptr.h | 7 +++++++ src/sortaction.h | 4 ++-- 4 files changed, 24 insertions(+), 4 deletions(-) create mode 100644 src/shared_ptr.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 642ef50..9bdaf40 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,5 @@ INCLUDE(CheckIncludeFile) +INCLUDE(CheckIncludeFileCXX) SET(CMAKE_VERBOSE_MAKEFILE OFF) @@ -26,6 +27,18 @@ ELSE(HAVE_FANN) SET(GENELIBS GeneSort) ENDIF(HAVE_FANN) + +CHECK_INCLUDE_FILE_CXX("tr1/memory" HAVE_TR1) + +IF(HAVE_TR1) + ADD_DEFINITIONS(-DHAVE_TR1) +ELSE(HAVE_TR1) + CHECK_INCLUDE_FILE_CXX("boost/shared_ptr.hpp" HAVE_BOOST) + IF(NOT HAVE_BOOST) + MESSAGE(FATAL_ERROR "Neither Boost nor TR1 found, need a shared_ptr implementation") + ENDIF(NOT HAVE_BOOST) +ENDIF(HAVE_TR1) + TARGET_LINK_LIBRARIES(germs ${GENELIBS}) SUBDIRS(test) diff --git a/src/model.h b/src/model.h index 4c5f46a..235f164 100644 --- a/src/model.h +++ b/src/model.h @@ -21,7 +21,7 @@ #ifndef __MODEL_H__ #define __MODEL_H__ -#include +#include "shared_ptr.h" #include class SortAction; @@ -38,7 +38,7 @@ namespace Models { */ class Model{ public: - typedef std::tr1::shared_ptr ModelPointer; + typedef shared_ptr ModelPointer; /** * Constructs a new model. diff --git a/src/shared_ptr.h b/src/shared_ptr.h new file mode 100644 index 0000000..7b602da --- /dev/null +++ b/src/shared_ptr.h @@ -0,0 +1,7 @@ +#if HAVE_TR1 +#include +using std::tr1::shared_ptr; +#else +#include +using boost::shared_ptr; +#endif diff --git a/src/sortaction.h b/src/sortaction.h index ec9a023..a99f786 100644 --- a/src/sortaction.h +++ b/src/sortaction.h @@ -21,7 +21,7 @@ #ifndef __SORTACTION_H__ #define __SORTACTION_H__ -#include +#include "shared_ptr.h" #include class GeneOrder; @@ -58,7 +58,7 @@ class SortActionImpl{ */ class SortAction{ public: - typedef std::tr1::shared_ptr ActionPointer; + typedef shared_ptr ActionPointer; /** * Creates a new sort action, given a specified action. -- 2.39.2