Skip to content

Commit

Permalink
Simplify SuiteSparse installation (#2501)
Browse files Browse the repository at this point in the history
Use the provided overall cmake configuration from SuiteSparse instead of using `make` wrappers for subprojects.

Properly install the SuiteSparse libraries which makes finding their cmake configuration easier for downstream packages.
  • Loading branch information
dweindl authored Sep 26, 2024
1 parent 3dca16e commit 57d0c29
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 28 deletions.
19 changes: 2 additions & 17 deletions cmake/AmiciConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,8 @@ find_package(OpenMP)
# Current SUNDIALSConfig.cmake doesn't use KLU's FindKLU, but hardcodes paths,
# and is not relocatable. This does not work with Python package installation in
# tmpdirs.
list(APPEND CMAKE_MODULE_PATH
@CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/lib/cmake/SuiteSparse/)
if(NOT DEFINED SUITESPARSE_CONFIG_ROOT)
set(SUITESPARSE_CONFIG_ROOT @CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/)
endif()
if(NOT DEFINED AMD_ROOT)
set(AMD_ROOT @CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/)
endif()
if(NOT DEFINED BTF_ROOT)
set(BTF_ROOT @CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/)
endif()
if(NOT DEFINED COLAMD_ROOT)
set(COLAMD_ROOT @CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/)
endif()
if(NOT DEFINED KLU_ROOT)
set(KLU_ROOT @CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/)
endif()
list(APPEND CMAKE_PREFIX_PATH
@CMAKE_SOURCE_DIR@/ThirdParty/SuiteSparse/install/)
find_dependency(SuiteSparse_config REQUIRED)
find_dependency(AMD REQUIRED)
find_dependency(BTF REQUIRED)
Expand Down
25 changes: 16 additions & 9 deletions scripts/buildSuiteSparse.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,21 @@ script_path=$(dirname "$BASH_SOURCE")
amici_path=$(cd "$script_path/.." && pwd)

suitesparse_root="${amici_path}/ThirdParty/SuiteSparse"
for subdir in SuiteSparse_config BTF AMD COLAMD KLU; do
export CMAKE_OPTIONS="-DSUITESPARSE_USE_CUDA=OFF -DSUITESPARSE_USE_FORTRAN=OFF"

if [ $subdir = "SuiteSparse_config" ]; then
export CMAKE_OPTIONS="$CMAKE_OPTIONS -DCMAKE_POSITION_INDEPENDENT_CODE=ON -DBLA_VENDOR=All -DSUITESPARSE_USE_64BIT_BLAS=ON -DBLAS_LIBRARIES=dummy"
elif [ $subdir = "KLU" ]; then
export CMAKE_OPTIONS="$CMAKE_OPTIONS -DKLU_USE_CHOLMOD=OFF"
fi
cd "${suitesparse_root}/build"
cmake -DSUITESPARSE_ENABLE_PROJECTS="amd;btf;colamd;klu" \
-DCMAKE_INSTALL_PREFIX="${suitesparse_root}/install" \
-DCHOLMOD_CAMD=OFF \
-DKLU_USE_CHOLMOD=OFF \
-DSUITESPARSE_CONFIG_USE_OPENMP=OFF \
-DSUITESPARSE_USE_CUDA=OFF \
-DSUITESPARSE_USE_FORTRAN=OFF \
-DSUITESPARSE_USE_PYTHON=OFF \
-DSUITESPARSE_USE_OPENMP=OFF \
-DCMAKE_POSITION_INDEPENDENT_CODE=ON \
-DSUITESPARSE_USE_64BIT_BLAS=ON \
-DBLAS_LIBRARIES=dummy \
..

cd "${suitesparse_root}/${subdir}" && make local install
done
cmake --build .
cmake --install .
4 changes: 2 additions & 2 deletions scripts/buildSundials.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ ${cmake} -DCMAKE_INSTALL_PREFIX="${sundials_build_path}" \
-DEXAMPLES_ENABLE_C=OFF \
-DEXAMPLES_INSTALL=OFF \
-DENABLE_KLU=ON \
-DKLU_LIBRARY_DIR="${suitesparse_root}/lib" \
-DKLU_INCLUDE_DIR="${suitesparse_root}/include/suitesparse" \
-DKLU_LIBRARY_DIR="${suitesparse_root}/install/lib" \
-DKLU_INCLUDE_DIR="${suitesparse_root}/install/include/suitesparse" \
${SuperLUMT} \
..

Expand Down

0 comments on commit 57d0c29

Please sign in to comment.