Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
sudo apt-get install --assume-yes --no-install-recommends clang-${{ matrix.compiler.version }}
echo "CC=/usr/bin/clang-${{ matrix.compiler.version }}" >> $GITHUB_ENV
echo "CXX=/usr/bin/clang++-${{ matrix.compiler.version }}" >> $GITHUB_ENV
- uses: actions/checkout@v4
- uses: actions/checkout@v6
with:
submodules: recursive
- name: Build
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,11 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v6

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v3
uses: github/codeql-action/init@v4
with:
languages: ${{ matrix.language }}

Expand All @@ -48,6 +48,6 @@ jobs:

# Perform Analysis
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
uses: github/codeql-action/analyze@v4
with:
category: "/language:${{matrix.language}}"
177 changes: 80 additions & 97 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,124 +2,107 @@ cmake_minimum_required(VERSION 3.5...4.0)
project(SSHASH)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
set(CMAKE_BUILD_TYPE "Release")
endif ()

set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})

# Options
option(SSHASH_BUILD_EXECUTABLES "Build sshash executables" ON)
option(SSHASH_USE_ARCH_NATIVE "Build with -march=native" OFF)
option(SSHASH_USE_MAX_KMER_LENGTH_63 "Use max kmer length 63" OFF)
option(SSHASH_USE_TRADITIONAL_NUCLEOTIDE_ENCODING "Use traditional nucleotide encoding" OFF)
option(SSHASH_USE_SANITIZERS "Build with sanitizers" OFF)

