aboutsummaryrefslogtreecommitdiff
path: root/seqwish-shared-library.diff
blob: be982def5df0826b6a8230810257b690ed4b3a6c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 09eafb5..a39f90f 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -7,6 +7,8 @@ project(seqwish)
 # We build using c++14
 set(CMAKE_CXX_STANDARD 14)
 
+include(GNUInstallDirs)
+
 set(THREADS_PREFER_PTHREAD_FLAG ON)
 find_package(Threads REQUIRED)
 
@@ -26,6 +28,8 @@ if(NOT DEFINED EXTRA_FLAGS)
           "Extra compilation flags for C and CXX." FORCE)
 endif()
 
+set(SEQWISH_LINK_SHARED_LIBRARY OFF CACHE BOOL "Do not link against the libseqwish shared library")
+
 if (${CMAKE_BUILD_TYPE} MATCHES Release)
   set(EXTRA_FLAGS "-Ofast ${EXTRA_FLAGS}")
   set(CMAKE_CXX_FLAGS_RELEASE "-DNDEBUG") # reset CXX_FLAGS to replace -O3 with -Ofast
@@ -82,7 +86,7 @@ include(${CMAKE_ROOT}/Modules/ExternalProject.cmake)
 # sdsl-lite (full build using its cmake config)
 ExternalProject_Add(sdsl-lite
   SOURCE_DIR "${CMAKE_SOURCE_DIR}/deps/sdsl-lite"
-  CMAKE_ARGS "${CMAKE_ARGS};-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
+  CMAKE_ARGS "${CMAKE_ARGS};-DCMAKE_CXX_FLAGS=-fPIC;-DCMAKE_C_FLAGS=-fPIC;-DCMAKE_INSTALL_PREFIX=<INSTALL_DIR>"
   UPDATE_COMMAND ""
   INSTALL_COMMAND "")
 ExternalProject_Get_property(sdsl-lite INSTALL_DIR)
@@ -203,27 +207,125 @@ set(mio_INCLUDE "${SOURCE_DIR}/include")
 #set(CMAKE_BUILD_TYPE Debug)
 set(CMAKE_BUILD_TYPE Release)
 
