]> ruin.nu Git - germs.git/commitdiff
Check for TR1 or Boost
authorMichael Andreen <harv@ruin.nu>
Wed, 19 Dec 2007 13:40:04 +0000 (14:40 +0100)
committerMichael Andreen <harv@ruin.nu>
Wed, 19 Dec 2007 13:40:04 +0000 (14:40 +0100)
The build system now checks for TR1 or Boost for a shared_ptr implementation
instead of assuming that TR1 is present.

src/CMakeLists.txt
src/model.h
src/shared_ptr.h [new file with mode: 0644]
src/sortaction.h

index 642ef504ef394723e6c6ee9d9c143b6c0906c673..9bdaf401e2ed40883a3a4fe745bd729b13ad6c52 100644 (file)
@@ -1,4 +1,5 @@
 INCLUDE(CheckIncludeFile)
 INCLUDE(CheckIncludeFile)
+INCLUDE(CheckIncludeFileCXX)
 
 SET(CMAKE_VERBOSE_MAKEFILE OFF)
 
 
 SET(CMAKE_VERBOSE_MAKEFILE OFF)
 
@@ -26,6 +27,18 @@ ELSE(HAVE_FANN)
        SET(GENELIBS GeneSort)
 ENDIF(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)
 TARGET_LINK_LIBRARIES(germs ${GENELIBS})
 
 SUBDIRS(test)
index 4c5f46a8005956dd523cd4edabcf04aa1b2b23b9..235f164d4cd28325c68daac533538c166ef44dd0 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef __MODEL_H__
 #define __MODEL_H__
 
 #ifndef __MODEL_H__
 #define __MODEL_H__
 
-#include <tr1/memory>
+#include "shared_ptr.h"
 #include <string>
 
 class SortAction;
 #include <string>
 
 class SortAction;
@@ -38,7 +38,7 @@ namespace Models {
  */
 class Model{
        public:
  */
 class Model{
        public:
-               typedef std::tr1::shared_ptr<Models::ModelImpl> ModelPointer;
+               typedef shared_ptr<Models::ModelImpl> ModelPointer;
 
                /**
                 * Constructs a new model.
 
                /**
                 * Constructs a new model.
diff --git a/src/shared_ptr.h b/src/shared_ptr.h
new file mode 100644 (file)
index 0000000..7b602da
--- /dev/null
@@ -0,0 +1,7 @@
+#if HAVE_TR1
+#include <tr1/memory>
+using std::tr1::shared_ptr;
+#else
+#include <boost/shared_ptr.hpp>
+using boost::shared_ptr;
+#endif
index ec9a023710961ee0978651fe46f1520d6d18039d..a99f786988b88a9cb238fc77122fb6a14aa5d4f2 100644 (file)
@@ -21,7 +21,7 @@
 #ifndef __SORTACTION_H__
 #define __SORTACTION_H__
 
 #ifndef __SORTACTION_H__
 #define __SORTACTION_H__
 
-#include <tr1/memory>
+#include "shared_ptr.h"
 #include <string>
 class GeneOrder;
 
 #include <string>
 class GeneOrder;
 
@@ -58,7 +58,7 @@ class SortActionImpl{
  */
 class SortAction{
        public:
  */
 class SortAction{
        public:
-               typedef std::tr1::shared_ptr<SortActionImpl> ActionPointer;
+               typedef shared_ptr<SortActionImpl> ActionPointer;
 
                /**
                 * Creates a new sort action, given a specified action.
 
                /**
                 * Creates a new sort action, given a specified action.