if (UNIX AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64"))
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2 -mavx2")
if (SSHASH_USE_ARCH_NATIVE AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif()
endif()
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -mbmi2 -mavx2")
if (SSHASH_USE_ARCH_NATIVE AND NOT CMAKE_CROSSCOMPILING)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native")
endif ()
endif ()

if (SSHASH_USE_MAX_KMER_LENGTH_63)
MESSAGE(STATUS "SSHash uses a maximum kmer length of 63")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSSHASH_USE_MAX_KMER_LENGTH_63")
else()
MESSAGE(STATUS "SSHash uses a maximum kmer length of 31")
endif()
message(STATUS "SSHash uses a maximum kmer length of 63")
add_compile_definitions(SSHASH_USE_MAX_KMER_LENGTH_63)
else ()
message(STATUS "SSHash uses a maximum kmer length of 31")
endif ()

if (SSHASH_USE_TRADITIONAL_NUCLEOTIDE_ENCODING)
MESSAGE(STATUS "SSHash maps {'A','a'}->0, {'C','c'}->1, {'G','g'}->2, and {'T','t'}->3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -DSSHASH_USE_TRADITIONAL_NUCLEOTIDE_ENCODING")
else()
MESSAGE(STATUS "SSHash maps {'A','a'}->0, {'C','c'}->1, {'T','t'}->2, and {'G','g'}->3")
endif()
message(STATUS "SSHash maps {'A','a'}->0, {'C','c'}->1, {'G','g'}->2, and {'T','t'}->3")
add_compile_definitions(SSHASH_USE_TRADITIONAL_NUCLEOTIDE_ENCODING)
else ()
message(STATUS "SSHash maps {'A','a'}->0, {'C','c'}->1, {'T','t'}->2, and {'G','g'}->3")
endif ()

if (UNIX)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -ggdb -Wall -Wextra -Werror -Wno-missing-braces -Wno-unknown-attributes -Wno-unused-function -pthread")

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ggdb")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -Wno-missing-braces -Wno-unknown-attributes -Wno-unused-function")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -pthread")
if (SSHASH_USE_SANITIZERS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif ()
endif ()

if (SSHASH_USE_SANITIZERS)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fsanitize=address -fno-omit-frame-pointer")
endif()
if (CONDA_BUILD)
set(CONDA_BUILD TRUE)
else ()
set(CONDA_BUILD FALSE)
endif ()

endif()
message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
message(STATUS "Conda build: ${CONDA_BUILD}")
message(STATUS "Installation prefix: ${CMAKE_INSTALL_PREFIX}")
message(STATUS "Compiling for processor: ${CMAKE_SYSTEM_PROCESSOR}")
message(STATUS "Compiling with flags:${CMAKE_CXX_FLAGS}")
message(STATUS "Build executables: ${SSHASH_BUILD_EXECUTABLES}")

if (CONDA_BUILD)
set(CONDA_BUILD TRUE)
else()
set(CONDA_BUILD FALSE)
endif()
# Find dependencies
find_package(ZLIB REQUIRED)

option(SSHASH_BUILD_EXECUTABLES "Build sshash executables" ON)
MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
MESSAGE(STATUS "Conda build: ${CONDA_BUILD}")
MESSAGE(STATUS "Installation prefix: ${CMAKE_INSTALL_PREFIX}")
MESSAGE(STATUS "Compiling for processor: ${CMAKE_SYSTEM_PROCESSOR}")
MESSAGE(STATUS "Compiling with flags:${CMAKE_CXX_FLAGS}")
MESSAGE(STATUS "Build executables: ${SSHASH_BUILD_EXECUTABLES}")

set(Z_LIB_SOURCES
external/gz/zip_stream.cpp
# SSHash static library target
add_library(sshash_static STATIC
external/gz/zip_stream.cpp
external/cityhash/cityhash.cpp
src/builder/build.cpp
src/dictionary.cpp
src/query.cpp
src/info.cpp
)

set(CITYHASH_SOURCES
external/cityhash/cityhash.cpp
# PUBLIC: Only expose SSHash's own API headers to consuming projects
target_include_directories(sshash_static PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/external/bits/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/external/fastmod>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/external/bits/external/essentials/include>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/external/xxHash>
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/external/pthash/external/mm_file/include>
)

set(SSHASH_SOURCES
src/builder/build.cpp
src/dictionary.cpp
src/query.cpp
src/info.cpp
)
# Link dependencies
target_link_libraries(sshash_static PUBLIC ZLIB::ZLIB)

set(SSHASH_INCLUDE_DIRS
external/pthash/include
external/pthash/external/bits/include
external/pthash/external/fastmod
external/pthash/external/bits/external/essentials/include
external/pthash/external/xxHash
external/pthash/external/mm_file/include
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/include
)
# Create standard target alias
add_library(sshash::sshash ALIAS sshash_static)

# Create a static lib
add_library(sshash_static STATIC
${Z_LIB_SOURCES}
${CITYHASH_SOURCES}
${SSHASH_SOURCES}
)
if (SSHASH_BUILD_EXECUTABLES)
add_executable(sshash tools/sshash.cpp)
target_link_libraries(sshash PRIVATE sshash_static)

target_include_directories(sshash_static PUBLIC ${SSHASH_INCLUDE_DIRS})

if(SSHASH_BUILD_EXECUTABLES)
add_executable(sshash tools/sshash.cpp)
target_include_directories(sshash PUBLIC ${SSHASH_INCLUDE_DIRS})
target_link_libraries(sshash
sshash_static
z
)

# tests:

add_executable(test_alphabet test/test_alphabet.cpp)
target_link_libraries(test_alphabet
sshash_static
)

add_executable(test_minimizer test/test_minimizer.cpp)
target_link_libraries(test_minimizer
sshash_static
)

add_executable(check test/check.cpp)
target_link_libraries(check
sshash_static
z
)

if (CONDA_BUILD)
install(TARGETS sshash
RUNTIME DESTINATION bin
)
endif()
endif()
add_executable(test_alphabet test/test_alphabet.cpp)
target_link_libraries(test_alphabet PRIVATE sshash_static)

add_executable(test_minimizer test/test_minimizer.cpp)
target_link_libraries(test_minimizer PRIVATE sshash_static)

add_executable(check test/check.cpp)
target_link_libraries(check PRIVATE sshash_static)

if (CONDA_BUILD)
install(TARGETS sshash RUNTIME DESTINATION bin)
endif ()
endif ()
Loading