+# set up our target libraries and specify its dependencies and includes
+add_library( libseqwish_static
+  ${CMAKE_SOURCE_DIR}/src/utils.cpp
+  ${CMAKE_SOURCE_DIR}/src/tempfile.cpp
+  ${CMAKE_SOURCE_DIR}/src/main.cpp
+  ${CMAKE_SOURCE_DIR}/src/seqindex.cpp
+  ${CMAKE_SOURCE_DIR}/src/paf.cpp
+  ${CMAKE_SOURCE_DIR}/src/sxs.cpp
+  ${CMAKE_SOURCE_DIR}/src/cigar.cpp
+  ${CMAKE_SOURCE_DIR}/src/alignments.cpp
+  ${CMAKE_SOURCE_DIR}/src/pos.cpp
+  ${CMAKE_SOURCE_DIR}/src/match.cpp
+  ${CMAKE_SOURCE_DIR}/src/transclosure.cpp
+  ${CMAKE_SOURCE_DIR}/src/links.cpp
+  ${CMAKE_SOURCE_DIR}/src/compact.cpp
+  ${CMAKE_SOURCE_DIR}/src/dna.cpp
+  ${CMAKE_SOURCE_DIR}/src/gfa.cpp
+  ${CMAKE_SOURCE_DIR}/src/vgp.cpp
+  ${CMAKE_SOURCE_DIR}/src/exists.cpp
+  ${CMAKE_SOURCE_DIR}/src/time.cpp
+  ${CMAKE_SOURCE_DIR}/src/mmap.cpp
+  )
+add_dependencies(libseqwish_static tayweeargs)
+add_dependencies(libseqwish_static sdsl-lite)
+add_dependencies(libseqwish_static gzipreader)
+add_dependencies(libseqwish_static mmmulti)
+add_dependencies(libseqwish_static iitii)
+add_dependencies(libseqwish_static ips4o)
+add_dependencies(libseqwish_static bbhash)
+add_dependencies(libseqwish_static atomicbitvector)
+add_dependencies(libseqwish_static atomicqueue)
+add_dependencies(libseqwish_static ska)
+add_dependencies(libseqwish_static paryfor)
+add_dependencies(libseqwish_static mio)
+target_include_directories(libseqwish_static PUBLIC
+  "${sdsl-lite_INCLUDE}"
+  "${sdsl-lite-divsufsort_INCLUDE}"
+  "${tayweeargs_INCLUDE}"
+  "${gzipreader_INCLUDE}"
+  "${ips4o_INCLUDE}"
+  "${mmmulti_INCLUDE}"
+  "${iitii_INCLUDE}"
+  "${bbhash_INCLUDE}"
+  "${atomicbitvector_INCLUDE}"
+  "${atomicqueue_INCLUDE}"
+  "${ska_INCLUDE}"
+  "${paryfor_INCLUDE}"
+  "${mio_INCLUDE}")
+target_link_libraries(libseqwish_static
+  "${sdsl-lite_LIB}/libsdsl.a"
+  "${sdsl-lite-divsufsort_LIB}/libdivsufsort.a"
+  "${sdsl-lite-divsufsort_LIB}/libdivsufsort64.a"
+  "-latomic"
+  Threads::Threads
+  jemalloc
+  z)
+set_target_properties(libseqwish_static PROPERTIES OUTPUT_NAME "seqwish")
+
+add_library( libseqwish SHARED
+  ${CMAKE_SOURCE_DIR}/src/utils.cpp
+  ${CMAKE_SOURCE_DIR}/src/tempfile.cpp
+  ${CMAKE_SOURCE_DIR}/src/main.cpp
+  ${CMAKE_SOURCE_DIR}/src/seqindex.cpp
+  ${CMAKE_SOURCE_DIR}/src/paf.cpp
+  ${CMAKE_SOURCE_DIR}/src/sxs.cpp
+  ${CMAKE_SOURCE_DIR}/src/cigar.cpp
+  ${CMAKE_SOURCE_DIR}/src/alignments.cpp
+  ${CMAKE_SOURCE_DIR}/src/pos.cpp
+  ${CMAKE_SOURCE_DIR}/src/match.cpp
+  ${CMAKE_SOURCE_DIR}/src/transclosure.cpp
+  ${CMAKE_SOURCE_DIR}/src/links.cpp
+  ${CMAKE_SOURCE_DIR}/src/compact.cpp
+  ${CMAKE_SOURCE_DIR}/src/dna.cpp
+  ${CMAKE_SOURCE_DIR}/src/gfa.cpp
+  ${CMAKE_SOURCE_DIR}/src/vgp.cpp
+  ${CMAKE_SOURCE_DIR}/src/exists.cpp
+  ${CMAKE_SOURCE_DIR}/src/time.cpp
+  ${CMAKE_SOURCE_DIR}/src/mmap.cpp
+  ${CMAKE_SOURCE_DIR}/src/version.cpp
+  )
+add_dependencies(libseqwish tayweeargs)
+add_dependencies(libseqwish sdsl-lite)
+add_dependencies(libseqwish gzipreader)
+add_dependencies(libseqwish mmmulti)
+add_dependencies(libseqwish iitii)
+add_dependencies(libseqwish ips4o)
+add_dependencies(libseqwish bbhash)
+add_dependencies(libseqwish atomicbitvector)
+add_dependencies(libseqwish atomicqueue)
+add_dependencies(libseqwish ska)
+add_dependencies(libseqwish paryfor)
+add_dependencies(libseqwish mio)
+target_include_directories(libseqwish PUBLIC
+  "${sdsl-lite_INCLUDE}"
+  "${sdsl-lite-divsufsort_INCLUDE}"
+  "${tayweeargs_INCLUDE}"
+  "${gzipreader_INCLUDE}"
+  "${ips4o_INCLUDE}"
+  "${mmmulti_INCLUDE}"
+  "${iitii_INCLUDE}"
+  "${bbhash_INCLUDE}"
+  "${atomicbitvector_INCLUDE}"
+  "${atomicqueue_INCLUDE}"
+  "${ska_INCLUDE}"
+  "${paryfor_INCLUDE}"
+  "${mio_INCLUDE}")
+target_link_libraries(libseqwish
+  "${sdsl-lite_LIB}/libsdsl.a"
+  "${sdsl-lite-divsufsort_LIB}/libdivsufsort.a"
+  "${sdsl-lite-divsufsort_LIB}/libdivsufsort64.a"
+  "-latomic"
+  Threads::Threads
+  jemalloc
+  z)
+set_target_properties(libseqwish PROPERTIES OUTPUT_NAME "seqwish")
+
 # set up our target executable and specify its dependencies and includes
 add_executable(seqwish
-  ${CMAKE_SOURCE_DIR}/src/utils.cpp
-  ${CMAKE_SOURCE_DIR}/src/tempfile.cpp
   ${CMAKE_SOURCE_DIR}/src/main.cpp
-  ${CMAKE_SOURCE_DIR}/src/seqindex.cpp
-  ${CMAKE_SOURCE_DIR}/src/paf.cpp
-  ${CMAKE_SOURCE_DIR}/src/sxs.cpp
-  ${CMAKE_SOURCE_DIR}/src/cigar.cpp
-  ${CMAKE_SOURCE_DIR}/src/alignments.cpp
-  ${CMAKE_SOURCE_DIR}/src/pos.cpp
-  ${CMAKE_SOURCE_DIR}/src/match.cpp
-  ${CMAKE_SOURCE_DIR}/src/transclosure.cpp
-  ${CMAKE_SOURCE_DIR}/src/links.cpp
-  ${CMAKE_SOURCE_DIR}/src/compact.cpp
-  ${CMAKE_SOURCE_DIR}/src/dna.cpp
-  ${CMAKE_SOURCE_DIR}/src/gfa.cpp
-  ${CMAKE_SOURCE_DIR}/src/vgp.cpp
-  ${CMAKE_SOURCE_DIR}/src/exists.cpp
-  ${CMAKE_SOURCE_DIR}/src/time.cpp
-  ${CMAKE_SOURCE_DIR}/src/mmap.cpp
   ${CMAKE_SOURCE_DIR}/src/version.cpp
   )
 add_dependencies(seqwish tayweeargs)
@@ -252,6 +354,11 @@ target_include_directories(seqwish PUBLIC
   "${ska_INCLUDE}"
   "${paryfor_INCLUDE}"
   "${mio_INCLUDE}")
+if( SEQWISH_LINK_SHARED_LIBRARY )
+    target_link_libraries( seqwish libseqwish )
+else()
+    target_link_libraries( seqwish libseqwish_static )
+endif()
 target_link_libraries(seqwish
   "${sdsl-lite_LIB}/libsdsl.a"
   "${sdsl-lite-divsufsort_LIB}/libdivsufsort.a"
@@ -269,4 +376,6 @@ endif()
 file(MAKE_DIRECTORY ${CMAKE_SOURCE_DIR}/include)
 execute_process(COMMAND bash ${CMAKE_SOURCE_DIR}/scripts/generate_git_version.sh ${CMAKE_SOURCE_DIR}/include)
 
-install(TARGETS seqwish DESTINATION bin)
+install(TARGETS seqwish DESTINATION "${CMAKE_INSTALL_BIDIR}")
+install(TARGETS libseqwish LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}")
+install(TARGETS libseqwish_static ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}")