Skip to content
Open
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ data/
core
man/
example/output/
.DS_Store
50 changes: 9 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,15 @@
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.13)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES};Profile")

project(Bifrost)

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE} -pg")
set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE} -pg")
set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} -pg")
set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} -pg")
endif()

# To enable a larger default k-mer size, replace MAX_KMER_SIZE with a larger multiple of 32: actual maximum k-mer size will be MAX_KMER_SIZE-1.
SET(MAX_KMER_SIZE "32" CACHE STRING "MAX_KMER_SIZE")
SET(MAX_GMER_SIZE "${MAX_KMER_SIZE}" CACHE STRING "MAX_GMER_SIZE")
Expand All @@ -10,46 +18,6 @@ SET(COMPILATION_ARCH "native" CACHE STRING "COMPILATION_ARCH")
# Enable AVX2 instructions
SET(ENABLE_AVX2 "ON" CACHE STRING "ENABLE_AVX2")

# Set some default compile flags
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")

set_property(SOURCE BlockedBloomFilter.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -funroll-loops")

if(COMPILATION_ARCH MATCHES "OFF")
message("Disabling native architecture compilation (including AVX2)")
else(COMPILATION_ARCH MATCHES "OFF")
message("Compilation architecture: ${COMPILATION_ARCH}")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -march=${COMPILATION_ARCH}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=${COMPILATION_ARCH}")
endif(COMPILATION_ARCH MATCHES "OFF")

if(ENABLE_AVX2 MATCHES "OFF")
message("Disabling AVX2 instructions")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -mno-avx2")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mno-avx2")
endif(ENABLE_AVX2 MATCHES "OFF")

# Manages build types
if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif(NOT CMAKE_BUILD_TYPE)

if(CMAKE_BUILD_TYPE MATCHES Debug)
message("Build type: Debug")
add_compile_options(-g)
else(CMAKE_BUILD_TYPE MATCHES Debug)
if(CMAKE_BUILD_TYPE MATCHES Profile)
message("Build type: Profiling")
add_compile_options(-pg)
set(CMAKE_SHARED_LINKER_FLAGS "-pg")
set(CMAKE_EXE_LINKER_FLAGS "-pg")
else(CMAKE_BUILD_TYPE MATCHES Profile)
message("Build type: Release")
add_compile_options(-O3)
endif(CMAKE_BUILD_TYPE MATCHES Profile)
endif(CMAKE_BUILD_TYPE MATCHES Debug)

MATH(EXPR PRINT_MAX_KMER_SIZE "${MAX_KMER_SIZE}-1")
message("Maximum k-mer size: " ${PRINT_MAX_KMER_SIZE})

Expand Down
66 changes: 58 additions & 8 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,32 +6,82 @@ list(REMOVE_ITEM sources Bifrost.cpp)
add_definitions(-DMAX_KMER_SIZE=${MAX_KMER_SIZE})
add_definitions(-DMAX_GMER_SIZE=${MAX_GMER_SIZE})

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
# Make sure to add trailing space
set(PROFILE_FLAGS "$<$<CONFIG:Profile>:-pg> ")
else()
if("${CONFIG}" STREQUAL "Profile" OR "${CMAKE_BUILD_TYPE}" STREQUAL "Profile")
message(FATAL_ERROR "Profiling is only supported with GCC")
endif()
endif()

set(BIFROST_COMPILER_FLAGS "${PROFILE_FLAGS}")
set(BIFROST_LINKER_FLAGS "${PROFILE_FLAGS}")

if(COMPILATION_ARCH MATCHES "OFF")
message("Disabling native architecture compilation (including AVX2)")
else(COMPILATION_ARCH MATCHES "OFF")
message("Compilation architecture: ${COMPILATION_ARCH}")
set(BIFROST_COMPILER_FLAGS "${BIFROST_COMPILER_FLAGS} -march=${COMPILATION_ARCH}")
endif(COMPILATION_ARCH MATCHES "OFF")

