|
| 1 | +cmake_minimum_required(VERSION 3.20) |
| 2 | +project(FastANI |
| 3 | + VERSION 1.34 |
| 4 | + DESCRIPTION "Fast computation of whole-genome Average Nucleotide Identity (ANI)." |
| 5 | + LANGUAGES CXX) |
| 6 | +# |
| 7 | +# Main executable |
| 8 | +add_executable(FastANI src/cgi/core_genome_identity.cpp src/cgi/main.cpp) |
| 9 | +target_include_directories(FastANI PUBLIC "src/") |
| 10 | +# |
| 11 | +# by default, static linking |
| 12 | +option(GSL_SHARED "Build using shared libraries" OFF) |
| 13 | +option(BUILD_TESTING "Build tests" ON) # build tests |
| 14 | +# |
| 15 | +# zlib dependency |
| 16 | +find_package(ZLIB 1.1 REQUIRED) |
| 17 | +if(${ZLIB_FOUND}) |
| 18 | + message("Using zlib library v${ZLIB_VERSION_STRING}") |
| 19 | +endif(${ZLIB_FOUND}) |
| 20 | +target_link_libraries(FastANI PUBLIC ZLIB::ZLIB) |
| 21 | +# |
| 22 | +# openmp dependency |
| 23 | +find_package(OpenMP) |
| 24 | +if(${OpenMP_CXX_FOUND}) |
| 25 | + message("Using OpenMP_CXX v${OpenMP_CXX_VERSION}") |
| 26 | + target_link_libraries(FastANI PUBLIC ${OpenMP_CXX_LIBRARIES}) |
| 27 | + target_include_directories(FastANI PUBLIC ${OpenMP_CXX_INCLUDE_DIRS}) |
| 28 | + target_compile_options(FastANI PUBLIC ${OpenMP_CXX_FLAGS}) |
| 29 | +else() |
| 30 | + message("NOTE: OpenMP not found; Compiling as a single threaded app...") |
| 31 | +endif(${OpenMP_CXX_FOUND}) |
| 32 | +# |
| 33 | +# GSL or Boost math |
| 34 | +find_package(GSL 1.6) |
| 35 | +if(${GSL_FOUND}) |
| 36 | + message("GSL v${GSL_VERSION} Found: ${GSL_LIBDIR}") |
| 37 | + if(${GSL_SHARED}) |
| 38 | + target_link_libraries(FastANI PUBLIC ${GSL_LIBRARIES}) |
| 39 | + else() |
| 40 | + # GSL_LIBDIR is not documented |
| 41 | + target_link_libraries(FastANI PUBLIC |
| 42 | + ${GSL_LIBDIR}/libgsl.a |
| 43 | + ${GSL_LIBDIR}/libgslcblas.a) |
| 44 | + endif(${GSL_SHARED}) |
| 45 | + target_include_directories(FastANI PUBLIC ${GSL_INCLUDE_DIRS}) |
| 46 | +else() |
| 47 | + set(Boost_USE_STATIC_LIBS ON) # only find static libs |
| 48 | + set(Boost_USE_DEBUG_LIBS OFF) # ignore debug libs and |
| 49 | + set(Boost_USE_RELEASE_LIBS ON) # only find release libs |
| 50 | + set(Boost_USE_MULTITHREADED ON) |
| 51 | + find_package(Boost 1.45 REQUIRED COMPONENTS math_c99) |
| 52 | + target_link_libraries(FastANI PUBLIC ${Boost_MATCH_C99_LIBRARY}) |
| 53 | + target_include_directories(FastANI PUBLIC ${Boost_INCLUDE_DIRS}) |
| 54 | + target_compile_definitions(FastANI PUBLIC USE_BOOST=1) |
| 55 | +endif(${GSL_FOUND}) |
| 56 | +# |
| 57 | +# |
| 58 | +if(${BUILD_TESTING}) |
| 59 | + add_subdirectory(ext/Catch2) |
| 60 | + include(CTest) |
| 61 | + include(Catch) |
| 62 | + add_executable(FastANITest tests/fastani_tests.cpp src/cgi/core_genome_identity.cpp) |
| 63 | + target_include_directories(FastANITest PUBLIC "src/" |
| 64 | + ${OpenMP_CXX_INCLUDE_DIRS}) |
| 65 | + target_compile_options(FastANITest PUBLIC |
| 66 | + --coverage -g -O0 -fprofile-arcs -ftest-coverage ${OpenMP_CXX_FLAGS}) |
| 67 | + target_link_libraries(FastANITest PRIVATE |
| 68 | + Catch2::Catch2 Catch2::Catch2WithMain |
| 69 | + ZLIB::ZLIB GSL::gsl GSL::gslcblas |
| 70 | + ${OpenMP_CXX_LIBRARIES} |
| 71 | + gcov) |
| 72 | + catch_discover_tests(FastANITest) |
| 73 | + file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) |
| 74 | + add_custom_target(lcov lcov -c -d .. -o FastANITest.out |
| 75 | + COMMAND genhtml -o ../lcov/ FastANITest.out |
| 76 | + DEPENDS FastANITest) |
| 77 | + add_custom_target(lcov2 lcov -c -d ./ -o FastANITest.info |
| 78 | + COMMAND lcov -e FastANITest.info "*/FastANI/src/*/*.cpp" "*/FastANI/src/*/*.hpp" > coverage.info |
| 79 | + COMMAND lcov --list coverage.info |tee coverage_list.txt |
| 80 | + COMMAND lcov --summary coverage.info |tee coverage_summary.txt |
| 81 | + DEPENDS FastANITest) |
| 82 | +endif(${BUILD_TESTING}) |
| 83 | + |
| 84 | +set(CPACK_GENERATOR "TGZ") |
| 85 | +set(CPACK_SOURCE_GENERATOR "TGZ") |
| 86 | +set(CPACK_PACKAGE_DIRECTORY ${PROJECT_BINARY_DIR}/package) |
| 87 | + |
| 88 | +set(CPACK_SOURCE_IGNORE_FILES .git/ .github/ |
| 89 | + .vscode/ .cache/ .mypy_cache/ |
| 90 | + .idea/ complie_comands.json |
| 91 | + lcov/ lcov0/ lcov2/ data/ cmake-build-debug/ |
| 92 | + _CPack_Packages/ build.sh/ build/ build.clang/ |
| 93 | + ${CMAKE_BINARY_DIR}/ ${PROJECT_BINARY_DIR}/) |
| 94 | + |
| 95 | +include(CPack) |
0 commit comments