* API-related headers are copied here to provide an explicit target for client code.
./lib/
+The BamTools API headers will be found here:
+
+ ./include/*
+
--------------------------------------------------------------------------------
III. Usage :
--------------------------------------------------------------------------------
// close the reader
reader.Close();
-To use this API in your application, you simply need to do 3 things:
+To use this API in your application, you simply need to do the following:
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
- #include "BamWriter.h" // as needed
- using namespace BamTools; // all of BamTools classes/methods live in
+ 2 - Import BamTools API functionality as needed, for example:
+
+ #include "api/BamReader.h"
+ #include "api/BamWriter.h"
+ using namespace BamTools; // all BamTools classes/methods live within
// this namespace
- 3 - Link with '-lbamtools' ('l' as in Lima).
+ 3 - In your own build step, point your include path to the
+ (BAMTOOLS_ROOT)/include directory. Link your app with '-lbamtools' ('l'
+ as in Lima).
-You may need to modify the -L flag (library path) as well to help your linker
+* You may need to modify the -L flag (library path) as well to help your linker
find the (BAMTOOLS_ROOT)/lib directory.
+* Depending on your platform and where you install the BamTools API library, you
+may also need to adjust how your app locates the library at runtime. For
+Windows users, this can be as simple as dropping the DLL in the same folder as
+your executable. For *nix users (using gcc at least), you can add the following
+to your app's CXXFLAGS:
+
+ -Wl,-rpath,$(BAMTOOLS_LIB_DIR)
+
+where BAMTOOLS_LIB_DIR is, as you would guess, the directory containing the libs.
+An alternative is to set your local LD_LIBRARY_PATH environment variable.
+
See any included programs for more detailed usage examples. See comments in the
header files for more detailed API documentation.
add_subdirectory (third_party)
add_subdirectory (toolkit)
+# export shared headers
+include(ExportHeader.cmake)
+set(SharedIncludeDir "shared")
+ExportHeader(SharedHeaders shared/bamtools_global.h ${SharedIncludeDir})
+
+
--- /dev/null
+#
+# ExportHeader
+#
+
+function( ExportHeader MODULE FILE DEST )
+
+ # if haven't defined our custom 'build target'
+ # not exactly a build target, but lets this command get
+ # checked any time build step happens
+ if (NOT TARGET ${MODULE})
+ add_custom_target( ${MODULE} ALL COMMENT "Exporting ${MODULE}" )
+ endif (NOT TARGET ${MODULE} )
+
+ # get the filename (without path)
+ get_filename_component( FILENAME "${FILE}" NAME )
+
+ # copy header to destination
+ add_custom_command( TARGET ${MODULE} COMMAND
+ ${CMAKE_COMMAND} -E copy_if_different
+ "${CMAKE_CURRENT_SOURCE_DIR}/${FILE}"
+ "${CMAKE_SOURCE_DIR}/include/${DEST}/${FILENAME}" )
+
+
+
+ # make sure files are properly 'installed'
+ # set(INSTALL_DEST "bamtools/${DEST}")
+ # install( FILES "${FILE}" DESTINATION "${INSTALL_DEST}")
+ install( FILES "${FILE}" DESTINATION "include/bamtools/${DEST}" )
+
+endfunction( ExportHeader )
+
# ==========================
# list include paths
-include_directories ( ${BamTools_SOURCE_DIR}/src )
+include_directories( ${BamTools_SOURCE_DIR}/src )
# add compiler definitions
-add_definitions(-DBAMTOOLS_API_LIBRARY) # (for proper exporting of library symbols)
+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
- internal/BamReader_p.cpp
- internal/BamStandardIndex_p.cpp
- internal/BamToolsIndex_p.cpp
- internal/BamWriter_p.cpp
- )
+add_library( BamTools SHARED
+ BamAlignment.cpp
+ BamIndex.cpp
+ BamMultiReader.cpp
+ BamReader.cpp
+ BamWriter.cpp
+ BGZF.cpp
+ internal/BamReader_p.cpp
+ internal/BamStandardIndex_p.cpp
+ internal/BamToolsIndex_p.cpp
+ internal/BamWriter_p.cpp
+ )
# link BamTools library with zlib automatically
-target_link_libraries ( BamTools z )
+target_link_libraries( BamTools z )
# set BamTools library properties
set_target_properties( BamTools PROPERTIES
OUTPUT_NAME bamtools
)
+install( TARGETS BamTools LIBRARY DESTINATION "lib/bamtools")
+
+# export API headers
+include(../ExportHeader.cmake)
+set(ApiIncludeDir "api")
+ExportHeader(APIHeaders api_global.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamAlignment.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamAux.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamIndex.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamMultiReader.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamReader.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BamWriter.h ${ApiIncludeDir})
+ExportHeader(APIHeaders BGZF.h ${ApiIncludeDir})