-
The approach here is to first build/install dependencies of ASAP and then define their paths in the
cmake
command for ASAP. The order in which I build the dependencies is in the same order as defined using thefind_package()
function inASAP/CMakeLists.txt
. -
Assumptions
- Note 1: I assume you have your conda environment installed and activated
- Note 2: These instruction assume you have cmake installed. Find a basic tutorial here and a quick intuition here.
- Note 3: These instruction also assume that you
gcc --version
is>=9
since otherwise it leads to issues with compiling#include<filesystem>
in some.cpp
files like core/filetools.cpp.
-
My packages and their versions
-
Library Version conda 4.9.2 python 3.8.13 numpy 1.23.1 cmake 3.20.2 gcc 112.0
-
-
My System
cat /etc/os-release
-
NAME="CentOS Stream" VERSION="8" ID="centos" ID_LIKE="rhel fedora" VERSION_ID="8" PLATFORM_ID="platform:el8"
-
-
Terminals commands to check if libs exist via cmake
- OpenJPEG :
cmake --find-package -DNAME=OpenJPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- TIFF :
cmake --find-package -DNAME=TIFF -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- JPEG :
cmake --find-package -DNAME=JPEG -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- ZLIB :
cmake --find-package -DNAME=ZLIB -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- PugiXML :
cmake --find-package -DNAME=PugiXML -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- OPENSLIDE :
cmake --find-package -DNAME=OPENSLIDE -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- OpenCV :
cmake --find-package -DNAME=OpenCV -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- Qt :
cmake --find-package -DNAME=Qt5Core -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- Qt :
cmake --find-package -DNAME=Qt5Gui -DCOMPILER_ID=GNU -DLANGUAGE=C -DMODE=LINK
- OpenJPEG :
-
Install missing libs (as non-root user)
- Results from my academic cluster (I already had OpenJPEG, TIFF, JPEG and ZLIB)
- Define
export PATH_ASAP_EXTLIBS=""
as the directory where you install the missing libraries - Then do
mkdir -p $PATH_ASAP_EXTLIBS && cd $PATH_ASAP_EXTLIBS
- Define
export PATH_ASAP=""
as the directory where you install ASAP - PugiXML
-
cd $PATH_ASAP_EXTLIBS git clone [email protected]:zeux/pugixml.git && cd pugixml cmake -S . -B build # makes this file: pugixml/build/CMakeFiles cmake --build build -j 4 # compiles .cpp files cd build make DESTDIR=../install install # uses pugixml/build/CMakeFiles to copy the build files into "proper" locations cp $PATH_ASAP_EXTLIBS/pugixml/src/pugixml.cpp $PATH_ASAP_EXTLIBS/pugixml/install/usr/local/include/ # needed during ASAP building
-
- OpenSlide (uses a different build system, not cmake)
-
cd $PATH_ASAP_EXTLIBS git clone [email protected]:openslide/openslide.git && cd openslide autoreconf -i ./configure make DESTDIR=$PATH_ASAP_EXTLIBS/openslide/install install
-
- OpenCV (we dont install here, dunno why!)
-
cd $PATH_ASAP_EXTLIBS wget -O opencv.zip https://github.com/opencv/opencv/archive/4.x.zip unzip opencv.zip && rm opencv.zip && cd opencv-4.x/ # time consuming cmake -S . -B build # time consuming cmake --build build -j 4 # ultra time consuming
-
- DCMTK (Dicom toolkit, apparently only needed for VSI support, specified in
find_package()
of the CMakeLists.txt belonging to multiresolutionimageinterface folder)-
cd $PATH_ASAP_EXTLIBS wget https://github.com/DCMTK/dcmtk/archive/refs/tags/DCMTK-3.6.7.tar.gz tar -xvzf DCMTK-3.6.7.tar.gz && rm DCMTK-3.6.7.tar.gz && cd dcmtk-DCMTK-3.6.7 cmake -S . -B build -DCMAKE_POSITION_INDEPENDENT_CODE=ON # time consuming cmake --build build -j 4 # ultra time consuming cd $PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/build && make DESTDIR=$PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/install install cp -r $PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/dcmjpeg/libijg8 $PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/install/usr/local/include/dcmtk/dcmjpeg/
- Check if all required files have been put in the
$PATH_ASAP_EXTLIBS/dcmtk/install
dirtree --prune -P 'jconfig8.h|jpeglib8.h|djdecode.h|djencode.h'
-
-
Build ASAP
cd $PATH_ASAP wget https://github.com/computationalpathologygroup/ASAP/archive/refs/tags/ASAP-2.1.tar.gz tar -xvzf ASAP-2.1.tar.gz && rm ASAP-2.1.tar.gz && cd ASAP-ASAP-2.1 # Need to define many macros here. cmake -S . -B build -DPugiXML_INCLUDE_DIR="$PATH_ASAP_EXTLIBS/pugixml/install/usr/local/include/" -DOPENSLIDE_INCLUDE_DIR="$PATH_ASAP_EXTLIBS/openslide/install/usr/local/include/openslide" -DOPENSLIDE_LIBRARY="$PATH_ASAP_EXTLIBS/openslide/install/usr/local/lib/libopenslide.so.0.4.1" -DOpenCV_DIR="$PATH_ASAP_EXTLIBS/opencv-4.x/build" -DDCMTK_DIR="$PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/build" -DDCMTKJPEG_INCLUDE_DIR="$PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/install/usr/local/include" -DDCMTKJPEG_LIBRARY="$PATH_ASAP_EXTLIBS/dcmtk-DCMTK-3.6.7/install/usr/local/lib64/libijg8.a" -DBUILD_EXECUTABLES=ON -DBUILD_ASAP=ON -DBUILD_IMAGEPROCESSING=ON -DPACKAGE_ON_INSTALL=ON -DBUILD_MULTIRESOLUTIONIMAGEINTERFACE_VSI_SUPPORT=ON -DBUILD_MULTIRESOLUTIONIMAGEINTERFACE_DICOM_SUPPORT=ON -DWRAP_MULTIRESOLUTIONIMAGEINTERFACE_PYTHON=ON -DPYTHON_LIBRARY=$CONDA_PREFIX/lib/libpython3.8.so cd $PATH_ASAP/ASAP-ASAP-2.1/ && cmake --build build -j 4 cd $PATH_ASAP/ASAP-ASAP-2.1/build && make DESTDIR=$PATH_ASAP/ASAP-ASAP-2.1/install install
-
Import ASAP in python
-
import os import sys from pathlib import Path path_add1 = Path.cwd().joinpath(os.environ['PATH_ASAP'], 'ASAP-ASAP-2.1', 'install', 'usr', 'local', 'bin') # you may have modify this option depending on where 'multiresolutionimageinterface.py' installs sys.path.append(str(path_add1)) assert Path(sys.path[0]).exists() import multiresolutionimageinterface as mir
-
- If you wish to print within a .cmake file
-
function(PRINT_VAR VARNAME) message(STATUS "${VARNAME}: ${${VARNAME}}") endfunction() PRINT_VAR("CMAKE_CXX_COMPILER")
-
- References