]> git.donarmstrong.com Git - bamtools.git/commitdiff
Migrated to CMake build system.
authorderek <derekwbarnett@gmail.com>
Fri, 19 Nov 2010 15:32:45 +0000 (10:32 -0500)
committerderek <derekwbarnett@gmail.com>
Fri, 19 Nov 2010 15:32:45 +0000 (10:32 -0500)
* Please see README: Installation for help in building BamTools toolkit & API and integrating the new shared library into your application

19 files changed:
CMakeLists.txt [new file with mode: 0644]
Makefile [deleted file]
README
src/CMakeLists.txt [new file with mode: 0644]
src/api/CMakeLists.txt [new file with mode: 0644]
src/api/Makefile [deleted file]
src/api/api_global.h [new file with mode: 0644]
src/shared/bamtools_global.h [new file with mode: 0644]
src/third_party/CMakeLists.txt [new file with mode: 0644]
src/third_party/Makefile [deleted file]
src/third_party/jsoncpp/CMakeLists.txt [new file with mode: 0644]
src/third_party/jsoncpp/Makefile [deleted file]
src/third_party/jsoncpp/json_config.h
src/toolkit/CMakeLists.txt [new file with mode: 0644]
src/toolkit/Makefile [deleted file]
src/toolkit/bamtools_version.h.in [new file with mode: 0644]
src/utils/CMakeLists.txt [new file with mode: 0644]
src/utils/Makefile [deleted file]
src/utils/utils_global.h [new file with mode: 0644]

diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644 (file)
index 0000000..5af858e
--- /dev/null
@@ -0,0 +1,48 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# top-level
+# ==========================
+
+# set project name
+project (BamTools)
+
+# Cmake requirements
+cmake_minimum_required (VERSION 2.6.4)
+
+# Force the build directory to be different from source directory
+macro (ENSURE_OUT_OF_SOURCE_BUILD MSG)
+    string (COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${CMAKE_BINARY_DIR}" insource)
+    get_filename_component (PARENTDIR ${CMAKE_SOURCE_DIR} PATH)
+    string (COMPARE EQUAL "${CMAKE_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
+    IF (insource OR insourcesubdir)
+        message (FATAL_ERROR "${MSG}")
+    ENDIF (insource OR insourcesubdir)
+endmacro (ENSURE_OUT_OF_SOURCE_BUILD)
+
+ensure_out_of_source_build ("
+  ${PROJECT_NAME} requires an out of source build.
+  $ mkdir build 
+  $ cd build
+  $ cmake ..
+  $ make 
+(or the Windows equivalent)\n")
+
+# set BamTools version information
+set (BamTools_VERSION_MAJOR 0)
+set (BamTools_VERSION_MINOR 9)
+set (BamTools_VERSION_BUILD 0)
+
+# set our library and executable destination dirs
+set (EXECUTABLE_OUTPUT_PATH "${CMAKE_SOURCE_DIR}/bin")
+set (LIBRARY_OUTPUT_PATH    "${CMAKE_SOURCE_DIR}/lib")
+
+# define compiler flags for all code
+add_definitions (-Wall -O3 -D_FILE_OFFSET_BITS=64)
+
+# add our includes root path
+include_directories (src)
+
+# list subdirectories to build in
+add_subdirectory (src)
diff --git a/Makefile b/Makefile
deleted file mode 100644 (file)
index f282c20..0000000
--- a/Makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# top-level
-# ==========================
-
-# define current BamTools version
-BT_MAJOR_VER = 0
-BT_MINOR_VER = 8
-BT_BUILD_VER = 1025
-export BT_VERSION = $(BT_MAJOR_VER).$(BT_MINOR_VER).$(BT_BUILD_VER)
-
-# define main directories
-export OBJ_DIR  = obj
-export BIN_DIR  = bin
-export SRC_DIR  = src
-
-# define compile/link flags
-export CXX      = g++
-export CXXFLAGS = -Wall -O3 -D_FILE_OFFSET_BITS=64 -DBT_VERSION=$(BT_VERSION)
-export LIBS     = -lz
-
-# define source subdirectories
-SUBDIRS = $(SRC_DIR)/api \
-          $(SRC_DIR)/utils \
-          $(SRC_DIR)/third_party \
-          $(SRC_DIR)/toolkit 
-
-all:
-       @echo "Building BamTools:"
-       @echo "Version: $$BT_VERSION"
-       @echo "========================================================="
-       @echo ""
-       @echo "- Creating target directories"
-       @mkdir -p $(BIN_DIR)
-       @mkdir -p $(OBJ_DIR)
-       @echo ""
-       @for dir in $(SUBDIRS); do \
-               echo "- Building in $$dir"; \
-               $(MAKE) --no-print-directory -C $$dir; \
-               echo ""; \
-       done
-
-.PHONY: all
-
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
diff --git a/README b/README
index 00d96583db41aefb08f91e8b33059f2c1c065ebf..b6a8b0721163e88abe3831d7b0b22a4967df03d9 100644 (file)
--- a/README
+++ b/README
@@ -8,15 +8,17 @@ I.   Introduction
      a. The API
      b. The Toolkit
 
-II.  Usage
+II.  Installation
+
+III. Usage
      a. The API
      b. The Toolkit
 
-III. License
+IV.  License
 
-IV.  Acknowledgements
+V.   Acknowledgements
 
-V  Contact
+VI.  Contact
 
 --------------------------------------------------------------------------------
 I. Introduction:
@@ -80,14 +82,77 @@ Available bamtools commands:
 See 'bamtools help COMMAND' for more information on a specific command.
 
 --------------------------------------------------------------------------------
-II. Usage :
+II. Installation :
+--------------------------------------------------------------------------------
+
+----------------------------------------
+IIa. Get CMake
+----------------------------------------
+
+BamTools has been migrated to a CMake-based build system.  We believe that this 
+should simplify the build process across all platforms, especially as the 
+BamTools API moves into a shared library (that you link to instead of compiling 
+lots of source files directly into your application). CMake is available on all 
+major platforms, and indeed comes *out-of-the-box* with many Linux distributions.
+
+To see if you have CMake (and which version), try this command:
+
+  $ cmake --version
+
+BamTools requires CMake version >= 2.6.4. If you are missing CMake or have an 
+older version, check your OS package manager (for Linux) or download it here:
+http://www.cmake.org/cmake/resources/software.html .
+
+----------------------------------------
+IIb. Build BamTools 
+----------------------------------------
+
+Ok, now that you have CMake ready to go, let's build BamTools.  A good
+practice in building applications is to do an out-of-source build, meaning
+that we're going to set up an isolated place to hold all the intermediate 
+installation steps.
+
+In the top-level directory of BamTools, type the following commands:
+
+  $ mkdir build
+  $ cd build
+  $ cmake ..
+
+Windows users:
+This creates a Visual Studio solution file, which can then be built to create 
+the toolkit executable and API DLL's.
+
+Everybody else:
+After running cmake, just run:
+
+  $ make
+
+Then go back up to the BamTools root directory.
+
+  $ cd ..
+
+----------------------------------------
+IIIb. Check It 
+----------------------------------------
+
+Assuming the build process finished correctly, you should be able to find the 
+toolkit executable here:
+
+  ./bin/
+
+The BamTools-associated libraries will be found here:
+
+  ./lib/
+
+--------------------------------------------------------------------------------
+III. Usage :
 --------------------------------------------------------------------------------
 
 ** General usage information - perhaps explain common terms, point to SAM/BAM
 spec, etc **
 
 ----------------------------------------
-IIa. The API
+IIIa. The API
 ----------------------------------------
 
 The API, as noted above, contains 2 main modules - BamReader & BamWriter - for
@@ -120,7 +185,7 @@ following:
 
 To use this API in your application, you simply need to do 3 things:
 
-    1 - Drop the BamTools API files somewhere the compiler can find them.
+    1 - Build the BamTools library (see Installation steps above). 
 
     2 - Import BamTools API with the following lines of code
         #include "BamReader.h"     // (or "BamMultiReader.h") as needed
@@ -128,15 +193,23 @@ To use this API in your application, you simply need to do 3 things:
         using namespace BamTools;  // all of BamTools classes/methods live in
                                    // this namespace
 
-    3 - Link with '-lz' ('l' as in Lima) to access ZLIB compression library
-        (For MSVC users, I can provide you modified zlib headers - just contact
-        me if needed).
+    3 - Link with '-lbamtools' ('l' as in Lima).
+
+You may need to modify the -L flag (library path) as well to help your linker 
+find the (BAMTOOLS_ROOT)/lib directory.
+
+See any included programs for more detailed usage examples. See comments in the 
+header files for more detailed API documentation.
 
-See any included programs and Makefile for more specific compiling/usage
-examples. See comments in the header files for more detailed API documentation.
+Note - For users that don't want to bother with the new BamTools shared library
+scheme: you are certainly free to just compile the API source code directly into 
+your application, but be aware that the files involved are subject to change.  
+Meaning that filenames, number of files, etc. are not fixed.  You will also need 
+to be sure to link with '-lz' for ZLIB functionality (linking with '-lbamtools' 
+gives you this automatically).
 
 ----------------------------------------
-IIb. The Toolkit
+IIIb. The Toolkit
 ----------------------------------------
 
 BamTools provides a small, but powerful suite of command-line utility programs
@@ -717,7 +790,7 @@ Help:
   --help, -h                        shows this help text
 
 --------------------------------------------------------------------------------
-III. License :
+IV. License :
 --------------------------------------------------------------------------------
 
 Both the BamTools API and toolkit are released under the MIT License.
@@ -727,7 +800,7 @@ Copyright (c) 2009-2010 Derek Barnett, Erik Garrison, Gabor Marth,
 See included file LICENSE for details.
 
 --------------------------------------------------------------------------------
-IV. Acknowledgements :
+V. Acknowledgements :
 --------------------------------------------------------------------------------
 
  * Aaron Quinlan for several key feature ideas and bug fix contributions
@@ -735,7 +808,7 @@ IV. Acknowledgements :
  * Heng Li, author of SAMtools - the original C-language BAM API/toolkit.
 
 --------------------------------------------------------------------------------
-V. Contact :
+VI. Contact :
 --------------------------------------------------------------------------------
 
 Feel free to contact me with any questions, comments, suggestions, bug reports,
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f057a61
--- /dev/null
@@ -0,0 +1,12 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/
+# ==========================
+
+add_subdirectory (api)
+add_subdirectory (utils)
+add_subdirectory (third_party)
+add_subdirectory (toolkit)
+
diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt
new file mode 100644 (file)
index 0000000..8445603
--- /dev/null
@@ -0,0 +1,31 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/api/
+# ==========================
+
+# list include paths
+include_directories ( ${BamTools_SOURCE_DIR}/src/shared )
+
+# add compiler definitions 
+add_definitions(-DBAMTOOLS_API_LIBRARY) # (for proper exporting of library symbols)
+
+# create main BamTools API library
+add_library ( BamTools SHARED 
+              BamAlignment.cpp 
+              BamIndex.cpp 
+              BamMultiReader.cpp
+              BamReader.cpp
+              BamWriter.cpp
+              BGZF.cpp 
+            )
+
+# link BamTools library with zlib automatically
+target_link_libraries ( BamTools z )
+
+# set BamTools library properties
+set_target_properties( BamTools PROPERTIES
+                       SOVERSION   0.9.0
+                       OUTPUT_NAME bamtools
+                     )
diff --git a/src/api/Makefile b/src/api/Makefile
deleted file mode 100644 (file)
index e8a6228..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# src/api
-# ==========================
-
-OBJ_DIR = ../../obj
-BIN_DIR = ../../bin
-
-# ----------------------------------
-# define our source and object files
-# ----------------------------------
-SOURCES = BGZF.cpp \
-         BamAlignment.cpp \
-          BamIndex.cpp \
-          BamReader.cpp \
-          BamMultiReader.cpp \
-          BamWriter.cpp
-OBJECTS= $(SOURCES:.cpp=.o)
-BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
-
-all: $(BUILT_OBJECTS)
-
-$(BUILT_OBJECTS): $(SOURCES)
-       @echo "  * compiling" $(*F).cpp
-       @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES)
-
-.PHONY: all
-
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
diff --git a/src/api/api_global.h b/src/api/api_global.h
new file mode 100644 (file)
index 0000000..84fcad2
--- /dev/null
@@ -0,0 +1,22 @@
+// ***************************************************************************
+// api_global.h (c) 2010 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// All rights reserved.
+// ---------------------------------------------------------------------------
+// Last modified: 19 November 2010 (DB)
+// ---------------------------------------------------------------------------
+// Provides macros for exporting & importing BamTools API library symbols
+// ***************************************************************************
+
+#ifndef API_GLOBAL_H
+#define API_GLOBAL_H
+
+#include "shared/bamtools_global.h"
+
+#ifdef BAMTOOLS_API_LIBRARY
+#  define API_EXPORT BAMTOOLS_LIBRARY_EXPORT
+#else
+#  define API_EXPORT BAMTOOLS_LIBRARY_IMPORT
+#endif
+
+#endif // API_GLOBAL_H
diff --git a/src/shared/bamtools_global.h b/src/shared/bamtools_global.h
new file mode 100644 (file)
index 0000000..be7e034
--- /dev/null
@@ -0,0 +1,32 @@
+// ***************************************************************************
+// bamtools_global.h (c) 2010 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// All rights reserved.
+// ---------------------------------------------------------------------------
+// Last modified: 19 November 2010 (DB)
+// ---------------------------------------------------------------------------
+// Provides the basic definitions for exporting & importing library symbols
+// ***************************************************************************
+
+#ifndef BAMTOOLS_GLOBAL_H
+#define BAMTOOLS_GLOBAL_H
+
+// BAMTOOLS_LIBRARY_EXPORT
+#ifndef BAMTOOLS_LIBRARY_EXPORT
+#  if defined(WIN32)
+#    define BAMTOOLS_LIBRARY_EXPORT __declspec(dllexport)
+#  else
+#    define BAMTOOLS_LIBRARY_EXPORT __attribute__((visibility("default")))
+#  endif
+#endif // BAMTOOLS_LIBRARY_EXPORT
+
+// BAMTOOLS_LIBRARY_IMPORT
+#ifndef BAMTOOLS_LIBRARY_IMPORT
+#  if defined(WIN32)
+#    define BAMTOOLS_LIBRARY_IMPORT __declspec(dllimport)
+#  else
+#    define BAMTOOLS_LIBRARY_IMPORT
+#  endif
+#endif // BAMTOOLS_LIBRARY_IMPORT
+
+#endif // BAMTOOLS_GLOBAL_H
diff --git a/src/third_party/CMakeLists.txt b/src/third_party/CMakeLists.txt
new file mode 100644 (file)
index 0000000..15229c6
--- /dev/null
@@ -0,0 +1,10 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/third-party/
+# ==========================
+
+# list third-party subdirectories to build in
+add_subdirectory (jsoncpp)
+
diff --git a/src/third_party/Makefile b/src/third_party/Makefile
deleted file mode 100644 (file)
index 8f475a2..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# src/third_party
-# ==========================
-
-OBJ_DIR = ../../obj
-BIN_DIR = ../../bin
-SRC_DIR = 
-
-# define source subdirectories
-SUBDIRS = jsoncpp
-
-all:
-       @for dir in $(SUBDIRS); do \
-               echo "- Building in $$dir"; \
-               $(MAKE) --no-print-directory -C $$dir; \
-               echo ""; \
-       done
-
-.PHONY: all
-
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
diff --git a/src/third_party/jsoncpp/CMakeLists.txt b/src/third_party/jsoncpp/CMakeLists.txt
new file mode 100644 (file)
index 0000000..1ee9cdf
--- /dev/null
@@ -0,0 +1,22 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/third-party/jsoncpp
+# ==========================
+
+# add compiler definitions 
+#add_definitions(-DJSONCPP_LIBRARY) # (for proper exporting of library symbols)
+
+# create jsoncpp library
+add_library ( jsoncpp SHARED 
+              json_reader.cpp
+              json_value.cpp
+              json_writer.cpp
+            )
+
+# set jsoncpp library properties
+set_target_properties( jsoncpp PROPERTIES
+                       SOVERSION   1.0.0
+                       OUTPUT_NAME jsoncpp
+                     )
diff --git a/src/third_party/jsoncpp/Makefile b/src/third_party/jsoncpp/Makefile
deleted file mode 100644 (file)
index fa25563..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# src/third_party/jsoncpp
-# ==========================
-
-OBJ_DIR = ../../../obj
-BIN_DIR = ../../../bin
-
-# ----------------------------------
-# define our source and object files
-# ----------------------------------
-SOURCES = json_reader.cpp \
-          json_value.cpp \
-          json_writer.cpp
-OBJECTS= $(SOURCES:.cpp=.o)
-BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
-
-all: $(BUILT_OBJECTS)
-
-$(BUILT_OBJECTS): $(SOURCES)
-       @echo "  * compiling" $(*F).cpp
-       @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES)
-
-.PHONY: all
-
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
index 3fe08f2f9353f4b6fee4e624cd987771b262d4d3..4977f147dbfd5a91e2a885f8bfc65f8d1fce162b 100644 (file)
@@ -4,73 +4,39 @@
 // See file LICENSE for detail or copy at http://jsoncpp.sourceforge.net/LICENSE
 
 #ifndef JSON_CONFIG_H_INCLUDED
-# define JSON_CONFIG_H_INCLUDED
+#define JSON_CONFIG_H_INCLUDED
 
-/// If defined, indicates that json library is embedded in CppTL library.
-//# define JSON_IN_CPPTL 1
+// Last Modified: Derek Barnett, 19 November 2010
 
-/// If defined, indicates that json may leverage CppTL library
-//#  define JSON_USE_CPPTL 1
-/// If defined, indicates that cpptl vector based map should be used instead of std::map
-/// as Value container.
-//#  define JSON_USE_CPPTL_SMALLMAP 1
-/// If defined, indicates that Json specific container should be used
-/// (hash table & simple deque container with customizable allocator).
-/// THIS FEATURE IS STILL EXPERIMENTAL!
-//#  define JSON_VALUE_USE_INTERNAL_MAP 1
-/// Force usage of standard new/malloc based allocator instead of memory pool based allocator.
-/// The memory pools allocator used optimization (initializing Value and ValueInternalLink
-/// as if it was a POD) that may cause some validation tool to report errors.
-/// Only has effects if JSON_VALUE_USE_INTERNAL_MAP is defined.
-//#  define JSON_USE_SIMPLE_INTERNAL_ALLOCATOR 1
-
-/// If defined, indicates that Json use exception to report invalid type manipulation
-/// instead of C assert macro.
-# define JSON_USE_EXCEPTION 1
-
-# ifdef JSON_IN_CPPTL
-#  include <cpptl/config.h>
-#  ifndef JSON_USE_CPPTL
-#   define JSON_USE_CPPTL 1
-#  endif
-# endif
-
-# ifdef JSON_IN_CPPTL
-#  define JSON_API CPPTL_API
-# elif defined(JSON_DLL_BUILD)
-#  define JSON_API __declspec(dllexport)
-# elif defined(JSON_DLL)
-#  define JSON_API __declspec(dllimport)
-# else
-#  define JSON_API
-# endif
-
-// If JSON_NO_INT64 is defined, then Json only support C++ "int" type for integer
-// Storages.
-// #define JSON_NO_INT64 1
+#include "shared/bamtools_global.h"
+#ifdef BAMTOOLS_JSONCPP_LIBRARY
+#  define JSON_API BAMTOOLS_LIBRARY_EXPORT
+#else
+#  define JSON_API BAMTOOLS_LIBRARY_IMPORT
+#endif
 
 #if defined(_MSC_VER)  &&  _MSC_VER <= 1200 // MSVC 6
 // Microsoft Visual Studio 6 only support conversion from __int64 to double
 // (no conversion from unsigned __int64).
-#define JSON_USE_INT64_DOUBLE_CONVERSION 1
+#  define JSON_USE_INT64_DOUBLE_CONVERSION 1
 #endif // if defined(_MSC_VER)  &&  _MSC_VER < 1200 // MSVC 6
 
-
 namespace Json {
-# if defined(JSON_NO_INT64)
+
+#if defined(JSON_NO_INT64)
    typedef int Int;
    typedef unsigned int UInt;
-# else // if defined(JSON_NO_INT64)
+#else // if defined(JSON_NO_INT64)
    // For Microsoft Visual use specific types as long long is not supported
 #  if defined(_MSC_VER) // Microsoft Visual Studio
-   typedef __int64 Int;
-   typedef unsigned __int64 UInt;
+     typedef __int64 Int;
+     typedef unsigned __int64 UInt;
 #  else // if defined(_MSC_VER) // Other platforms, use long long
-   typedef long long int Int;
-   typedef unsigned long long int UInt;
+     typedef long long int Int;
+     typedef unsigned long long int UInt;
 #  endif // if defined(_MSC_VER)
-# endif // if defined(JSON_NO_INT64)
-} // end namespace Json
+#endif // if defined(JSON_NO_INT64)
 
+} // end namespace Json
 
 #endif // JSON_CONFIG_H_INCLUDED
