Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 49 additions & 0 deletions cmake/FindLIBDEFLATE.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
# SPDX-License-Identifier: GPL-3.0-or-later; (c) 2025 Andrew D Smith (author)
#[=======================================================================[.rst:
FindLIBDEFLATE
--------------

Find the native libdeflate includes and library.

#]=======================================================================]

# FindLIBDEFLATE.cmake
# Custom CMake module to find libdeflate

# Support preference of static libs by adjusting CMAKE_FIND_LIBRARY_SUFFIXES
# ADS: this is taken from the FindBoost.cmake file
if(LIBDEFLATE_USE_STATIC_LIBS)
set(_libdeflate_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES
${CMAKE_FIND_LIBRARY_SUFFIXES}
)
if(WIN32)
list(INSERT CMAKE_FIND_LIBRARY_SUFFIXES 0 .lib .a)
else()
set(CMAKE_FIND_LIBRARY_SUFFIXES .a)
endif()
endif()

find_path(LIBDEFLATE_INCLUDE_DIR NAMES libdeflate.h)
find_library(LIBDEFLATE_LIBRARY NAMES deflate libdeflate)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(LIBDEFLATE
REQUIRED_VARS LIBDEFLATE_LIBRARY LIBDEFLATE_INCLUDE_DIR
VERSION_VAR LIBDEFLATE_VERSION
)

if(LIBDEFLATE_FOUND AND NOT TARGET LIBDEFLATE::LIBDEFLATE)
add_library(LIBDEFLATE::LIBDEFLATE UNKNOWN IMPORTED)
set_target_properties(LIBDEFLATE::LIBDEFLATE PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${LIBDEFLATE_INCLUDE_DIR}"
IMPORTED_LOCATION "${LIBDEFLATE_LIBRARY}"
)
endif()

# Restore the original find library ordering
# ADS: this is take from the FindBoost.cmake file
if(LIBDEFLATE_USE_STATIC_LIBS)
set(CMAKE_FIND_LIBRARY_SUFFIXES
${_libdeflate_ORIG_CMAKE_FIND_LIBRARY_SUFFIXES}
)
endif()
21 changes: 18 additions & 3 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,26 @@
# You should have received a copy of the GNU General Public License along with
# this program. If not, see <https://www.gnu.org/licenses/>.

# Packages
if(USE_LIBDEFLATE)
find_package(LIBDEFLATE REQUIRED)
endif()
if(BUILD_NANOPORE)
find_package(HTSLIB 1.20 REQUIRED)
add_compile_definitions(BUILD_NANOPORE)
else()
find_package(HTSLIB REQUIRED)
endif()
find_package(Threads REQUIRED)
find_package(ZLIB REQUIRED)

if(NOT TARGET bamxx)
add_subdirectory(bamxx)
endif()
# Subdirs
if(NOT TARGET smithlab_cpp)
add_subdirectory(smithlab_cpp)
endif()
if(NOT TARGET bamxx)
add_subdirectory(bamxx)
endif()
add_subdirectory(common)
add_subdirectory(radmeth)
add_subdirectory(utils)
Expand All @@ -46,4 +52,13 @@ target_link_libraries(dnmtools PUBLIC
dnmtools_radmeth_objs
dnmtools_mlml_objs
dnmtools_amrfinder_objs
bamxx
HTSLIB::HTSLIB
ZLIB::ZLIB
Threads::Threads
)
if(USE_LIBDEFLATE)
target_link_libraries(dnmtools PUBLIC
LIBDEFLATE::LIBDEFLATE
)
endif()
1 change: 1 addition & 0 deletions src/amrfinder/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ target_link_libraries(dnmtools_amrfinder_objs PUBLIC
${LIBRARY_OBJECTS}
smithlab_cpp
bamxx
Threads::Threads
)
1 change: 1 addition & 0 deletions src/radmeth/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ target_link_libraries(dnmtools_radmeth_objs PUBLIC
${LIBRARY_OBJECTS}
smithlab_cpp
bamxx
Threads::Threads
)