Skip to content

Commit

Permalink
Fix cmake clang htslib incompatibility, pt 5
Browse files Browse the repository at this point in the history
  • Loading branch information
lczech committed Feb 20, 2024
1 parent be80e5c commit f86d0d8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 26 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,8 @@ jobs:

- name: Setup C++
# Reference: https://github.com/marketplace/actions/setup-cpp-c-c
uses: aminya/[email protected]
# uses: aminya/[email protected]
uses: aminya/[email protected]
if: matrix.compiler != 'apple'
with:
compiler: ${{ matrix.compiler }}
Expand Down
30 changes: 5 additions & 25 deletions tools/cmake/IncludeHtslib.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -194,25 +194,6 @@ if( NOT ( CMAKE_VERSION VERSION_LESS 3.24 ))
cmake_policy(SET CMP0135 NEW)
endif()

# We construct the command for configuring htslib here, so that in the ExternalProject_Add call
# below, we do not have commands with more than one argument. That seems to cause trouble in
# some weird interaction of cmake, autotools, and clang, and fails in our GitHub Actions builds...
#
# We need to manually add -fPIC here, as somehow otherwise the local installation
# won't link properly. Linking will always remain a mystery to me...
# Need some special care to fix https://github.com/lczech/grenedalf/issues/12,
# see https://stackoverflow.com/a/59536947 for the solution.
SET(
HTSLIB_CONFIGURE_COMMAND
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib --libdir=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib/lib --disable-multi-os-directory --disable-libcurl ${HTSLIB_Deflate_configure}
)

file(WRITE ${CMAKE_CURRENT_BINARY_DIR}/configure-htslib.sh
"#!/bin/bash" \n
"cd $(dirname $0)/genesis-htslib-source" \n
"./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib --libdir=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib/lib --disable-multi-os-directory --disable-libcurl ${HTSLIB_Deflate_configure}"
)

# We download and built on our own, using the correct commit hash to get our exact desired
# version, and install locally to the build directory.
ExternalProject_Add(
Expand Down Expand Up @@ -242,13 +223,12 @@ ExternalProject_Add(
# autoheader
# COMMAND
# autoconf
# COMMAND
# For whatever reason, CMake can't make the script executable, so we do that manually...
# We tried file(COPY) and simiar, nothing worked :-(
COMMAND
chmod +x ${CMAKE_CURRENT_BINARY_DIR}/configure-htslib.sh
COMMAND
${CMAKE_CURRENT_BINARY_DIR}/configure-htslib.sh
# We need to manually add -fPIC here, as somehow otherwise the local installation
# won't link properly. Linking will always remain a mystery to me...
# Need some special care to fix https://github.com/lczech/grenedalf/issues/12,
# see https://stackoverflow.com/a/59536947 for the solution.
./configure CFLAGS=-fPIC CXXFLAGS=-fPIC --prefix=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib --libdir=${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib/lib --disable-multi-os-directory --disable-libcurl ${HTSLIB_Deflate_configure}

# Build Step
# BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}/genesis-htslib
Expand Down

0 comments on commit f86d0d8

Please sign in to comment.