Skip to content

Commit 62f03b9

Browse files
CMakeLists.txt: adding controls for linking and including htslib
1 parent e9145d1 commit 62f03b9

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

CMakeLists.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ if(STATIC_ANALYSIS)
4040
include(cmake/static_analysis.cmake)
4141
endif()
4242

43+
list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake")
44+
4345
add_compile_options(
4446
-Wall
4547
-Wextra
@@ -49,6 +51,8 @@ add_compile_options(
4951
)
5052

5153
file(GLOB cpp_files "*.cpp")
54+
# exclude htslib_wrapper unless (below) USE_HTSLIB is set
55+
list(FILTER cpp_files EXCLUDE REGEX "htslib_wrapper.cpp")
5256

5357
set(LIBRARY_OBJECTS "")
5458
foreach(cpp_file ${cpp_files})
@@ -57,6 +61,17 @@ foreach(cpp_file ${cpp_files})
5761
list(APPEND LIBRARY_OBJECTS ${BASE_NAME})
5862
endforeach()
5963

64+
if(USE_HTSLIB)
65+
find_package(HTSLIB REQUIRED)
66+
find_package(Threads REQUIRED)
67+
add_library(htslib_wrapper OBJECT htslib_wrapper.cpp)
68+
list(APPEND LIBRARY_OBJECTS htslib_wrapper)
69+
target_link_libraries(htslib_wrapper PUBLIC
70+
HTSLIB::HTSLIB
71+
Threads::Threads
72+
)
73+
endif()
74+
6075
add_library(smithlab_cpp)
6176
target_include_directories(smithlab_cpp PUBLIC
6277
${CMAKE_CURRENT_SOURCE_DIR}

0 commit comments

Comments
 (0)