]> git.donarmstrong.com Git - bamtools.git/commitdiff
Added static library to build step.
authorderek <derekwbarnett@gmail.com>
Fri, 24 Dec 2010 01:56:01 +0000 (20:56 -0500)
committerderek <derekwbarnett@gmail.com>
Fri, 24 Dec 2010 01:56:01 +0000 (20:56 -0500)
 * Suggested & contributed by Rob Bradley.

README
src/api/CMakeLists.txt

diff --git a/README b/README
index 3581add98f3cdd32902d33265fae50345d38cf30..c471dc5fa3bb23666af07657a3c5f89ea1fde078 100644 (file)
--- a/README
+++ b/README
@@ -206,7 +206,7 @@ To use this API in your application, you simply need to do the following:
 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
+may also need to adjust how your app locates the shared 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:
@@ -216,6 +216,9 @@ to your app's CXXFLAGS:
 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.
 
+Another alternative is to use the newly provided static library libbamtools.a and 
+resolve this issue at compile/link time, instead of runtime.
+
 See any included programs for more detailed usage examples. See comments in the 
 header files for more detailed API documentation.
 
index d56be583e01311cd7a8432936f675c94555ac496..db82f4efe7df86551bf94467e0b005cf9557493d 100644 (file)
@@ -11,7 +11,7 @@ include_directories( ${BamTools_SOURCE_DIR}/src )
 # add compiler definitions 
 add_definitions( -DBAMTOOLS_API_LIBRARY ) # (for proper exporting of library symbols)
 
-# create main BamTools API library
+# create main BamTools API shared library
 add_library( BamTools SHARED
              BamAlignment.cpp
              BamIndex.cpp
@@ -24,17 +24,34 @@ add_library( BamTools SHARED
              internal/BamToolsIndex_p.cpp
              internal/BamWriter_p.cpp
            )
+# set shared lib properties
+set_target_properties( BamTools PROPERTIES SOVERSION "0.9.0" )
+set_target_properties( BamTools PROPERTIES OUTPUT_NAME "bamtools" )
 
-# link BamTools library with zlib automatically
-target_link_libraries( BamTools z )
+# create main BamTools API static library
+add_library( BamTools-static STATIC
+             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
+           )
+# set static lib properties
+set_target_properties( BamTools-static PROPERTIES OUTPUT_NAME "bamtools" )
+set_target_properties( BamTools-static PROPERTIES PREFIX "lib" )
 
-# set BamTools library properties
-set_target_properties( BamTools PROPERTIES
-                       SOVERSION   0.9.0
-                       OUTPUT_NAME bamtools
-                     )
+# link libraries with zlib automatically
+target_link_libraries( BamTools z )
+target_link_libraries( BamTools-static z )
 
+# set library install destinations
 install( TARGETS BamTools LIBRARY DESTINATION "lib/bamtools")
+install( TARGETS BamTools-static ARCHIVE DESTINATION "lib/bamtools")
 
 # export API headers
 include(../ExportHeader.cmake)