From c7cd5d83eec198354cbb14cf548ef48247d8c83c Mon Sep 17 00:00:00 2001 From: Ben Lawrence Date: Tue, 23 Apr 2024 12:10:59 +0000 Subject: [PATCH] Merge branch 'DOR-670-homebrew-dylibs' into 'master' [DOR-670] Change to using a CDN hosted HDF5 Closes DOR-670 See merge request machine-learning/dorado!964 (cherry picked from commit e91695c5c6a3a26442dc384cbcbadf9c673eee84) f1701fd1 [DOR-670] Add post-build check that dorado doesn't link to brew dylibs ad75e886 [DOR-670] Skip checks for sanitizer builds 29399c7f [DOR-670] Add macOS Intel homebrew path to the search too 3daead45 [DOR-670] Add macOS hdf5 libs 12509cfb [DOR-670] Simplify download_and_extract() call c3ece9ae [DOR-670] Remove references to hdf5 and libaec --- CMakeLists.txt | 1 + DEV.md | 2 +- README.md | 2 -- cmake/HDF5.cmake | 25 ++++++++++++++++--------- cmake/Warnings.cmake | 19 +++++++++++++++++++ 5 files changed, 37 insertions(+), 12 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8a88adef..59faa587 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -341,6 +341,7 @@ if(NOT DORADO_DISABLE_DORADO) endif() enable_warnings_as_errors(dorado) + check_linked_libs(dorado) if (DORADO_ENABLE_PCH) target_precompile_headers(dorado REUSE_FROM dorado_lib) diff --git a/DEV.md b/DEV.md index ffd8a8a7..35badf8e 100644 --- a/DEV.md +++ b/DEV.md @@ -35,5 +35,5 @@ $ brew link autoconf@2.69 The following other packages need to be available as well ```bash -brew install openssl zstd hdf5 +brew install openssl zstd ``` diff --git a/README.md b/README.md index 57d53490..6dee444e 100644 --- a/README.md +++ b/README.md @@ -452,8 +452,6 @@ On macOS, the equivalent export would be (change path as appropriate): $ export DYLD_LIBRARY_PATH=/dorado-x.y.z-osx-arm64/lib:$DYLD_LIBRARY_PATH ``` -This will let the Dorado binary pick up the shipped libraries and you will not need to manually install `libaec` and `zstd`. - ### Improving the Speed of Duplex Basecalling Duplex basecalling is an IO-intensive process and can perform poorly if using networked storage or HDD. This can generally be improved by splitting up POD5 files appropriately. diff --git a/cmake/HDF5.cmake b/cmake/HDF5.cmake index a9d6b733..d1b9432b 100644 --- a/cmake/HDF5.cmake +++ b/cmake/HDF5.cmake @@ -1,21 +1,16 @@ -set(HDF_VER hdf5-1.12.1-3) -set(ZLIB_VER 1.2.12) - option(DYNAMIC_HDF "Link HDF as dynamic libs" OFF) if((CMAKE_SYSTEM_NAME STREQUAL "Linux") AND (CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64")) # download the pacakge for arm, we want to package this due to hdf5's dependencies - set(DYNAMIC_HDF ON) set(HDF_VER hdf5-1.10.0-aarch64) - if(EXISTS ${DORADO_3RD_PARTY_DOWNLOAD}/${HDF_VER}) - message(STATUS "Found ${HDF_VER}") - else() - download_and_extract(https://cdn.oxfordnanoportal.com/software/analysis/${HDF_VER}.zip ${HDF_VER}) - endif() + download_and_extract(https://cdn.oxfordnanoportal.com/software/analysis/${HDF_VER}.zip ${HDF_VER}) list(PREPEND CMAKE_PREFIX_PATH ${DORADO_3RD_PARTY_DOWNLOAD}/${HDF_VER}/${HDF_VER}) elseif(WIN32) + set(HDF_VER hdf5-1.12.1-3) + set(ZLIB_VER 1.2.12) + # On windows, we need to build HDF5 set(HDF5_ZLIB_INSTALL_DIR ${CMAKE_BINARY_DIR}/zlib-${ZLIB_VER}/install) if(EXISTS ${DORADO_3RD_PARTY_DOWNLOAD}/${HDF_VER} AND EXISTS ${HDF5_ZLIB_INSTALL_DIR}) @@ -42,9 +37,21 @@ elseif(WIN32) list(APPEND CMAKE_PREFIX_PATH ${DORADO_3RD_PARTY_DOWNLOAD}/${HDF_VER}/${HDF_VER}) install(FILES ${HDF5_ZLIB_INSTALL_DIR}/bin/zlib.dll DESTINATION bin) + elseif (IOS) # iOS doesn't make use of HDF5. return() + +elseif (APPLE) + set(HDF_VER 1.14.3) + if (CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") + set(HDF_ARCH "x86_64") + else() + set(HDF_ARCH "armv8") + endif() + download_and_extract(https://cdn.oxfordnanoportal.com/software/analysis/hdf5-${HDF_VER}-${HDF_ARCH}.zip hdf5-${HDF_VER}-${HDF_ARCH}) + list(PREPEND CMAKE_PREFIX_PATH ${DORADO_3RD_PARTY_DOWNLOAD}/hdf5-${HDF_VER}-${HDF_ARCH}/${HDF_VER}_${HDF_ARCH}) + endif() if(DYNAMIC_HDF) diff --git a/cmake/Warnings.cmake b/cmake/Warnings.cmake index b7ce071a..c3a8bbd6 100644 --- a/cmake/Warnings.cmake +++ b/cmake/Warnings.cmake @@ -30,3 +30,22 @@ function(disable_warnings TARGET_NAME) ) endif() endfunction() + +function(check_linked_libs TARGET_NAME) + if (ECM_ENABLE_SANITIZERS) + # We don't ship these, so no need to check them. + return() + endif() + + if (APPLE) + add_custom_command( + TARGET ${TARGET_NAME} + POST_BUILD + COMMAND echo "Checking linked libs..." + # We shouldn't be linking to anything from homebrew. + COMMAND sh -c "otool -L $ | grep -i /opt/homebrew ; test $? -eq 1" + COMMAND sh -c "otool -L $ | grep -i /usr/local/opt ; test $? -eq 1" + VERBATIM + ) + endif() +endfunction()