From 54cdbfab8659f13806645133196ce2df01b0ffb4 Mon Sep 17 00:00:00 2001 From: derek Date: Thu, 23 Dec 2010 20:56:01 -0500 Subject: [PATCH] Added static library to build step. * Suggested & contributed by Rob Bradley. --- README | 5 ++++- src/api/CMakeLists.txt | 33 +++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/README b/README index 3581add..c471dc5 100644 --- 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. diff --git a/src/api/CMakeLists.txt b/src/api/CMakeLists.txt index d56be58..db82f4e 100644 --- a/src/api/CMakeLists.txt +++ b/src/api/CMakeLists.txt @@ -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) -- 2.39.2