diff --git a/src/toolkit/CMakeLists.txt b/src/toolkit/CMakeLists.txt
new file mode 100644 (file)
index 0000000..7e0fad0
--- /dev/null
@@ -0,0 +1,39 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/toolkit
+# ==========================
+
+# set include path
+include_directories ( ${BamTools_SOURCE_DIR}/src/api
+                      ${BamTools_SOURCE_DIR}/src/utils
+                      ${BamTools_SOURCE_DIR}/src/third_party
+                    )
+
+# compile main bamtools application
+add_executable ( bamtools
+                 bamtools_convert.cpp
+                 bamtools_count.cpp
+                 bamtools_coverage.cpp
+                 bamtools_filter.cpp
+                 bamtools_header.cpp
+                 bamtools_index.cpp
+                 bamtools_merge.cpp
+                 bamtools_random.cpp
+                 bamtools_sort.cpp
+                 bamtools_split.cpp
+                 bamtools_stats.cpp
+                 bamtools.cpp
+               )
+
+# set BamTools application properties
+set_target_properties( BamTools PROPERTIES
+                       VERSION  0.9.0
+                     )
+# make version info available in application
+configure_file(bamtools_version.h.in ${BamTools_SOURCE_DIR}/src/toolkit/bamtools_version.h)
+
+# define libraries to link
+target_link_libraries ( bamtools BamTools BamTools-utils jsoncpp )
+
diff --git a/src/toolkit/Makefile b/src/toolkit/Makefile
deleted file mode 100644 (file)
index 1b87288..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# src/toolkit
-# ==========================
-
-API_DIR   = ../api
-UTILS_DIR = ../utils
-OBJ_DIR   = ../../obj
-BIN_DIR   = ../../bin
-THIRD_PARTY_DIR = ../third_party
-
-INCLUDES = -I$(API_DIR)/ -I$(UTILS_DIR) -I$(THIRD_PARTY_DIR)
-
-# ----------------------------------
-# define our source and object files
-# ----------------------------------
-SOURCES = bamtools_convert.cpp \
-          bamtools_count.cpp \
-          bamtools_coverage.cpp \
-          bamtools_filter.cpp \
-          bamtools_header.cpp \
-          bamtools_index.cpp \
-          bamtools_merge.cpp \
-          bamtools_random.cpp \
-          bamtools_sort.cpp \
-         bamtools_split.cpp \
-          bamtools_stats.cpp \
-          bamtools.cpp 
-OBJECTS= $(SOURCES:.cpp=.o)
-BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
-EXT_OBJECTS = $(OBJ_DIR)/*.o
-PROGRAM = bamtools
-
-all: $(PROGRAM)
-
-.PHONY: all
-
-$(PROGRAM): $(BUILT_OBJECTS) $(EXT_OBJECTS)
-       @echo "  * linking $(PROGRAM)"
-       @$(CXX) $(LDFLAGS) $(CXXFLAGS) -o $(BIN_DIR)/$@ $^ $(LIBS)
-
-$(BUILT_OBJECTS): $(SOURCES)
-       @echo "  * compiling" $(*F).cpp
-       @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES)
-
-$(EXT_OBJECTS):
-       @$(MAKE) --no-print-directory -C $(API_DIR) $(UTILS_DIR)        
-       
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
diff --git a/src/toolkit/bamtools_version.h.in b/src/toolkit/bamtools_version.h.in
new file mode 100644 (file)
index 0000000..aa7c06a
--- /dev/null
@@ -0,0 +1,21 @@
+// ***************************************************************************
+// bamtools_version.h.in (c) 2010 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// All rights reserved.
+// ---------------------------------------------------------------------------
+// Last modified: 19 November 2010 (DB)
+// ---------------------------------------------------------------------------
+// Provides version information for the BamTools toolkit.
+// ***************************************************************************
+
+#ifndef BAMTOOLS_VERSION_H
+#define BAMTOOLS_VERSION_H
+
+// CMake uses this file as a template to generate "bamtools_version.h".
+// These constants are defined to match the variables set in the build system. 
+#define BAMTOOLS_VERSION_MAJOR @BamTools_VERSION_MAJOR@
+#define BAMTOOLS_VERSION_MINOR @BamTools_VERSION_MINOR@
+#define BAMTOOLS_VERSION_BUILD @BamTools_VERSION_BUILD@
+
+#endif // BAMTOOLS_VERSION_H
+
diff --git a/src/utils/CMakeLists.txt b/src/utils/CMakeLists.txt
new file mode 100644 (file)
index 0000000..f93835b
--- /dev/null
@@ -0,0 +1,29 @@
+# ==========================
+# BamTools CMakeLists.txt
+# (c) 2010 Derek Barnett
+#
+# src/utils/
+# ==========================
+
+# list include paths
+include_directories (${BamTools_SOURCE_DIR}/src/api) 
+
+# add compiler definitions 
+#add_definitions(-DBAMTOOLS_UTILS_LIBRARY) # (for proper exporting of library symbols)
+
+# create BamTools utils library
+add_library ( BamTools-utils SHARED 
+              bamtools_fasta.cpp
+              bamtools_options.cpp
+              bamtools_pileup_engine.cpp
+              bamtools_utilities.cpp
+            )
+
+# link BamTools-utils library with BamTools automatically
+target_link_libraries ( BamTools-utils BamTools )
+
+# set BamTools library properties
+set_target_properties( BamTools-utils PROPERTIES
+                       SOVERSION   0.9.0
+                       OUTPUT_NAME bamtools-utils
+                     )
diff --git a/src/utils/Makefile b/src/utils/Makefile
deleted file mode 100644 (file)
index 6e88122..0000000
+++ /dev/null
@@ -1,36 +0,0 @@
-# ==========================
-# BamTools Makefile
-# (c) 2010 Derek Barnett
-#
-# src/utils
-# ==========================
-
-API_DIR = ../api
-OBJ_DIR = ../../obj
-BIN_DIR = ../../bin
-
-INCLUDES = -I$(API_DIR)/
-
-# ----------------------------------
-# define our source and object files
-# ----------------------------------
-SOURCES = bamtools_fasta.cpp \
-          bamtools_options.cpp \
-         bamtools_pileup_engine.cpp \
-          bamtools_utilities.cpp 
-OBJECTS= $(SOURCES:.cpp=.o)
-BUILT_OBJECTS= $(patsubst %,$(OBJ_DIR)/%,$(OBJECTS))
-
-all: $(BUILT_OBJECTS)
-
-$(BUILT_OBJECTS): $(SOURCES)
-       @echo "  * compiling" $(*F).cpp
-       @$(CXX) -c -o $@ $(*F).cpp $(LDFLAGS) $(CXXFLAGS) $(INCLUDES)
-
-.PHONY: all
-
-clean:
-       @echo "Cleaning up."
-       @rm -f $(OBJ_DIR)/* $(BIN_DIR)/*
-
-.PHONY: clean
diff --git a/src/utils/utils_global.h b/src/utils/utils_global.h
new file mode 100644 (file)
index 0000000..8aa2826
--- /dev/null
@@ -0,0 +1,22 @@
+// ***************************************************************************
+// utils_global.h (c) 2010 Derek Barnett
+// Marth Lab, Department of Biology, Boston College
+// All rights reserved.
+// ---------------------------------------------------------------------------
+// Last modified: 19 November 2010 (DB)
+// ---------------------------------------------------------------------------
+// Provides macros for exporting & importing BamTools-utils library symbols
+// ***************************************************************************
+
+#ifndef UTILS_GLOBAL_H
+#define UTILS_GLOBAL_H
+
+#include "shared/bamtools_global.h"
+
+#ifdef BAMTOOLS_UTILS_LIBRARY
+#  define UTILS_EXPORT BAMTOOLS_LIBRARY_EXPORT
+#else
+#  define UTILS_EXPORT BAMTOOLS_LIBRARY_IMPORT
+#endif
+
+#endif // UTILS_GLOBAL_H