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:
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.
# 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
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)