Skip to content

Commit

Permalink
support packaging
Browse files Browse the repository at this point in the history
  • Loading branch information
sergiud committed Mar 4, 2022
1 parent e9ff99c commit e92f1bd
Show file tree
Hide file tree
Showing 2 changed files with 113 additions and 39 deletions.
69 changes: 52 additions & 17 deletions .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,23 @@ jobs:
include:
- sys: mingw64
env: x86_64
system: Win64
- msvc: VS-16-2019
generator: "Visual Studio 16 2019"
os: windows-2019
marker: vc16
- msvc: VS-17-2022
generator: "Visual Studio 17 2022"
os: windows-2022
marker: vc17

steps:
- uses: actions/checkout@v2

- name: Query Tags
run: |
git fetch --unshallow --tags
- uses: ashutoshvarma/setup-ninja@master
with:
version: 1.10.0
Expand All @@ -121,31 +129,18 @@ jobs:
path-type: inherit
install: >-
wget
mingw-w64-${{matrix.env}}-ccache
mingw-w64-${{matrix.env}}-gcc-fortran
- name: Cache LAPACK
id: cache-lapack
uses: actions/cache@v2
with:
path: lapack-3.10.0
key: ${{runner.os}}-lapack-3.10.0

- name: Download LAPACK
if: steps.cache-lapack.outputs.cache-hit != 'true'
shell: msys2 {0}
run: |
wget https://github.com/Reference-LAPACK/lapack/archive/refs/tags/v3.10.0.tar.gz
tar xvf v3.10.0.tar.gz
- name: Cache BLAS and LAPACK Build
id: cache-lapack-build
uses: actions/cache@v2
with:
path: ${{env.CCACHE_DIR}}
key: ${{runner.os}}-ccache-${{github.run_id}}
restore-keys: ${{runner.os}}-ccache-

- name: Build BLAS and LAPACK
- name: Build LAPACK
if: steps.cache-lapack.outputs.cache-hit != 'true'
shell: msys2 {0}
run: |
cmake -S lapack-3.10.0 -B build_lapack_${{matrix.build_type}}/ \
Expand All @@ -160,12 +155,32 @@ jobs:
--config ${{matrix.build_type}} \
--target install
- name: Cache LAPACK
id: cache-lapack
uses: actions/cache@v2
with:
path: |
${{env.CCACHE_DIR}}
${{github.workspace}}/install
key: ${{runner.os}}-lapack-3.10

