Author: Andreas Tille <tille@debian.org>
Last-Update: Wed, 29 Jun 2022 20:34:40 +0200
Description: Enable static and shared library

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -42,18 +42,31 @@
 # add_executable(slow5exmp ${openmp_get_reads})
 
 
-option(SLOW5_LINK_STATIC "libslow5 will create a static lib" OFF) #OFF by default
-if(SLOW5_LINK_STATIC)
-    message( STATUS "libslow5 will create a static lib" )
-    add_library(slow5 STATIC ${slow5_} ${slow5_idx} ${slow5_misc} ${slow5_press})
-else()
-    message( STATUS "libslow5 will create a shared lib" )
+#option(SLOW5_LINK_STATIC "libslow5 will create a static lib" OFF) #OFF by default
+#if(SLOW5_LINK_STATIC)
+#    message( STATUS "libslow5 will create a static lib" )
+    add_library(slow5_static STATIC ${slow5_} ${slow5_idx} ${slow5_misc} ${slow5_press})
+#else()
+#    message( STATUS "libslow5 will create a shared lib" )
     add_library(slow5 SHARED ${slow5_} ${slow5_idx} ${slow5_misc} ${slow5_press})
-endif(SLOW5_LINK_STATIC)
-unset(SLOW5_LINK_STATIC CACHE)
+#endif(SLOW5_LINK_STATIC)
+#unset(SLOW5_LINK_STATIC CACHE)
 
+set_target_properties(slow5 PROPERTIES
+        SOVERSION 0
+)
+
+target_link_libraries(slow5_static)
 target_link_libraries(slow5)
 
+set(slow5_targets slow5 slow5_static)
+
+target_compile_definitions(slow5_static PUBLIC _GLIBCXX_DEBUG) # PUBLIC to maintain ABI compatibility
+target_compile_definitions(slow5 PUBLIC _GLIBCXX_DEBUG) # PUBLIC to maintain ABI compatibility
+
+target_include_directories(slow5_static PUBLIC include)
+target_include_directories(slow5 PUBLIC include)
+
 # Build a static lib
 #add_library(slow5 STATIC ${slow5_} ${slow5_idx} ${slow5_misc} ${slow5_press})
 #
@@ -72,3 +85,10 @@
 #     target_link_libraries(slow5test slow5 streamvbyte_slow5 -lz -ldl -lm)
 #     target_link_libraries(slow5exmp slow5 streamvbyte_slow5 -lz -ldl -lm)
 # ENDIF()
+
+install (
+  TARGETS slow5
+  TARGETS slow5 slow5_static
+  LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
+)
+
