diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..0a07326 --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,114 @@ +cmake_minimum_required(VERSION 3.24.0) + +project(cantera-dependency-superbuild) + +include(ExternalProject) + +set(DOWNLOAD_DIR "/cache") + +set(BOOST_VERSION 1.85.0) +ExternalProject_Add( + boost + URL https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=release + -DBOOST_INCLUDE_LIBRARIES:STRING="algorithm;dll;stacktrace;core;math;numeric/ublas;serialization;multi_array" + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(LIBAEC_VERSION 1.0.6) +set(LIBAEC_PATCHFILE) +ExternalProject_Add( + libaec + URL https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-${LIBAEC_VERSION}.tar.gz + PATCH_COMMAND patch -p0 < ${LIBAEC_PATCHFILE} + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_INSTALL_LIBDIR:STRING=lib + -DBUILD_TESTING:BOOL=OFF + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(LIBHDF5_VERSION 1.14.2) +set(LIBHDF5_SHORT_VERSION 1.14) +ExternalProject_Add( + libhdf5 + URL https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-${LIBHDF5_SHORT_VERSION}/hdf5-${LIBHDF5_VERSION}/src/hdf5-${LIBHDF5_VERSION}.tar.gz + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_INSTALL_PREFIX:STRING=/usr/local + -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=ON + -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=ON + -DHDF5_BUILD_EXAMPLES:BOOL=OFF + -DBUILD_TESTING:BOOL=OFF + DEPENDS libaec + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(EIGEN_VERSION 3.4.0) +ExternalProject_Add( + eigen + URL https://gitlab.com/libeigen/eigen/-/archive/${EIGEN_VERSION}/eigen-${EIGEN_VERSION}.tar.bz2 + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DEIGEN_BUILD_DOC:BOOL=OFF + -DBUILD_TESTING:BOOL=OFF + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(YAML_CPP_VERSION 0.8.0) +ExternalProject_Add( + yamlcpp + URL https://github.com/jbeder/yaml-cpp/archive/refs/tags/${YAML_CPP_VERSION}.tar.gz + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_INSTALL_LIBDIR:STRING=lib + -DYAML_CPP_DISABLE_UNINSTALL:BOOL=OFF + -DYAML_CPP_FORMAT_SOURCE:BOOL=OFF + -DBUILD_TESTING:BOOL=OFF + -DBUILD_SHARED_LIBS:BOOL=OFF + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(SUNDIALS_VERSION 7.0.0) +ExternalProject_Add( + sundials + URL https://github.com/LLNL/sundials/releases/download/v${SUNDIALS_VERSION}/sundials-${SUNDIALS_VERSION}.tar.gz + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=release + -DCMAKE_INSTALL_LIBDIR:STRING=lib + -DBUILD_SHARED_LIBS:BOOL=OFF + -DEXAMPLES_INSTALL:BOOL=OFF + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(FMT_VERSION 10.2.1) +ExternalProject_Add( + fmt + URL https://github.com/fmtlib/fmt/releases/download/${FMT_VERSION}/fmt-${FMT_VERSION}.zip + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_INSTALL_LIBDIR:STRING=lib + -DFMT_DOC:BOOL=OFF + -DFMT_TEST:BOOL=OFF + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) + +set(HIGHFIVE_VERSION 2.9.0) +ExternalProject_Add( + highfive + URL https://github.com/BlueBrain/HighFive/archive/refs/tags/v${HIGHFIVE_VERSION}.tar.gz + CMAKE_GENERATOR Ninja + CMAKE_CACHE_ARGS + -DCMAKE_BUILD_TYPE:STRING=release + -DHIGHFIVE_UNIT_TESTS:BOOL=OFF + -DHIGHFIVE_USE_BOOST:BOOL=ON + -DHIGHFIVE_USE_EIGEN:BOOL=ON + -DHIGHFIVE_EXAMPLES:BOOL=OFF + -DHIGHFIVE_BUILD_DOCS:BOOL=OFF + -DBoost_NO_BOOST_CMAKE:BOOL=OFF + DEPENDS boost eigen libhdf5 + DOWNLOAD_DIR ${DOWNLOAD_DIR} +) diff --git a/Dockerfile b/Dockerfile index 252ba07..62ffc19 100644 --- a/Dockerfile +++ b/Dockerfile @@ -4,27 +4,21 @@ ARG TARGET_ARCH FROM quay.io/pypa/manylinux_2_28_${TARGET_ARCH}:2024-07-15-c746fd8 -ARG BOOST_VERSION=1.85.0 -ARG HDF5_VERSION=1.14.2 ARG NINJA_VERSION=1.12.1 # Has to be repeated here so it's imported from the "top level" above the FROM ARG TARGET_ARCH -ENV HDF5_VERSION=${HDF5_VERSION} \ - HDF5_DIR=/usr/local \ - BOOST_DIR=/usr/local \ - BOOST_VERSION=${BOOST_VERSION} +COPY CMakeLists.txt libaec_cmakelists.patch /tmp/ RUN --mount=type=cache,target=/cache \ if [[ "$TARGET_ARCH" == "aarch64" ]]; then NINJA_ARCH="-aarch64"; else NINJA_ARCH=""; fi \ && echo "Getting Ninja for '${NINJA_ARCH}'" \ && curl -fsSL -o /cache/ninja-linux.zip https://github.com/ninja-build/ninja/releases/download/v${NINJA_VERSION}/ninja-linux${NINJA_ARCH}.zip \ && unzip /cache/ninja-linux.zip -d /usr/local/bin \ - && ninja --version -COPY install_libaec.sh libaec_cmakelists.patch install_hdf5.sh install_boost.sh /tmp/ -RUN --mount=type=cache,target=/cache \ - bash /tmp/install_libaec.sh -RUN --mount=type=cache,target=/cache \ - bash /tmp/install_hdf5.sh -RUN --mount=type=cache,target=/cache \ - bash /tmp/install_boost.sh + && ninja --version \ + && mkdir build \ + && pushd build \ + && cmake -G Ninja -DLIBAEC_PATCHFILE=/tmp/libaec_cmakelists.patch ../tmp \ + && ninja \ + && popd \ + && rm -rf build diff --git a/install_boost.sh b/install_boost.sh deleted file mode 100644 index 003d60a..0000000 --- a/install_boost.sh +++ /dev/null @@ -1,19 +0,0 @@ -set -euo pipefail - -pushd /tmp - -BOOST_DOWNLOAD_FILE="/cache/boost-cmake.tar.xz" -curl -fsSL -o $BOOST_DOWNLOAD_FILE https://github.com/boostorg/boost/releases/download/boost-${BOOST_VERSION}/boost-${BOOST_VERSION}-cmake.tar.xz -tar -xf $BOOST_DOWNLOAD_FILE -C /tmp -mkdir -p boost-${BOOST_VERSION}/build -pushd boost-${BOOST_VERSION}/build - -cmake -G "Ninja" \ - -DCMAKE_BUILD_TYPE=release \ - -DBOOST_INCLUDE_LIBRARIES="algorithm;dll;stacktrace;core;math;numeric/ublas;serialization;multi_array" \ - .. -ninja install - -popd - -rm -rf boost-${BOOST_VERSION} diff --git a/install_hdf5.sh b/install_hdf5.sh deleted file mode 100644 index beb7ab0..0000000 --- a/install_hdf5.sh +++ /dev/null @@ -1,35 +0,0 @@ -set -euo pipefail - -echo "Installing zlib with yum" -yum -y install zlib-devel - -pushd /tmp - -# This seems to be needed to find libsz.so.2 -ldconfig - -echo "Downloading & unpacking HDF5 ${HDF5_VERSION}" -HDF5_DOWNLOAD_FILE="/cache/hdf5-${HDF5_VERSION}.tar.gz" -# Remove trailing .*, to get e.g. '1.12' ↓ -curl -fsSL -o $HDF5_DOWNLOAD_FILE "https://www.hdfgroup.org/ftp/HDF5/releases/hdf5-${HDF5_VERSION%.*}/hdf5-$HDF5_VERSION/src/hdf5-$HDF5_VERSION.tar.gz" -tar -xzf $HDF5_DOWNLOAD_FILE -C /tmp -mkdir -p hdf5-${HDF5_VERSION}/build -pushd hdf5-$HDF5_VERSION/build - -echo "Configuring, building & installing HDF5 ${HDF5_VERSION} to ${HDF5_DIR}" -cmake -G "Ninja" \ - -DCMAKE_INSTALL_PREFIX=${HDF5_DIR} \ - -DHDF5_BUILD_CPP_LIB=ON \ - -DHDF5_ENABLE_Z_LIB_SUPPORT=ON \ - -DHDF5_ENABLE_SZIP_SUPPORT=ON \ - -DHDF5_BUILD_EXAMPLES=OFF \ - -DBUILD_TESTING=OFF \ - .. -ninja install -popd - -# Clean up to limit the size of the Docker image -echo "Cleaning up unnecessary files" -rm -r hdf5-$HDF5_VERSION - -yum -y erase zlib-devel diff --git a/install_libaec.sh b/install_libaec.sh deleted file mode 100644 index dc76127..0000000 --- a/install_libaec.sh +++ /dev/null @@ -1,27 +0,0 @@ -# libaec implements szip compression, so the optional szip filter can be built -# in HDF5. -set -euo pipefail - -pushd /tmp - -aec_version="1.0.6" - -echo "Downloading libaec" -LIBAEC_DOWNLOAD_FILE="/cache/libaec-${aec_version}.tar.gz" -# The URL includes a hash, so it needs to change if the version does -curl -fsSL -o $LIBAEC_DOWNLOAD_FILE https://gitlab.dkrz.de/k202009/libaec/uploads/45b10e42123edd26ab7b3ad92bcf7be2/libaec-${aec_version}.tar.gz -tar -zxf $LIBAEC_DOWNLOAD_FILE -C /tmp - -echo "Building & installing libaec" -mkdir -p libaec-${aec_version}/build -pushd libaec-$aec_version -patch -p0 < /tmp/libaec_cmakelists.patch -pushd build -cmake -G "Ninja" -DCMAKE_INSTALL_PREFIX=/usr/local -DCMAKE_INSTALL_LIBDIR=lib -DBUILD_TESTING=OFF .. -ninja install - -popd - -# Clean up the files from the build -popd -rm -r libaec-$aec_version