Skip to content

Commit

Permalink
strongly improved building by more efficient use of libfastafs
Browse files Browse the repository at this point in the history
  • Loading branch information
yhoogstrate committed Jan 22, 2022
1 parent b28592d commit cc861ee
Show file tree
Hide file tree
Showing 2 changed files with 100 additions and 339 deletions.
186 changes: 100 additions & 86 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,6 @@ add_custom_target(tidy DEPENDS make_tidy )


add_subdirectory(src)
#include_directories(${BUILD_DIR})
include_directories("${BUILD_DIR}/include")
include_directories("${CMAKE_SOURCE_DIR}/include")

Expand Down Expand Up @@ -118,57 +117,11 @@ else()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -D_FILE_OFFSET_BITS=64")
endif()

add_executable(fastafs
src/main.cpp
src/fasta_to_fastafs.cpp
src/ucsc2bit_to_fastafs.cpp
src/flags.cpp
src/fastafs.cpp
src/ucsc2bit.cpp
src/twobit_byte.cpp
src/fourbit_byte.cpp
src/fivebit_fivebytes.cpp
src/database.cpp
src/utils.cpp
src/sequence_region.cpp
src/fuse.cpp
src/lsfastafs.cpp
src/chunked_reader.cpp


dependencies/zstd-lib-common/xxhash.c
dependencies/zstd-seekable-adapted/zstdseek_utils.cpp
dependencies/zstd-seekable-adapted/zstdseek_compress.cpp
dependencies/zstd-seekable-adapted/zstdseek_decompress.cpp
)
set_target_properties(fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")

# mount-only binary, without all the other stuff 'mount.fastafs' [for fstab]
add_executable(mount.fastafs
src/main_mount.cpp
src/fasta_to_fastafs.cpp
src/ucsc2bit_to_fastafs.cpp
src/flags.cpp
src/fastafs.cpp
src/ucsc2bit.cpp
src/twobit_byte.cpp
src/fourbit_byte.cpp
src/fivebit_fivebytes.cpp
src/database.cpp
src/utils.cpp
src/sequence_region.cpp
src/fuse.cpp
src/lsfastafs.cpp
src/chunked_reader.cpp
# ----------------------------------------------------------------------
# ----------------------------- Build lib ------------------------------


dependencies/zstd-lib-common/xxhash.c
dependencies/zstd-seekable-adapted/zstdseek_utils.cpp
dependencies/zstd-seekable-adapted/zstdseek_compress.cpp
dependencies/zstd-seekable-adapted/zstdseek_decompress.cpp
)
set_target_properties(mount.fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")

add_library(libfastafs SHARED
src/fasta_to_fastafs.cpp
src/ucsc2bit_to_fastafs.cpp
Expand All @@ -190,64 +143,125 @@ add_library(libfastafs SHARED
dependencies/zstd-seekable-adapted/zstdseek_utils.cpp
dependencies/zstd-seekable-adapted/zstdseek_compress.cpp
dependencies/zstd-seekable-adapted/zstdseek_decompress.cpp

include/chunked_reader.hpp
include/database.hpp
include/fastafs.hpp
include/fasta_to_fastafs.hpp
include/fivebit_fivebytes.hpp
include/flags.hpp
include/fourbit_byte.hpp
include/fuse.hpp
include/lsfastafs.hpp
include/sequence_region.hpp
include/twobit_byte.hpp
include/ucsc2bit.hpp
include/ucsc2bit_to_fastafs.hpp
include/utils.hpp

)
target_include_directories(libfastafs PUBLIC include)
target_sources(libfastafs PUBLIC include/fastafs.hpp)
target_include_directories(libfastafs PUBLIC dependencies/zstd-lib-common)
target_include_directories(libfastafs PUBLIC dependencies/zstd-seekable-adapted)


set_target_properties(libfastafs PROPERTIES LIBRARY_OUTPUT_DIRECTORY "lib")
set_target_properties(libfastafs PROPERTIES VERSION ${PROJECT_VERSION})
set_target_properties(libfastafs PROPERTIES SOVERSION 1)
set_target_properties(libfastafs PROPERTIES OUTPUT_NAME fastafs)


##set_target_properties(libfastafs PROPERTIES HEADER_OUTPUT_DIRECTORY "include")
## great, this doesn't go automagically with an entire dir
set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER "include/config.hpp;include/chunked_reader.hpp;include/database.hpp;include/fastafs.hpp;include/fasta_to_fastafs.hpp;include/flags.hpp;include/fourbit_byte.hpp;include/fuse.hpp;include/lsfastafs.hpp;include/sequence_region.hpp;include/twobit_byte.hpp;include/ucsc2bit.hpp;include/ucsc2bit_to_fastafs.hpp;include/utils.hpp")
set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER_DIRECTORY include)
##set_target_properties(libfastafs PROPERTIES PUBLIC_HEADER_OUTPUT_DIRECTORY "include")

# ----------------------------------------------------------------------
# ----------------------------- Build exe ------------------------------


add_executable(fastafs src/main.cpp)
set_target_properties(fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")
target_link_libraries(fastafs libfastafs)

# mount-only binary, without all the other stuff 'mount.fastafs' [for fstab]
add_executable(mount.fastafs src/main_mount.cpp)
set_target_properties(mount.fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${BUILD_DIR}")
target_link_libraries(mount.fastafs libfastafs)



# ----------------------------------------------------------------------
# ------------------------------ Testing -------------------------------

add_subdirectory(test)
#add_subdirectory(test)

set(BUILD_TEST_DIR "${BUILD_DIR}/test")
enable_testing()

add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND}) # 'make check' as alias for 'make test'

add_test(test_twobit_byte "${BUILD_TEST_DIR}/test_twobit_byte") # ACTG(N) | ACUG(N)
add_test(test_fourbit_byte "${BUILD_TEST_DIR}/test_fourbit_byte") # ACGTURYKMSWBDHVN(-)
add_test(test_fivebit_fivebytes "${BUILD_TEST_DIR}/test_fivebit_fivebytes")
add_test(test_cache "${BUILD_TEST_DIR}/test_cache")
add_test(test_view "${BUILD_TEST_DIR}/test_view")
add_test(test_flags "${BUILD_TEST_DIR}/test_flags")
add_test(test_fastafs "${BUILD_TEST_DIR}/test_fastafs")
add_test(test_check "${BUILD_TEST_DIR}/test_check") # file integrity checks
add_test(test_fastafs_as_ucsc2bit "${BUILD_TEST_DIR}/test_fastafs_as_ucsc2bit")
add_test(test_ucsc2bit_to_fastafs "${BUILD_TEST_DIR}/test_ucsc2bit_to_fastafs")
add_test(test_ucsc2bit_as_fasta "${BUILD_TEST_DIR}/test_ucsc2bit_as_fasta")
add_test(test_sequenceregion "${BUILD_TEST_DIR}/test_sequenceregion")
add_test(test_utils "${BUILD_TEST_DIR}/test_utils")
add_test(test_functional "test/test_functional.py")
#add_test(test_tree "${BUILD_TEST_DIR}/test_tree")

#find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) # 'ctest -T memcheck'
#INCLUDE(Dart)

add_executable(test_cache test/cache/test_cache.cpp)
set_target_properties(test_cache PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_cache libfastafs)
add_test(test_cache ${BUILD_TEST_DIR}/test_cache)

add_executable(test_check test/check/test_check.cpp)
set_target_properties(test_check PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_check libfastafs)
add_test(test_check ${BUILD_TEST_DIR}/test_check)

add_executable(test_chunked_reader test/chunked_reader/test_chunked_reader.cpp )
add_test(test_chunked_reader ${BUILD_TEST_DIR}/test_chunked_reader)
set_target_properties(test_chunked_reader PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_chunked_reader libfastafs)

add_executable(test_fastafs_as_ucsc2bit test/fastafs/test_ucsc2bit.cpp)
add_test(test_fastafs_as_ucsc2bit ${BUILD_TEST_DIR}/test_fastafs_as_ucsc2bit)
set_target_properties(test_fastafs_as_ucsc2bit PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fastafs_as_ucsc2bit libfastafs)

add_executable(test_fastafs test/fastafs/test_fastafs.cpp)
add_test(test_fastafs ${BUILD_TEST_DIR}/test_fastafs)
set_target_properties(test_fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fastafs libfastafs)

add_executable(test_fivebit_byte test/fivebit_fivebytes/test_fivebit_fivebytes.cpp)
add_test(test_fivebit_byte ${BUILD_TEST_DIR}/test_fivebit_byte)
set_target_properties(test_fivebit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fivebit_byte libfastafs)

add_executable(test_flags test/flags/test_flags.cpp)
add_test(test_flags ${BUILD_TEST_DIR}/test_flags)
set_target_properties(test_flags PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_flags libfastafs)

add_executable(test_fourbit_byte test/fourbit_byte/test_fourbit_byte.cpp)
add_test(test_fourbit_byte ${BUILD_TEST_DIR}/test_fourbit_byte)
set_target_properties(test_fourbit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_fourbit_byte libfastafs)

add_executable(test_sequenceregion test/sequenceregion/test_sequenceregion.cpp)
add_test(test_sequenceregion ${BUILD_TEST_DIR}/test_sequenceregion)
set_target_properties(test_sequenceregion PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_sequenceregion libfastafs)

add_executable(test_twobit_byte test/twobit_byte/test_twobit_byte.cpp)
add_test(test_twobit_byte ${BUILD_TEST_DIR}/test_twobit_byte)
set_target_properties(test_twobit_byte PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_twobit_byte libfastafs)

add_executable(test_ucsc2bit_as_fasta test/ucsc2bit/test_ucsc2bit_as_fasta.cpp)
add_test(test_ucsc2bit_as_fasta ${BUILD_TEST_DIR}/test_ucsc2bit_as_fasta)
set_target_properties(test_ucsc2bit_as_fasta PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_ucsc2bit_as_fasta libfastafs)

add_executable(test_ucsc2bit_to_fastafs test/ucsc2bit_to_fastafs/test_ucsc2bit_to_fastafs.cpp)
add_test(test_ucsc2bit_to_fastafs ${BUILD_TEST_DIR}/test_ucsc2bit_to_fastafs)
set_target_properties(test_ucsc2bit_to_fastafs PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_ucsc2bit_to_fastafs libfastafs)

add_executable(test_utils test/utils/test_utils.cpp)
add_test(test_utils ${BUILD_TEST_DIR}/test_utils)
set_target_properties(test_utils PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_utils libfastafs)

add_executable(test_view test/view/test_view.cpp)
add_test(test_view ${BUILD_TEST_DIR}/test_view)
set_target_properties(test_view PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${BUILD_TEST_DIR})
target_link_libraries(test_view libfastafs)


#add_test(test_functional "test/test_functional.py")


find_program(CTEST_MEMORYCHECK_COMMAND NAMES valgrind) # 'ctest -T memcheck'
INCLUDE(Dart)

# ----------------------------------------------------------------------
# --------------------------- Installation -----------------------------
Expand Down
Loading

0 comments on commit cc861ee

Please sign in to comment.