if(ENABLE_AVX2 MATCHES "OFF")
message("Disabling AVX2 instructions")
set(BIFROST_COMPILER_FLAGS "${BIFROST_COMPILER_FLAGS} -mno-avx2")
endif(ENABLE_AVX2 MATCHES "OFF")

add_library(bifrost_static STATIC ${sources} ${headers})
add_library(bifrost_dynamic SHARED ${sources} ${headers})

set_target_properties(bifrost_static PROPERTIES OUTPUT_NAME "bifrost")
set_target_properties(bifrost_dynamic PROPERTIES OUTPUT_NAME "bifrost")

target_include_directories(bifrost_static PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(bifrost_dynamic PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
target_include_directories(bifrost_dynamic PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
)

add_executable(Bifrost Bifrost.cpp)
target_compile_features(bifrost_static PUBLIC cxx_std_11)
target_compile_features(bifrost_static PRIVATE c_std_11)
target_compile_features(bifrost_dynamic PUBLIC cxx_std_11 c_std_11)
target_compile_features(bifrost_dynamic PRIVATE c_std_11)

target_compile_options(bifrost_static PUBLIC "${BIFROST_COMPILER_FLAGS}")
target_compile_options(bifrost_dynamic PUBLIC "${BIFROST_COMPILER_FLAGS}")

target_link_options(bifrost_static PUBLIC "${BIFROST_LINKER_FLAGS}")
target_link_options(bifrost_dynamic PUBLIC "${BIFROST_LINKER_FLAGS}")

target_compile_definitions(bifrost_static PRIVATE "${BIFROST_COMPILER_DEFINITIONS}")
target_compile_definitions(bifrost_dynamic PRIVATE "${BIFROST_COMPILER_DEFINITIONS}")

find_package(Threads REQUIRED)
target_link_libraries(bifrost_static ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(bifrost_dynamic ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(bifrost_static PUBLIC ${CMAKE_THREAD_LIBS_INIT})
target_link_libraries(bifrost_dynamic PUBLIC ${CMAKE_THREAD_LIBS_INIT})

find_package(ZLIB REQUIRED)
target_link_libraries(bifrost_static ${ZLIB_LIBRARIES})
target_link_libraries(bifrost_dynamic ${ZLIB_LIBRARIES})

if (ZLIB_FOUND)
include_directories(${ZLIB_INCLUDE_DIRS})
target_link_libraries(bifrost_static PUBLIC ${ZLIB_LIBRARIES})
target_link_libraries(bifrost_dynamic PUBLIC ${ZLIB_LIBRARIES})

target_include_directories(bifrost_static PUBLIC ${ZLIB_INCLUDE_DIRS})
target_include_directories(bifrost_dynamic PUBLIC ${ZLIB_INCLUDE_DIRS})
else()
message(FATAL_ERROR "zlib not found. Required for to output files")
endif(ZLIB_FOUND)

target_link_libraries(Bifrost bifrost_dynamic)
add_executable(Bifrost Bifrost.cpp)
set_property(SOURCE BlockedBloomFilter.cpp APPEND_STRING PROPERTY COMPILE_FLAGS " -funroll-loops")

target_include_directories(Bifrost PRIVATE ${CMAKE_CURRENT_SOURCE_DIR})

target_compile_features(Bifrost PUBLIC cxx_std_11 c_std_11)
target_compile_options(Bifrost PUBLIC "${BIFROST_COMPILER_FLAGS}")
target_link_options(Bifrost PUBLIC "${BIFROST_LINKER_FLAGS}")
target_compile_definitions(Bifrost PRIVATE "${BIFROST_COMPILER_DEFINITIONS}")
target_link_libraries(Bifrost PUBLIC bifrost_dynamic)

install(TARGETS Bifrost DESTINATION bin)
install(TARGETS bifrost_dynamic DESTINATION lib)
Expand Down