Skip to content

Commit

Permalink
Support cmake -DISAL=download to use an external ISA-L
Browse files Browse the repository at this point in the history
Some helpful inspiration for the CMakeLists.txt voodo comes from
https://github.com/charlesnicholson/cmake-external-project-test/blob/master/CMakeLists.txt
  • Loading branch information
marcelm committed Aug 30, 2024
1 parent 1c11f5d commit 462301e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 5 deletions.
17 changes: 14 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ jobs:
- name: Build
run: |
cmake -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cd build
make -j3
make install
cmake --build build -j 3
cmake --install build
- name: Install Linux dependencies
if: runner.os == 'Linux'
run: sudo apt-get install samtools
Expand All @@ -49,6 +48,18 @@ jobs:
- name: Run
run: tests/run.sh

# Test building with a downloaded ISA-L
build_external_isal:
if: >-
github.event_name != 'pull_request' ||
github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Build
run: |
cmake -B build -DISAL=download
cmake --build build -j3
pythonbindings:
if: >-
github.event_name != 'pull_request' ||
Expand Down
30 changes: 28 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ cmake_minimum_required(VERSION 3.16)

project(strobealign VERSION 0.13.0)
include(FetchContent)
include(ExternalProject)

option(ENABLE_AVX "Enable AVX2 support" OFF)
option(PYTHON_BINDINGS "Build Python bindings" OFF)
Expand All @@ -24,6 +25,9 @@ if(NOT CMAKE_BUILD_TYPE)
"RelWithDebInfo" "Debug" "Release")
endif()

set(ISAL "system" CACHE STRING "Where to find ISA-L: system (uses pkg-config), download (at build time)")
set_property(CACHE ISAL PROPERTY STRINGS "system" "download")

message(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
add_compile_options(-Wall -Wextra -Werror=maybe-uninitialized)

Expand Down Expand Up @@ -67,9 +71,31 @@ add_library(salib STATIC ${SOURCES}
ext/ssw/ssw_cpp.cpp
ext/ssw/ssw.c
)
pkg_check_modules(ISAL REQUIRED IMPORTED_TARGET GLOBAL libisal>=2.30.0)
if(ISAL STREQUAL "system")
pkg_check_modules(ISAL IMPORTED_TARGET GLOBAL libisal>=2.30.0 REQUIRED)
add_library(ISAL ALIAS PkgConfig::ISAL)
elseif(ISAL STREQUAL "download")
set(ISAL_ROOT ${CMAKE_BINARY_DIR}/ISAL)
ExternalProject_Add(
isal_external
GIT_REPOSITORY https://github.com/intel/isa-l
GIT_TAG v2.30.0
BUILD_COMMAND make -f Makefile.unx
CONFIGURE_COMMAND ""
INSTALL_DIR ${ISAL_ROOT}
INSTALL_COMMAND make -f Makefile.unx install prefix=<INSTALL_DIR>
BUILD_IN_SOURCE ON
)
target_include_directories(salib PUBLIC "${ISAL_ROOT}/include")
add_library(ISAL STATIC IMPORTED)
set_target_properties(ISAL PROPERTIES IMPORTED_LOCATION ${ISAL_ROOT}/lib/libisal.a)
add_dependencies(salib isal_external)
#elseif(ISAL STREQUAL "off")
# message(FATAL_ERROR "Building without ISA-L support is currently not supported")
endif()

target_include_directories(salib PUBLIC src/ ext/ ${PROJECT_BINARY_DIR})
target_link_libraries(salib PUBLIC ZLIB::ZLIB Threads::Threads zstr::zstr PkgConfig::ISAL)
target_link_libraries(salib PUBLIC ZLIB::ZLIB Threads::Threads zstr::zstr ISAL)
IF(ENABLE_AVX)
target_compile_options(salib PUBLIC "-mavx2")
ENDIF()
Expand Down

0 comments on commit 462301e

Please sign in to comment.