diff --git a/CMakeLists.txt b/CMakeLists.txt index cd5b978..0a3ea09 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,20 @@ project(KMC VERSION 1.0 DESCRIPTION "SBWT fork of KMC" LANGUAGES CXX) +find_package(Git QUIET) +if(GIT_FOUND AND EXISTS "${PROJECT_SOURCE_DIR}/.git") + option(GIT_SUBMODULE "Check submodules during build" ON) + if(GIT_SUBMODULE) + message(STATUS "Submodule update") + execute_process(COMMAND ${GIT_EXECUTABLE} submodule update --init --recursive + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} + RESULT_VARIABLE GIT_SUBMOD_RESULT) + if(NOT GIT_SUBMOD_RESULT EQUAL "0") + message(FATAL_ERROR "git submodule update --init --recursive failed with ${GIT_SUBMOD_RESULT}, please checkout submodules") + endif() + endif() +endif() + if(NOT ZLIB) find_library(ZLIB NAMES z PATHS ${CMAKE_CURRENT_SOURCE_DIR}/kmc_tools/libs/ REQUIRED) endif() @@ -11,24 +25,28 @@ if(NOT BZIP2) find_library(BZIP2 NAMES bz2 PATHS ${CMAKE_CURRENT_SOURCE_DIR}/kmc_tools/libs/ REQUIRED) endif() - set(KMC_MAIN_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kmc_core) set(KMC_CLI_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kmc_CLI) set(KMC_API_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kmc_api) set(KMC_TOOLS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/kmc_tools) if(APPLE) - add_library(RADULS_SSE2_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_sse2.cpp) - target_compile_options(RADULS_SSE2_OBJS PRIVATE -msse2 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) - - add_library(RADULS_SSE41_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_sse41.cpp) - target_compile_options(RADULS_SSE41_OBJS PRIVATE -msse4.1 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) - - add_library(RADULS_AVX_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_avx.cpp) - target_compile_options(RADULS_AVX_OBJS PRIVATE -mavx -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) - - add_library(RADULS_AVX2_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_avx2.cpp) - target_compile_options(RADULS_AVX2_OBJS PRIVATE -mavx2 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") + add_library(RADULS_NEON_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_neon.cpp) + target_compile_options(RADULS_NEON_OBJS PRIVATE -march=armv8-a -O3 -static-libgcc -static-libstdc++ -pthread -std=c++14) + else() + add_library(RADULS_SSE2_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_sse2.cpp) + target_compile_options(RADULS_SSE2_OBJS PRIVATE -msse2 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + + add_library(RADULS_SSE41_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_sse41.cpp) + target_compile_options(RADULS_SSE41_OBJS PRIVATE -msse4.1 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + + add_library(RADULS_AVX_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_avx.cpp) + target_compile_options(RADULS_AVX_OBJS PRIVATE -mavx -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + + add_library(RADULS_AVX2_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_avx2.cpp) + target_compile_options(RADULS_AVX2_OBJS PRIVATE -mavx2 -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + endif() else() add_library(RADULS_SSE2_OBJS OBJECT ${KMC_MAIN_DIR}/raduls_sse2.cpp) target_compile_options(RADULS_SSE2_OBJS PRIVATE -msse2 -O3 -m64 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++14) @@ -43,15 +61,23 @@ else() target_compile_options(RADULS_AVX2_OBJS PRIVATE -mavx2 -O3 -m64 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++14) endif() +# KKMC CLI OBJECTS + add_library(KMC_CLI_OBJS OBJECT ${KMC_CLI_DIR}/kmc.cpp) +# KFF OBJECTS + add_library(KFF_OBJS OBJECT ${KMC_MAIN_DIR}/kff_writer.cpp) +# KMC API OBJECTS + add_library(KMC_API_OBJS OBJECT ${KMC_API_DIR}/mmer.cpp ${KMC_API_DIR}/kmc_file.cpp ${KMC_API_DIR}/kmer_api.cpp) +# KMC CORE OBJECTS + add_library(KMC_CORE_OBJS OBJECT ${KMC_MAIN_DIR}/mem_disk_file.cpp ${KMC_MAIN_DIR}/rev_byte.cpp @@ -68,6 +94,8 @@ add_library(KMC_CORE_OBJS OBJECT ${KMC_MAIN_DIR}/kb_collector.cpp ${KMC_MAIN_DIR}/kmc_runner.cpp) +# KMC TOOLS OBJECTS + add_library(KMC_TOOLS_OBJS OBJECT ${KMC_TOOLS_DIR}/kmer_file_header.cpp ${KMC_TOOLS_DIR}/kmc_tools.cpp @@ -84,20 +112,39 @@ add_library(KMC_TOOLS_OBJS OBJECT ${KMC_API_DIR}/kmc_file.cpp ${KMC_API_DIR}/kmer_api.cpp) -add_library(kmc_core STATIC - $ - $ - $ - $ - $ - $ - $) +# KMC CORE + +if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") + add_library(kmc_core STATIC + $ + $ + $ + $) +else() + add_library(kmc_core STATIC + $ + $ + $ + $ + $ + $ + $) +endif() + if(APPLE) - target_compile_options(kmc_core PRIVATE -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) - target_link_libraries(kmc_core PRIVATE - ${ZLIB} - ${BZIP2}) - target_link_options(kmc_core PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") + target_compile_options(kmc_core PRIVATE -O3 -static-libgcc -static-libstdc++ -pthread -std=c++14) + target_link_libraries(kmc_core PRIVATE + ${ZLIB} + ${BZIP2}) + target_link_options(kmc_core PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + else() + target_compile_options(kmc_core PRIVATE -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + target_link_libraries(kmc_core PRIVATE + ${ZLIB} + ${BZIP2}) + target_link_options(kmc_core PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + endif() else() target_compile_options(kmc_core PRIVATE -O3 -m64 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++14) target_link_libraries(kmc_core PRIVATE @@ -106,16 +153,27 @@ else() target_link_options(kmc_core PRIVATE -lm -static -O3 -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++14) endif() +# KMC TOOLS + add_library(kmc_tools STATIC $ $ $) + if(APPLE) - target_compile_options(kmc_tools PRIVATE -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) - target_link_libraries(kmc_tools PRIVATE - ${ZLIB} - ${BZIP2}) - target_link_options(kmc_tools PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + if(CMAKE_SYSTEM_PROCESSOR MATCHES "arm64") + target_compile_options(kmc_tools PRIVATE -O3 -static-libgcc -static-libstdc++ -pthread -std=c++14) + target_link_libraries(kmc_tools PRIVATE + ${ZLIB} + ${BZIP2}) + target_link_options(kmc_tools PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + else() + target_compile_options(kmc_tools PRIVATE -O3 -m64 -static-libgcc -static-libstdc++ -pthread -std=c++14) + target_link_libraries(kmc_tools PRIVATE + ${ZLIB} + ${BZIP2}) + target_link_options(kmc_tools PRIVATE -lm -static-libgcc -static-libstdc++ -O3 -pthread -std=c++14) + endif() else() target_compile_options(kmc_tools PRIVATE -O3 -m64 -static -Wl,--whole-archive -lpthread -Wl,--no-whole-archive -std=c++14) target_link_libraries(kmc_tools PRIVATE