Author: Andreas Tille Last-Update: Thu, 21 Mar 2019 15:53:04 +0100 Description: Adapt build system to Debian packaged libhts --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -71,8 +71,17 @@ ELSE(LINK MATCHES shared) message("shared build") ENDIF(LINK MATCHES static) - include(ExternalProject) +ExternalProject_Add(bifrost + PREFIX ${PROJECT_SOURCE_DIR}/ext/bifrost + SOURCE_DIR ${PROJECT_SOURCE_DIR}/ext/bifrost + BUILD_IN_SOURCE 1 + CONFIGURE_COMMAND mkdir -p build && cd build && cmake .. -DCMAKE_INSTALL_PREFIX=${PREFIX} -DCMAKE_CXX_FLAGS=${PROJECT_BIFROST_CMAKE_CXX_FLAGS} + BUILD_COMMAND cd build && make + INSTALL_COMMAND "" +) + +if(!DEBIAN_BUILD) if (USE_BAM) ExternalProject_Add(htslib PREFIX ${PROJECT_SOURCE_DIR}/ext/htslib @@ -107,15 +116,24 @@ if (ZLIBNG) endif(ZLIBNG) if (USE_BAM) -include_directories(${htslib_PREFIX}/src/htslib) + if(DEBIAN_BUILD) + # For Debian builds, use system htslib + find_package(PkgConfig REQUIRED) + pkg_check_modules(HTSLIB REQUIRED htslib) + include_directories(${HTSLIB_INCLUDE_DIRS}) + link_libraries(${HTSLIB_LIBRARIES}) + else() + # For non-Debian builds, use bundled htslib + include_directories(${htslib_PREFIX}/src/htslib) + endif() endif(USE_BAM) +endif() include_directories(${EXT_PROJECTS_DIR}/bifrost/build/src) ExternalProject_Get_Property(bifrost install_dir) include_directories(${install_dir}/src) - # add_compile_options(-Wdeprecated-register) add_subdirectory(src) --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -3,9 +3,11 @@ file(GLOB headers *.h *.hpp) list(REMOVE_ITEM sources main.cpp) +if(!DEBIAN_BUILD) if (USE_BAM) include_directories(../ext/htslib) endif(USE_BAM) +endif() if(NOT MAX_KMER_SIZE) set(MAX_KMER_SIZE "32") @@ -18,13 +20,28 @@ target_include_directories(kallisto_core add_executable(kallisto main.cpp) +if (DEBIAN_BUILD) + if(USE_BAM) + # Link system htslib for Debian builds + find_package(PkgConfig REQUIRED) + pkg_check_modules(HTSLIB htslib) + target_link_libraries(kallisto ${HTSLIB_LIBRARIES}) + target_link_libraries(kallisto_core ${HTSLIB_LIBRARIES}) + endif() +endif() + find_package( Threads REQUIRED ) ExternalProject_Get_Property(bifrost install_dir) +if(!DEBIAN_BUILD) if (USE_BAM) target_link_libraries(kallisto kallisto_core pthread ${CMAKE_CURRENT_SOURCE_DIR}/../ext/htslib/libhts.a ${install_dir}/build/src/libbifrost.a -DMAX_KMER_SIZE=${MAX_KMER_SIZE}) else() target_link_libraries(kallisto kallisto_core pthread ${install_dir}/build/src/libbifrost.a -DMAX_KMER_SIZE=${MAX_KMER_SIZE}) endif(USE_BAM) +else() +# FIXME: once bifrost is accepted this should be linked against the Debian packaged library +target_link_libraries(kallisto kallisto_core pthread ${install_dir}/build/src/libbifrost.a) +endif() if(LINK MATCHES static) set(BUILD_SHARED_LIBS OFF) @@ -94,4 +111,4 @@ else() endif(LINK MATCHES static) -install(TARGETS kallisto DESTINATION "${CMAKE_INSTALL_BINDIR}") +#install(TARGETS kallisto DESTINATION "${CMAKE_INSTALL_BINDIR}")