- name: Setup MSYS2 Environment
shell: msys2 {0}
run: |
echo "$(cygpath -m /${{matrix.sys}}/bin)" >> $GITHUB_PATH
- name: Setup Environment
run: |
echo "${{github.workspace}}/install/bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
echo "VERSION_SUFFIX=$(git describe --tags)-${{matrix.marker}}-${{matrix.system}}-${{matrix.build_type}}-${{matrix.lib}}-${{matrix.components}}" | Out-File -FilePath $env:GITHUB_ENV -Encoding utf8 -Append
- name: Configure
run: |
cmake -S . -B build_${{matrix.build_type}}/ `
-A x64 `
-DBLAS_blas_LIBRARY=${{github.workspace}}/install/lib/libblas.lib `
-DBUILD_SHARED_LIBS=${{matrix.lib == 'shared'}} `
-DCMAKE_INSTALL_PREFIX:PATH=./install `
-DCMAKE_INSTALL_PREFIX:PATH=${{github.workspace}}/install-suitesparse `
-DLAPACK_lapack_LIBRARY=${{github.workspace}}/install/lib/liblapack.lib `
-DWITH_FORTRAN=OFF `
-DWITH_GPL=${{matrix.components == 'gpl'}} `
Expand All @@ -182,3 +197,23 @@ jobs:
cmake --build build_${{matrix.build_type}}/ `
--config ${{matrix.build_type}} `
--target install
- name: Prepare Deployment
run: |
New-Item -ItemType "directory" -Path "${{github.workspace}}/deploy"
Copy-Item -Path "${{github.workspace}}/install/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force
Copy-Item -Path "${{github.workspace}}/install-suitesparse/*" -Destination "${{github.workspace}}/deploy/" -Recurse -Force
Compress-Archive -Path "${{github.workspace}}/deploy/*" -Destination "SuiteSparse-${{env.VERSION_SUFFIX}}.zip"
- uses: actions/upload-artifact@v2
with:
name: SuiteSparse-${{env.VERSION_SUFFIX}}
path: |
deploy/
- name: Deploy
uses: softprops/action-gh-release@v1
if: startsWith(github.ref, 'refs/tags/') && matrix.lib == 'shared'
with:
files:
SuiteSparse-${{env.VERSION_SUFFIX}}.zip
83 changes: 61 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#
# CMake support layer for SuiteSparse
#
# Copyright 2016-2021 Sergiu Deitsch <sergiu.deitsch@gmail.com>
# Copyright 2016-2022 Sergiu Deitsch <sergiu.deitsch@gmail.com>
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -41,20 +41,7 @@ set (MAJOR_VERSION ${PROJECT_VERSION_MAJOR})
set (MINOR_VERSION ${PROJECT_VERSION_MINOR})
set (VERSION_PATCH ${PROJECT_VERSION_PATCH})

set (SHORT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}")

if (NOT VERSION_PATCH EQUAL 0)
set (SHORT_VERSION "${SHORT_VERSION}.${VERSION_PATCH}")
endif (NOT VERSION_PATCH EQUAL 0)

set (VERSION ${PROJECT_VERSION})

set (CPACK_PACKAGE_NAME SuiteSparse)
set (CPACK_PACKAGE_DESCRIPTION_SUMMARY "SuiteSparse: an extended version of CSparse")
set (CPACK_PACKAGE_VERSION_MAJOR ${MAJOR_VERSION})
set (CPACK_PACKAGE_VERSION_MINOR ${MINOR_VERSION})
set (CPACK_PACKAGE_VERSION_PATCH ${VERSION_PATCH})
set (CPACK_PACKAGE_VERSION ${SHORT_VERSION})

include (CheckCCompilerFlag)
include (CheckFunctionExists)
Expand All @@ -71,6 +58,7 @@ include (CPack)
include (FeatureSummary)
include (GenerateExportHeader)
include (GNUInstallDirs)
include (InstallRequiredSystemLibraries)
include (SuiteSparseBase)

option (BUILD_CXSPARSE "Build CXSparse" ON)
Expand Down Expand Up @@ -1460,12 +1448,6 @@ set (SuiteSparse_CMake_INSTALLDIR ${SuiteSparse_CMake_LIBDIR}/cmake)

target_sources (suitesparseconfig PRIVATE ${_output_CMake_MODULES})

install (TARGETS ${_SuiteSparse_TARGETS}
EXPORT suitesparse-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
LIBRARY DESTINATION ${SuiteSparse_CMake_LIBDIR} COMPONENT Development
ARCHIVE DESTINATION ${SuiteSparse_CMake_LIBDIR} COMPONENT Development)

set (SuiteSparse_NAMESPACE SuiteSparse::)

configure_package_config_file (suitesparse-config.cmake.in
Expand Down Expand Up @@ -1493,7 +1475,7 @@ set_component_version (ccolamd 2.9.6)
set_component_version (colamd 2.9.6)
set_component_version (klu 1.3.9)
set_component_version (ldl 2.2.6)
set_component_version (suitesparseconfig "${VERSION}")
set_component_version (suitesparseconfig ${SuiteSparse_VERSION})
set_component_version (umfpack 5.7.9)

if (TARGET cholmod)
Expand Down Expand Up @@ -1608,12 +1590,18 @@ if (WITH_DEMOS)
add_executable (kludemo
KLU/Demo/kludemo.c
)
target_link_libraries (kludemo PRIVATE SuiteSparse::KLU SuiteSparse::CHOLMOD)
target_link_libraries (kludemo PRIVATE SuiteSparse::KLU SuiteSparse::CHOLMOD)

add_executable (kluldemo
KLU/Demo/kluldemo.c
)
target_link_libraries (kluldemo PRIVATE SuiteSparse::KLU SuiteSparse::CHOLMOD)

install (TARGETS
kludemo
kluldemo
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
)
endif (TARGET cholmod)

add_executable (ldlamd
Expand Down Expand Up @@ -1668,9 +1656,32 @@ if (WITH_DEMOS)
add_executable (umfpack_simple UMFPACK/Demo/umfpack_simple.c)
target_link_libraries (umfpack_simple PRIVATE SuiteSparse::UMFPACK)

set (SuiteSparse_BIN_TARGETS
amd_demo
amd_demo2
amd_l_demo
camd_demo
camd_demo2
camd_l_demo
camd_simple
colamd_example
colamd_l_example
ldlamd
ldlmain
ldlsimple
umf4
umfpack_di_demo
umfpack_dl_demo
umfpack_simple
umfpack_zi_demo
umfpack_zl_demo
)

if (WITH_FORTRAN AND CMAKE_Fortran_COMPILER_LOADED)
add_executable (umf4hb UMFPACK/Demo/umf4_f77wrapper.c UMFPACK/Demo/umf4hb.f)
target_link_libraries (umf4hb PRIVATE SuiteSparse::UMFPACK)

list (APPEND SuiteSparse_BIN_TARGETS umf4hb)
endif (WITH_FORTRAN AND CMAKE_Fortran_COMPILER_LOADED)

if (TARGET spqr)
Expand All @@ -1684,21 +1695,49 @@ if (WITH_DEMOS)
target_link_libraries (qrsimple PRIVATE SuiteSparse::SPQR)
target_link_libraries (qrsimplec PRIVATE SuiteSparse::SPQR)

list (APPEND SuiteSparse_BIN_TARGETS
qrdemo
qrdemoc
qrsimple
qrsimplec
)

if (TARGET gpuqrengine)
add_executable (qrdemo_gpu SPQR/Demo/qrdemo_gpu.cpp)
target_link_libraries (qrdemo_gpu PRIVATE
SuiteSparse::CHOLMOD
SuiteSparse::GPURuntime
SuiteSparse::SPQR
)

list (APPEND SuiteSparse_BIN_TARGETS
qrdemo_gpu
)
endif (TARGET gpuqrengine)
endif (TARGET spqr)
endif (WITH_DEMOS)

install (TARGETS ${_SuiteSparse_TARGETS} ${SuiteSparse_BIN_TARGETS}
EXPORT suitesparse-targets
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} COMPONENT Runtime
LIBRARY DESTINATION ${SuiteSparse_CMake_LIBDIR} COMPONENT Development
ARCHIVE DESTINATION ${SuiteSparse_CMake_LIBDIR} COMPONENT Development)

if (BUILD_CXSPARSE)
add_subdirectory (CXSparse)
endif (BUILD_CXSPARSE)

if (WIN32)
foreach (bin IN LISTS SuiteSparse_BIN_TARGETS)
install (CODE
"
include (BundleUtilities)
fixup_bundle (\$ENV{DESTDIR}\${CMAKE_INSTALL_PREFIX}/${CMAKE_INSTALL_BINDIR}/${bin}${CMAKE_EXECUTABLE_SUFFIX} \"\" \"\")
"
COMPONENT Runtime)
endforeach (bin)
endif (WIN32)

add_feature_info (CUDA WITH_CUDA "GPU accelerated CHOLMOD using CUDA")
add_feature_info (GPL WITH_GPL "GNU GPL modules")
add_feature_info (LGPL WITH_LGPL "GNU LGPL modules")
Expand Down

0 comments on commit e92f1bd

Please sign in to comment.